Pytorch's spectral normalization doesn't work with convolutional layers

Viewed 23

In the documentation there is a little example of applying spectral norm to a linear layer and it has the norm being equal to one.

However when I apply it to a conv layer it doesn't make the output equal to one. For example:

import torch
import torch.nn as nn
snm = nn.utils.spectral_norm(nn.Conv2d(20, 40, 3))

print(torch.linalg.matrix_norm(snm.weight, 2))

Is there something wrong with the way I implement it or am I measuring it wrong?

0 Answers
Related