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.2088 -0.4128 -0.8802 -0.0136  0.1055
#>  0.4632 -0.5653  0.4194 -0.4373  0.3142
#> -0.4075  0.3174 -0.1865 -0.7347  0.3983
#> [ CPUFloatType{3,5} ]