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.0424  0.2832 -0.3343 -0.6013  0.1106
#>  0.3355 -1.1788 -1.0792  0.3414 -0.1957
#> -0.5356  1.0430 -0.1331 -0.0899  0.5079
#> [ CPUFloatType{3,5} ]