Positive Semidefinite Low Rank Matrices

\(\operatorname{PSSDLowRank}(n,r)\) is the algebraic variety of positive semidefinite matrices of rank less or equal to \(r\), for a given \(r \leq n\):

\[\operatorname{PSSDLowRank}(n,r) = \{X \in \mathbb{R}^{n\times n}\:\mid\:X \succeq 0,\,\operatorname{rank}(X) \leq r\}\]

It is realized via an eigenvalue-like factorization:

\[\begin{split}\begin{align*} \pi \colon \operatorname{St}(n,r) \times \mathbb{R}^r &\to \operatorname{PSSDLowRank}(n,r) \\ (Q, \Lambda) &\mapsto Q\left|\Lambda\right| Q^\intercal \end{align*}\end{split}\]

where we have identified the vector \(\Lambda\) with a diagonal matrix in \(\mathbb{R}^{r \times r}\) and \(\left|\Lambda\right|\) denotes the absolute value of the diagonal entries.

class geotorch.PSSDLowRank(size, rank, triv='expm')[source]

Variety of the symmetric positive semidefinite matrices of rank at most \(r\).

  • size (torch.size) – Size of the tensor to be parametrized

  • rank (int) – Rank of the matrices. It has to be less or equal to \(\min(\texttt{size}[-1], \texttt{size}[-2])\)

  • triv (str or callable) – Optional. A map that maps skew-symmetric matrices onto the orthogonal matrices surjectively. This is used to optimize the \(Q\) in the eigenvalue decomposition. It can be one of ["expm", "cayley"] or a custom callable. Default: "expm"

sample(init_=<function xavier_normal_>, factorized=False)

Returns a randomly sampled matrix on the manifold as

\[WW^\intercal \qquad W_{i,j} \sim \texttt{init_}\]

By default init\_ is a (xavier) normal distribution, so that the returned matrix follows a Wishart distribution.

The output of this method can be used to initialize a parametrized tensor that has been parametrized with this or any other manifold as:

>>> layer = nn.Linear(20, 20)
>>> M = PSSD(layer.weight.size())
>>> geotorch.register_parametrization(layer, "weight", M)
>>> layer.weight = M.sample()

init_ (callable) – Optional. A function that takes a tensor and fills it in place according to some distribution. See torch.init. Default: torch.nn.init.xavier_normal_

in_manifold(X, eps=1e-06)

Checks that a matrix is in the manifold.

  • X (torch.Tensor) – The matrix or batch of matrices of shape (*, n, n) to check.

  • eps (float) – Optional. Threshold at which the singular values are considered to be zero. Default: 1e-6