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 参考手册