Stiefel Manifold

\(\operatorname{St}(n,k)\) is the Stiefel manifold, that is, the rectangular matrices with orthonormal columns for \(n \geq k\):

\[\operatorname{St}(n,k) = \{X \in \mathbb{R}^{n\times k}\:\mid\:X^\intercal X = \mathrm{I}_k\}\]

If \(n < k\), then we consider the space of matrices with orthonormal rows, that is, \(X^\intercal \in \operatorname{St}(n,k)\).

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

Manifold of rectangular orthogonal matrices parametrized as a projection onto the first \(k\) columns from the space of square orthogonal matrices \(\operatorname{SO}(n)\). 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)[source]

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 to init_. This matrix will be then projected onto \(\operatorname{SO}(n)\) using self.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)[source]

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