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.0352  0.7292  0.5037  0.6919  0.0880
#> -0.6865 -0.4254  0.0470  0.6638 -0.7051
#>  0.6776 -0.6500 -0.7674 -0.1183  0.8304
#> [ CPUFloatType{3,5} ]