PyTorch torch.inverse 関数


Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

torch.inversePyTorch で行列の逆行列を計算するための関数です。

関数定義

torch.inverse(input, out)

使用例

例

import torch

A = torch.tensor([[4.0, 7.0], [2.0, 6.0]])

# 逆行列を計算
A_inv = torch.inverse(A)

print("逆行列:")
print(A_inv)

# 検証: A @ A_inv ≈ I
print("A @ A_inv:")
print(torch.mm(A, A_inv))

Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

その他の拡張