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.4308  0.4120 -0.5549 -0.0976 -0.1453
#> -0.2724 -0.6186  0.0142 -0.5900 -0.6579
#>  0.7876  0.0871 -0.2593  0.3299  0.1007
#> [ CPUFloatType{3,5} ]