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

PyTorch torch.matrix_power function

PyTorch torch.matrix_power function


PyTorch torch reference manual PyTorch torch reference manual

torch.matrix_power is a function in PyTorch used to compute matrix powers.

Function definition

torch.matrix_power(input, n)


Usage examples

Example

import

torch

Create a square matrix

A

=

torch.

tensor

(

[

[

1.0

,

2.0

]

,

[

3.0

,

4.0

]

]

)

Compute the 3rd power of a matrix

A_power

=

torch.

matrix_power

(

A

,

3

)

print

(

"Matrix power:"

)

print

(

A_power

)


PyTorch torch reference manual PyTorch torch reference manual