Returns a partial view of input with the its diagonal elements with respect to dim1 and dim2 appended as a dimension at the end of the shape.
tch_diagonal(x, offset = 0, dim1 = 0, dim2 = 1)
x | tensor object |
---|---|
offset | which diagonal to consider |
dim1 | first dimension with respect to which to take diagonal |
dim2 | second dimension with respect to which to take diagonal |
The argument offset controls which diagonal to consider:
If offset = 0, it is the main diagonal. If offset > 0, it is above the main diagonal. If offset < 0, it is below the main diagonal.
tch_diag()
tch_diagonal()
#> tensor #> 1 #> 4 #> [ Variable[CPUIntType]{2} ]