PyTorch torch.svd 関数
torch.svdは PyTorch で行列の特異値分解を計算するための関数です。
関数定義
torch.svd(input, some, compute_uv, out)
使用例
例
import torch
A = torch.randn(3, 4)
# SVD 分解
U, S, V = torch.svd(A)
print("U の形状:", U.shape)
print("S の形状:", S.shape)
print("V の形状:", V.shape)
A = torch.randn(3, 4)
# SVD 分解
U, S, V = torch.svd(A)
print("U の形状:", U.shape)
print("S の形状:", S.shape)
print("V の形状:", V.shape)
出力結果は次のとおりです:
U 形状: torch.Size([3, 3]) S 形状: torch.Size([3]) V 形状: torch.Size([4, 4])
その他の拡張
Pytorch torch リファレンスマニュアル