torch / torch
torch.matrix_rank¶
-
torch.
matrix_rank
(input, tol=None, symmetric=False) → Tensor¶ Returns the numerical rank of a 2-D tensor. The method to compute the matrix rank is done using SVD by default. If
symmetric
isTrue
, theninput
is assumed to be symmetric, and the computation of the rank is done by obtaining the eigenvalues.tol
is the threshold below which the singular values (or the eigenvalues whensymmetric
isTrue
) are considered to be 0. Iftol
is not specified,tol
is set toS.max() * max(S.size()) * eps
where S is the singular values (or the eigenvalues whensymmetric
isTrue
), andeps
is the epsilon value for the datatype ofinput
.- Parameters
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)
此页内容是否对您有帮助