From my understanding, torch.norm when p=2 should give the spectral norm, i.e. largest singular value of a matrix:
A = torch.eye(2)
norm = torch.norm(A, p=2)
The singular values of A
are of course 1 and 1, and so the max s.v. should also be 1. But the returned value norm
is sqrt(2) which is the Frobenius norm.
I’ve also tried various values of dim
to no avail.
[Update: It looks like this is a high priority issue https://github.com/pytorch/pytorch/issues/24802 ]