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.0550  0.7787  1.1692 -0.3118 -1.3273
#> -0.1758  1.0264  0.6925 -0.1937 -0.3805
#> -0.3389 -1.8120  1.2768 -1.2641 -0.1301
#> [ CPUFloatType{3,5} ]