Skip to contents

Fills the input Tensor with a (semi) orthogonal matrix, as described in Exact solutions to the nonlinear dynamics of learning in deep linear neural networks - Saxe, A. et al. (2013). The input tensor must have at least 2 dimensions, and for tensors with more than 2 dimensions the trailing dimensions are flattened.

Usage

nn_init_orthogonal_(tensor, gain = 1)

Arguments

tensor

an n-dimensional Tensor

gain

optional scaling factor

Examples

if (torch_is_installed()) {
w <- torch_empty(3, 5)
nn_init_orthogonal_(w)
}
#> torch_tensor
#>  0.4583 -0.4041  0.3835  0.2760  0.6351
#> -0.6087  0.2951 -0.1355  0.5512  0.4693
#>  0.5221  0.3736 -0.0996  0.6652 -0.3680
#> [ CPUFloatType{3,5} ]