Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.inverse function

PyTorch torch.inverse function


PyTorch torch reference manual 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

)

print

(

"Inverse matrix:"

)

print

(

A_inv

)

Verify: A @ A_inv ~= I

print

(

"A @ A_inv:"

)

print

(

torch.

mm

(

A

,

A_inv

)

)


PyTorch torch reference manual PyTorch torch reference manual