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.1319 -0.4703 -0.6449  1.7380  0.4386
#> -0.1114  0.3421  0.5100  0.5488  0.0384
#>  0.5420  0.0599  0.0501  0.2710  0.3871
#> [ CPUFloatType{3,5} ]