Grassmannian Manifold
\(\operatorname{Gr}(n,k)\) is the Grassmannian manifold, that is, the subspaces of dimension \(k\) in \(\mathbb{R}^n\). A subspace is represented by an element of the Stiefel Manifold, which represents the vectors in the basis that span the subspace.
- class geotorch.Grassmannian(size, triv='expm')[source]
Grassmannian manifold as a projection from the orthogonal matrices \(\operatorname{St}(n,k)\). The metric considered is the canonical.
- 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 surjectively. It can be one of
["expm", "cayley"]
or a custom callable. Default:"expm"
- sample(distribution='uniform', init_=None)
Returns a randomly sampled orthogonal matrix according to the specified
distribution
. The options are:"uniform"
: Samples a tensor distributed according to the Haar measure on \(\operatorname{SO}(n)\)"torus"
: Samples a block-diagonal skew-symmetric matrix. The blocks are of the form \(\begin{pmatrix} 0 & b \\ -b & 0\end{pmatrix}\) where \(b\) is distributed according toinit_
. This matrix will be then projected onto \(\operatorname{SO}(n)\) usingself.triv
- Parameters
distribution (string) – Optional. One of
["uniform", "torus"]
. Default:"uniform"
init_ (callable) – Optional. To be used with the
"torus"
option. A function that takes a tensor and fills it in place according to some distribution. See torch.init. Default: \(\operatorname{Uniform}(-\pi, \pi)\)
- in_manifold(X, eps=0.0001)
Checks that a matrix is in the manifold.
For tensors with more than 2 dimensions the first dimensions are treated as batch dimensions.
- Parameters
X (torch.Tensor) – The matrix to be checked
eps (float) – Optional. Tolerance to numerical errors. Default:
1e-4