PyTorch torch.svd function
PyTorch torch reference manual
torch.svd 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 examples
Example
import
torch
A
=
torch.
randn
(
3
,
4
)
SVD decomposition
U
,
S
,
V
=
torch.
svd
(
A
)
(
"U shape:"
,
U.
shape
)
(
"S shape:"
,
S.
shape
)
(
"V shape:"
,
V.
shape
)
The output is:
U 形状: torch.Size([3, 3])
S 形状: torch.Size([3])
V 形状: torch.Size([4, 4])