PyTorch torch.inverse function
PyTorch torch reference manual
torch.inverse A function in PyTorch for computing the inverse of a matrix.
Function definition
torch.inverse(input, out)
Usage examples
Example
import
torch
A
=
torch.
tensor
(
[
[
4.0
,
7.0
]
,
[
2.0
,
6.0
]
]
)
Compute the inverse matrix
A_inv
=
torch.
inverse
(
A
)
(
"Inverse matrix:"
)
(
A_inv
)
Verify: A @ A_inv ~= I
(
"A @ A_inv:"
)
(
torch.
mm
(
A
,
A_inv
)
)