nn.Conv2d but with normalized fan-in init
(*args, scale=1, **kwargs)
| 16 | |
| 17 | |
| 18 | def NormedConv2d(*args, scale=1, **kwargs): |
| 19 | """ |
| 20 | nn.Conv2d but with normalized fan-in init |
| 21 | """ |
| 22 | out = nn.Conv2d(*args, **kwargs) |
| 23 | out.weight.data *= scale / out.weight.norm(dim=(1, 2, 3), p=2, keepdim=True) |
| 24 | if kwargs.get("bias", True): |
| 25 | out.bias.data *= 0 |
| 26 | return out |
| 27 | |
| 28 | |
| 29 | def intprod(xs): |