importtorchfromtorch.autogradimportVariablefromweight_normimportWeightNorm# weight-normalize linear.weight and linear.biaslinear=WeightNorm(torch.nn.Linear(2, 3), ["weight", "bias"])
y=linear(Variable(torch.randn(5, 2))) # used as same as Linear# weight-normalize conv.weight and conv.biasconv=WeightNorm(torch.nn.Conv1d(2, 3, 3), ["weight", "bias"])
y=conv(Variable(torch.randn(5, 2, 7))) # used as same as Conv1d
tested parts
gradient check (numerical and autograd comparison)