| 52 | |
| 53 | |
| 54 | class LinearWN_v2(torch.nn.Linear): |
| 55 | def __init__(self, in_features, out_features, bias=True): |
| 56 | super(LinearWN_v2, self).__init__(in_features, out_features, bias) |
| 57 | self.g = torch.nn.Parameter(torch.ones(out_features)) |
| 58 | |
| 59 | |
| 60 | self.in_features=in_features |
| 61 | self.out_features=out_features |
| 62 | |
| 63 | def forward(self, input): |
| 64 | w= torch._weight_norm(self.weight, self.g, 0) |
| 65 | out=F.linear(input, w, self.bias) |
| 66 | return out |
| 67 | |
| 68 | |
| 69 |