megengine.module.init.xavier_uniform_

xavier_uniform_(tensor, gain=1.0)[source]

Fills tensor with random values sampled from \(\mathcal{U}(-a, a)\) where

\[a = \text{gain} \times \sqrt{\frac{6}{\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 \(a\).

Return type

None