scfocus.model.weight_init
- scfocus.model.weight_init(m)[source]
Initializes the weights of a neural network layer using the Xavier normal distribution and sets biases to zero.
- Parameters:
m (torch.nn.Module) – The neural network layer (usually nn.Linear) to initialize.
Notes
This function checks if the input module m is an instance of nn.Linear. If so, it initializes the weights (m.weight) using the Xavier normal distribution (also known as Glorot normal initialization) and sets the biases (m.bias) to zero. This initialization technique is designed to keep the weights of the neural network layers within a reasonable range during training, helping with convergence and preventing vanishing or exploding gradients.