torch.linalg.svdvals¶
-
torch.linalg.
svdvals
(A, *, out=None) → Tensor¶ Computes the singular values of a matrix.
Supports input of float, double, cfloat and cdouble dtypes. Also supports batches of matrices, and if
A
is a batch of matrices then the output has the same batch dimensions.The singular values are returned in descending order.
Note
This function is equivalent to NumPy’s linalg.svd(A, compute_uv=False).
Note
When inputs are on a CUDA device, this function synchronizes that device with the CPU.
See also
torch.linalg.svd()
computes the full singular value decomposition.- Parameters
A (Tensor) – tensor of shape (*, m, n) where * is zero or more batch dimensions.
- Keyword Arguments
out (Tensor, optional) – output tensor. Ignored if None. Default: None.
- Returns
A real-valued tensor, even when
A
is complex.
Examples:
>>> import torch >>> a = torch.randn(5, 3) >>> a tensor([[-1.3490, -0.1723, 0.7730], [-1.6118, -0.3385, -0.6490], [ 0.0908, 2.0704, 0.5647], [-0.6451, 0.1911, 0.7353], [ 0.5247, 0.5160, 0.5110]]) >>> s = torch.linalg.svdvals(a) >>> s tensor([2.5139, 2.1087, 1.1066])