Positive Semidefinite Matrices
\(\operatorname{PSSD}(n)\) is the algebraic variety of positive semidefinite matrices.
It is realized via an eigenvalue-like factorization:
where we have identified the vector \(\Lambda\) with a diagonal matrix in \(\mathbb{R}^{n \times n}\) and \(\left|\Lambda\right|\) denotes the absolute value of the diagonal entries.
- class geotorch.PSSD(size, triv='expm')[source]
Manifold of symmetric positive semidefinite matrices
- Parameters
size (torch.size) – Size of the tensor to be parametrized
triv (str or callable) – Optional. A map that maps skew-symmetric matrices onto the orthogonal matrices 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()
- Parameters
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.
- Parameters
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