diag_embed(input: Tensor, offset: int = 0, dim1: int = -2, dim2: int = -1)Embed the last dimension of input as the diagonal of a new matrix.
Inverse of lucid.diagonal. For a 1-D input of length n
the result is shape (n+|offset|, n+|offset|). For batch
inputs the last axis is treated as the diagonal vector and
dim1 / dim2 pick which two axes of the output carry the
matrix.
Parameters
inputTensorDiagonal values. Any shape; the last axis becomes the
diagonal of each output matrix.
offsetint= 0Diagonal offset.
0 (default) = main diagonal,
positive = above main, negative = below main. Output size
grows by |offset| along each matrix dimension.dim1int= -2First axis of the output matrix dimensions. Default
-2.dim2int= -1Second axis of the output matrix dimensions. Default
-1.Returns
Tensorinput.ndim + 1 dims: input's leading dims in order, and two
of size n + |offset| at dim1 (rows) and dim2 (columns).
Off-diagonal positions are zero.
Raises
IndexErrordim1 or dim2 outside [-(input.ndim + 1), input.ndim].ValueErrordim1 and dim2 name the same dim.