Skip to contents

Fills the input Tensor with values according to the method described in Understanding the difficulty of training deep feedforward neural networks - Glorot, X. & Bengio, Y. (2010), using a normal distribution.

Usage

nn_init_xavier_normal_(tensor, gain = 1)

Arguments

tensor

an n-dimensional Tensor

gain

an optional scaling factor

Examples

if (torch_is_installed()) {
w <- torch_empty(3, 5)
nn_init_xavier_normal_(w)
}
#> torch_tensor
#> -0.1958 -1.2098 -0.3898 -0.4418  0.3574
#> -0.2345  0.5271  0.5841 -0.1748  0.3071
#> -0.8960 -0.1640 -0.1738  0.7133  0.8885
#> [ CPUFloatType{3,5} ]