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.6287 -0.5792 -0.1305 -0.1029  0.0325
#>  0.6539  0.0275 -0.2274  0.5379 -0.0562
#> -0.2081 -0.2833  0.1389  0.3959 -0.8699
#> [ CPUFloatType{3,5} ]