PyTorch torch.adjoint 関数


Pytorch torch リファレンスマニュアル

torch.adjointは、PyTorch で行列の共役転置(adjoint)を計算するための関数です。実数行列の場合、これは転置と等価です。複素数行列の場合、転置した各要素の共役を取ったものを返します。

関数定義

torch.adjoint(input)

引数:

  • input(Tensor): 入力テンソル。

戻り値:

  • torch.Tensor: 入力テンソルの共役転置を返します。

使用例

実例 - 実数行列

import torch

# 実数行列を作成
A = torch.tensor([[1, 2, 3], [4, 5, 6]])

# 共役転置を計算
result = torch.adjoint(A)

print("元の行列:")
print(A)
print("形状:", A.shape)
print("共役転置:")
print(result)
print("形状:", result.shape)

出力結果は次のとおりです:

原矩阵:
tensor([[1, 2, 3],
        [4, 5, 6]])
形状: torch.Size([2, 3])
共轭转置:
tensor([[1, 4],
        [2, 5],
        [3, 6]])
形状: torch.Size([3, 2])

実例 - 複素数行列

import torch

# 複素数行列を作成
A = torch.tensor([[1+1j, 2+2j], [3+3j, 4+4j]])

# 共役転置を計算
result = torch.adjoint(A)

print("元の行列:")
print(A)
print("共役転置:")
print(result)

Pytorch torch リファレンスマニュアル

その他の拡張