megengine.module.init.xavier_normal_

xavier_normal_(tensor, gain=1.0)[源代码]

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}}}\]

又称Glorot初始化。详细的说明可以参考 “Understanding the difficulty of training deep feedforward neural networks”

参数
  • tensor (Tensor) – 待初始化的n维张量。

  • gain (float) – \(std\) 的比例因子。

返回类型

None