net = nn.Sequential(*[module for _ in range(10) for module in
(nn.Linear(256, 256, bias=False), nn.ReLU())])
X = torch.randn(1024, 256)
print(f'default: mean square of the output {net(X).pow(2).mean():.2g}')
def init_he(module):
if isinstance(module, nn.Linear):
nn.init.kaiming_normal_(module.weight, nonlinearity='relu')
net.apply(init_he)
print(f'He: mean square of the output {net(X).pow(2).mean():.2g}')