torch.pca_lowrank — PyTorch 2.7 documentation (original) (raw)

torch.pca_lowrank(A, q=None, center=True, niter=2)[source][source]

Performs linear Principal Component Analysis (PCA) on a low-rank matrix, batches of such matrices, or sparse matrix.

This function returns a namedtuple (U, S, V) which is the nearly optimal approximation of a singular value decomposition of a centered matrix AA such that A≈Udiag⁡(S)VHA \approx U \operatorname{diag}(S) V^{\text{H}}

Note

The relation of (U, S, V) to PCA is as follows:

Note

Different from the standard SVD, the size of returned matrices depend on the specified rank and q values as follows:

Note

To obtain repeatable results, reset the seed for the pseudorandom number generator

Parameters

Return type

tuple[torch.Tensor, torch.Tensor, torch.Tensor]

References: