Skip to contents

Fills the input Tensor with values drawn from a truncated normal distribution.

Usage

nn_init_trunc_normal_(tensor, mean = 0, std = 1, a = -2, b = 2)

Arguments

tensor

an n-dimensional Tensor

mean

the mean of the normal distribution

std

the standard deviation of the normal distribution

a

the minimum cutoff value

b

the maximum cutoff value

Examples

if (torch_is_installed()) {
w <- torch_empty(3, 5)
nn_init_trunc_normal_(w)
}
#> torch_tensor
#>  0.6464 -0.6509  0.2012 -0.7992  0.5492
#>  1.3356  0.8301  0.9598  1.3211  0.6400
#> -0.6911  0.9428 -0.5856 -1.6574  0.1572
#> [ CPUFloatType{3,5} ]