Skip to contents

Fills the input Tensor with values according to the method described in Delving deep into rectifiers: Surpassing human-level performance on ImageNet classification - He, K. et al. (2015), using a normal distribution.

Usage

nn_init_kaiming_normal_(
  tensor,
  a = 0,
  mode = "fan_in",
  nonlinearity = "leaky_relu"
)

Arguments

tensor

an n-dimensional torch.Tensor

a

the negative slope of the rectifier used after this layer (only used with 'leaky_relu')

mode

either 'fan_in' (default) or 'fan_out'. Choosing 'fan_in' preserves the magnitude of the variance of the weights in the forward pass. Choosing 'fan_out' preserves the magnitudes in the backwards pass.

nonlinearity

the non-linear function. recommended to use only with 'relu' or 'leaky_relu' (default).

Examples

if (torch_is_installed()) {
w <- torch_empty(3, 5)
nn_init_kaiming_normal_(w, mode = "fan_in", nonlinearity = "leaky_relu")
}
#> torch_tensor
#>  0.2824 -0.0212  0.2276 -0.5135  0.3246
#>  0.7331 -0.4224  0.7006 -1.0394 -0.2069
#> -0.0020 -1.2986  0.1520 -0.5600  0.3546
#> [ CPUFloatType{3,5} ]