Pinverse
Source:R/gen-namespace-docs.R, R/gen-namespace-examples.R, R/gen-namespace.R
torch_pinverse.RdPinverse
Note
The pseudo-inverse is not necessarily a continuous function in the elements of the matrix `[1]`_.
Therefore, derivatives are not always existent, and exist for a constant rank only `[2]`_.
However, this method is backprop-able due to the implementation by using SVD results, and
could be unstable. Double-backward will also be unstable due to the usage of SVD internally.
See `~torch.svd` for more details.pinverse(input, rcond=1e-15) -> Tensor
Calculates the pseudo-inverse (also known as the Moore-Penrose inverse) of a 2D tensor.
Please look at Moore-Penrose inverse_ for more details
Examples
if (torch_is_installed()) {
input = torch_randn(c(3, 5))
input
torch_pinverse(input)
# Batched pinverse example
a = torch_randn(c(2,6,3))
b = torch_pinverse(a)
torch_matmul(b, a)
}
#> torch_tensor
#> (1,.,.) =
#> 1.0000e+00 -6.9734e-08 5.1379e-08
#> -7.6204e-08 1.0000e+00 -1.0219e-07
#> 8.4445e-09 5.0922e-08 1.0000e+00
#>
#> (2,.,.) =
#> 1.0000e+00 1.9386e-07 1.0613e-07
#> 1.2553e-07 1.0000e+00 -3.1713e-08
#> 5.1747e-08 4.3823e-08 1.0000e+00
#> [ CPUFloatType{2,3,3} ]