Skip to content

Commit 65a5eb8

Browse files
ANotFoxpytorchmergebot
authored andcommitted
Fix for ambiguity in linalg.norm()'s ord argument of +2 & -2 (pytorch#155148)
Fixes pytorch#136453 ### Description --- Fixed the ambiguity by referencing a hyperlink to wikipedia's SVD/Singular Values section as per past discussion (by other contributors) on the above thread. In the ord argument, for values `+2` and `-2`, the `singular value` now points to [this section of singular values on the wiki SVD page](https://en.wikipedia.org/wiki/Singular_value_decomposition#Singular_values,_singular_vectors,_and_their_relation_to_the_SVD). ### Why not mention SVD --- For conciseness (expanding 'largest singular value' -> 'largest singular value of a SVD' is too much, i think, wrt rest of the table) --- I hope this is satisfactory. Please let me know if I have missed anything essential; cheers. Pull Request resolved: pytorch#155148 Approved by: https://github.com/Skylion007, https://github.com/lezcano
1 parent b084e1b commit 65a5eb8

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

torch/linalg/__init__.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,21 +1369,21 @@
13691369
13701370
:attr:`ord` defines the norm that is computed. The following norms are supported:
13711371
1372-
====================== ========================= ========================================================
1373-
:attr:`ord` norm for matrices norm for vectors
1374-
====================== ========================= ========================================================
1375-
`None` (default) Frobenius norm `2`-norm (see below)
1376-
`'fro'` Frobenius norm -- not supported --
1377-
`'nuc'` nuclear norm -- not supported --
1378-
`inf` `max(sum(abs(x), dim=1))` `max(abs(x))`
1379-
`-inf` `min(sum(abs(x), dim=1))` `min(abs(x))`
1380-
`0` -- not supported -- `sum(x != 0)`
1381-
`1` `max(sum(abs(x), dim=0))` as below
1382-
`-1` `min(sum(abs(x), dim=0))` as below
1383-
`2` largest singular value as below
1384-
`-2` smallest singular value as below
1385-
other `int` or `float` -- not supported -- `sum(abs(x)^{ord})^{(1 / ord)}`
1386-
====================== ========================= ========================================================
1372+
====================== ========================== ======================================================
1373+
:attr:`ord` norm for matrices norm for vectors
1374+
====================== ========================== ======================================================
1375+
`None` (default) Frobenius norm `2`-norm (see below)
1376+
`'fro'` Frobenius norm -- not supported --
1377+
`'nuc'` nuclear norm -- not supported --
1378+
`inf` `max(sum(abs(x), dim=1))` `max(abs(x))`
1379+
`-inf` `min(sum(abs(x), dim=1))` `min(abs(x))`
1380+
`0` -- not supported -- `sum(x != 0)`
1381+
`1` `max(sum(abs(x), dim=0))` as below
1382+
`-1` `min(sum(abs(x), dim=0))` as below
1383+
`2` largest `singular value`_ as below
1384+
`-2` smallest `singular value`_ as below
1385+
other `int` or `float` -- not supported -- `sum(abs(x)^{ord})^{(1 / ord)}`
1386+
====================== ========================== ======================================================
13871387
13881388
where `inf` refers to `float('inf')`, NumPy's `inf` object, or any equivalent object.
13891389
@@ -1483,6 +1483,9 @@
14831483
tensor([ 3.7417, 11.2250])
14841484
>>> LA.norm(A[0, :, :]), LA.norm(A[1, :, :])
14851485
(tensor(3.7417), tensor(11.2250))
1486+
1487+
.. _singular value:
1488+
https://en.wikipedia.org/wiki/Singular_value_decomposition#Singular_values,_singular_vectors,_and_their_relation_to_the_SVD
14861489
""",
14871490
)
14881491

0 commit comments

Comments
 (0)