mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Add overloads to diagonal docs (#144214)
Fixes #126827. Refactored doc to demonstrate when none of the optional values are passed in. Added another example so that all overloads of the function are covered. Pull Request resolved: https://github.com/pytorch/pytorch/pull/144214 Approved by: https://github.com/albanD
This commit is contained in:
parent
2af876707b
commit
a7c2d85c18
1 changed files with 8 additions and 1 deletions
|
|
@ -3611,13 +3611,20 @@ Examples::
|
|||
[ 0.6927, -0.3735, -0.4945]])
|
||||
|
||||
|
||||
>>> torch.diagonal(a, 0)
|
||||
>>> torch.diagonal(a)
|
||||
tensor([-1.0854, -0.0905, -0.4945])
|
||||
|
||||
|
||||
>>> torch.diagonal(a, 1)
|
||||
tensor([ 1.1431, 0.0360])
|
||||
|
||||
>>> b = torch.randn(2, 5)
|
||||
>>> b
|
||||
tensor([[-1.7948, -1.2731, -0.3181, 2.0200, -1.6745],
|
||||
[ 1.8262, -1.5049, 0.4114, 1.0704, -1.2607]])
|
||||
|
||||
>>> torch.diagonal(b, 1, 1, 0)
|
||||
tensor([1.8262])
|
||||
|
||||
>>> x = torch.randn(2, 5, 4, 2)
|
||||
>>> torch.diagonal(x, offset=-1, dim1=1, dim2=2)
|
||||
|
|
|
|||
Loading…
Reference in a new issue