PyTorch torch.svd Function


Pytorch torch 参考手册PyTorch torch Reference Manual

torch.svdIt is a function in PyTorch used to compute the singular value decomposition of a matrix.

Function Definition

torch.svd(input, some, compute_uv, out)

Usage Example

Example

import torch

A = torch.randn(3, 4)

# SVD decomposition
U, S, V = torch.svd(A)

print("U shape:", U.shape)
print("S shape:", S.shape)
print("V shape:", V.shape)

The output is:

U 形状: torch.Size([3, 3])
S 形状: torch.Size([3])
V 形状: torch.Size([4, 4])

Pytorch torch 参考手册PyTorch torch Reference Manual

Other Extensions