pytorch / pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration
https://pytorch.org
Other
83.14k stars 22.42k forks source link

The doc of `linalg.vector_norm()` should not say `ord` parameter accepts the `str` value `fro` or `nuc` #136563

Open hyperkai opened 3 weeks ago

hyperkai commented 3 weeks ago

📚 The doc issue

The doc of linalg.vector_norm() says ord parameter accepts the str value fro or nuc as shown below:

ord (int, float, inf, -inf, 'fro', 'nuc', optional) – order of norm. Default: 2

But ord parameter with fro or nuc doesn't work as shown below:

import torch
from torch import linalg

my_tensor = torch.tensor([[-2., -1., 0.],
                          [1., 2., 3.]])
linalg.vector_norm(input=my_tensor, ord='fro') # Error
                                  # ↑ ↑ ↑ ↑ ↑
linalg.vector_norm(input=my_tensor, ord='nuc') # Error
                                  # ↑ ↑ ↑ ↑ ↑

TypeError: linalg_vector_norm(): argument 'ord' must be Number, not str

TypeError: linalg_vector_norm(): argument 'ord' must be Number, not str

Suggest a potential alternative/fix

The doc of linalg.vector_norm() should not say ord parameter accepts the str value fro or nuc as shown below:

ord (int, float, inf, -inf, optional) – order of norm. Default: 2

ezyang commented 3 weeks ago

Send us a PR?