fn
svdvals
→Tensorsvdvals(x: Tensor)Compute only the singular values of a matrix.
Returns the singular values (with ) of an input matrix
without forming or . Equivalent
to svd(A)[1] but avoids the work of constructing the singular
vectors.
Parameters
xTensorInput matrix of shape
(*, m, n).Returns
TensorSingular values in descending order, shape (*, k).
Notes
When gradients are required this routes through the full
svd so backward still works. Without requires_grad,
the engine kernel skips assembly of the singular vectors and is
roughly faster. Useful for computing
matrix_rank, cond, or the nuclear / spectral norms.
Examples
>>> import lucid
>>> from lucid.linalg import svdvals
>>> svdvals(lucid.tensor([[3.0, 0.0], [0.0, 4.0]]))
Tensor([4.0000, 3.0000])