Skip to content

torch.norm named arguments do not work as expected #1419

@szagoruyko

Description

@szagoruyko

torch.norm only accepts p, dim, giving only dim results in error

In [3]: torch.autograd.Variable(torch.randn(4,8)).norm(dim=1)
Out[3]:
Variable containing:
 2.1210
 3.0991
 2.4054
 2.1048
[torch.FloatTensor of size 4x1]

In [4]: torch.randn(4,8).norm(dim=1)

TypeError: norm received an invalid combination of arguments - got (dim=int, ), but expected one of:
 * no arguments
 * (float p)
      didn't match because some of the keywords were incorrect: dim
 * (float p, int dim)

In [8]: torch.randn(4,8).norm(p=2, dim=1)
Out[8]:

 1.9636
 2.1119
 2.8933
 4.0552
[torch.FloatTensor of size 4x1]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions