torch.block_diag
- torch.block_diag(*tensors)
Create a block diagonal matrix from provided tensors.
- Parameters:
*tensors – One or more tensors with 0, 1, or 2 dimensions.
- Returns:
A 2 dimensional tensor with all the input tensors arranged in order such that their upper left and lower right corners are diagonally adjacent. All other elements are set to 0.
- Return type