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
#>  1.2405  0.0297  0.1791 -1.1906  0.5827
#>  0.2368 -0.3485  0.4034  0.3764 -0.2217
#>  0.0696  0.0207 -0.4911 -0.1007  0.1210
#> [ CPUFloatType{3,5} ]