Init method based on N(0, sigma/sqrt(2*num_layers).
(sigma, num_layers)
| 162 | |
| 163 | |
| 164 | def scaled_init_method_normal(sigma, num_layers): |
| 165 | """Init method based on N(0, sigma/sqrt(2*num_layers).""" |
| 166 | std = sigma / math.sqrt(2.0 * num_layers) |
| 167 | |
| 168 | def init_(tensor): |
| 169 | return torch.nn.init.normal_(tensor, mean=0.0, std=std) |
| 170 | |
| 171 | return init_ |