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.1684 -0.1398  0.2939 -0.3984  0.3564
#> -0.1845  0.4227  0.1140 -0.2152  0.0355
#> -0.0383  0.6960  0.8225 -0.3174 -0.5964
#> [ CPUFloatType{3,5} ]