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.2697  0.2206 -0.0843  0.4508  0.2508
#>  0.7868  0.7061 -0.2003 -0.3160  0.6367
#>  0.0087  0.6960 -0.7163  0.1714  0.7592
#> [ CPUFloatType{3,5} ]