(shape, scale=1.0)
| 24 | return x |
| 25 | |
| 26 | def sample_truncated_normal(shape, scale=1.0): |
| 27 | stddev = np.sqrt(scale/shape[-1])/.87962566103423978 # shape[-1] = fan_in |
| 28 | return stddev * truncated_normal(torch.rand(shape)) |
| 29 | |
| 30 | module.weight = torch.nn.Parameter( (sample_truncated_normal(module.weight.shape)) ) |
| 31 | return module |
no test coverage detected