torch.matrix_rank¶
-
torch.matrix_rank(input, tol=None, symmetric=False, *, out=None) → Tensor¶ Returns the numerical rank of a 2-D tensor. The method to compute the matrix rank is done using SVD by default. If
symmetricisTrue, theninputis assumed to be symmetric, and the computation of the rank is done by obtaining the eigenvalues.tolis the threshold below which the singular values (or the eigenvalues whensymmetricisTrue) are considered to be 0. Iftolis not specified,tolis set toS.max() * max(S.size()) * epswhere S is the singular values (or the eigenvalues whensymmetricisTrue), andepsis the epsilon value for the datatype ofinput.Warning
torch.matrix_rank()is deprecated in favor oftorch.linalg.matrix_rank()and will be removed in a future PyTorch release. The parametersymmetricwas renamed intorch.linalg.matrix_rank()tohermitian.- Parameters
- Keyword Arguments
out (Tensor, optional) – the output tensor.
Example:
>>> a = torch.eye(10) >>> torch.matrix_rank(a) tensor(10) >>> b = torch.eye(10) >>> b[0, 0] = 0 >>> torch.matrix_rank(b) tensor(9)