giagrad.Tensor.xavier_uniform#
- Tensor.xavier_uniform(gain=1.0) Tensor [source]#
Fills Tensor data with the also known Glorot uniform initialization.
This methos is described in Understanding the difficulty of training deep feedforward neural networks - Glorot, X. & Bengio, Y. (2010), using a uniform distribution. Tensor data will have values sampled from \(\mathcal{U}(-a, a)\) where
\[a = \text{gain} \times \sqrt{\frac{6}{\text{fan_in} + \text{fan_out}}}\]- Parameters:
gain¶ (float) – An optional scaling factor.
Examples
>>> from giagrad import calculate_gain >>> Tensor.empty(3, 5).xavier_uniform(gain=calculate_gain('relu'))