PyTorch torch.inverse Function
Pytorch torch Reference Manual
torch.inverseis a function in PyTorch used to compute the inverse of a matrix.
Function Definition
torch.inverse(input, out)
Usage Example
Example
import torch
A = torch.tensor([[4.0, 7.0], [2.0, 6.0]])
# Compute the inverse matrix
A_inv = torch.inverse(A)
print("Inverse matrix:")
print(A_inv)
# Verify: A @ A_inv ≈ I
print("A @ A_inv:")
print(torch.mm(A, A_inv))
A = torch.tensor([[4.0, 7.0], [2.0, 6.0]])
# Compute the inverse matrix
A_inv = torch.inverse(A)
print("Inverse matrix:")
print(A_inv)
# Verify: A @ A_inv ≈ I
print("A @ A_inv:")
print(torch.mm(A, A_inv))
Other Extensions