How to initialize the weights and biases (for example, with He or Xavier initialization) in a network in PyTorch?
Sorry for being so late, I hope my answer will help.
To initialise weights with a normal distribution
use:
torch.nn.init.normal_(tensor, mean=0, std=1)
Or to use a constant distribution
write:
torch.nn.init.constant_(tensor, value)
Or to use an uniform distribution
:
torch.nn.init.uniform_(tensor, a=0, b=1) # a: lower_bound, b: upper_bound
You can check other methods to initialise tensors here