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.3737 -1.2123  0.0864  0.1142  0.3002
#>  0.5584 -0.3336  0.5348 -0.1200 -0.5549
#>  0.6800  0.3521 -0.3174 -0.0033 -0.0166
#> [ CPUFloatType{3,5} ]