PyTorch torch.mm 関数
torch.mmは PyTorch で2次元行列乗算を実行するための関数です。
関数定義
torch.mm(input, mat2, out)
使用例
実例
import torch
A = torch.randn(2, 3)
B = torch.randn(3, 4)
# 行列乗算
C = torch.mm(A, B)
print("A の形状:", A.shape)
print("B の形状:", B.shape)
print("C の形状:", C.shape)
A = torch.randn(2, 3)
B = torch.randn(3, 4)
# 行列乗算
C = torch.mm(A, B)
print("A の形状:", A.shape)
print("B の形状:", B.shape)
print("C の形状:", C.shape)
出力結果は:
A 形状: torch.Size([2, 3]) B 形状: torch.Size([3, 4]) C 形状: torch.Size([2, 4])
その他の拡張
Pytorch torch リファレンスマニュアル