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.1424  1.1235  0.4007  0.2574 -0.1097
#> -0.6556 -0.6592 -0.9366  0.3650  0.0776
#> -0.2478 -0.4547  0.3113  0.2522  0.3727
#> [ CPUFloatType{3,5} ]