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 uniform distribution.

Usage

nn_init_xavier_uniform_(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_uniform_(w)
}
#> torch_tensor
#>  0.1698 -0.5148  0.2646  0.2990 -0.2563
#> -0.8303 -0.7034 -0.5871  0.2572  0.6939
#>  0.1074  0.1310 -0.2852  0.1093 -0.5368
#> [ CPUFloatType{3,5} ]