megengine.module.init.xavier_normal_#

xavier_normal_(tensor, gain=1.0)[source]#

Fills tensor with random values sampled from \(\mathcal{N}(0, \text{std}^2)\) where

\[\text{std} = \text{gain} \times \sqrt{\frac{2}{\text{fan_in} + \text{fan_out}}}\]

Also known as Glorot initialization. Detailed information can be retrieved from Understanding the difficulty of training deep feedforward neural networks - Glorot, X. & Bengio, Y. (2010).

Parameters:
  • tensor (Tensor) – tensor to be initialized.

  • gain (float) – scaling factor for \(std\).

Return type:

None