spd_learn.modules.ExpEig#
- class spd_learn.modules.ExpEig(upper=False, flatten=False, autograd=False, device=None, dtype=None)[source]#
Bases:
ModuleExponential Eigenvalue Layer (ExpEig).
This layer maps symmetric matrices from the tangent space back to the SPD manifold via the matrix exponential [Huang and Van Gool, 2017]. It is the inverse operation of
LogEig.\[\exp(X) = U \exp(\Lambda) U^\top\]where \(X = U \Lambda U^\top\) is the eigendecomposition of the symmetric input matrix, and \(\exp(\Lambda)\) applies the exponential element-wise to eigenvalues.
Geometric Interpretation
The exponential map \(\exp_I: T_I\mathcal{S}_{++}^n \to \mathcal{S}_{++}^n\) projects tangent vectors at the identity to points on the SPD manifold. This enables:
Manifold reconstruction: After processing in tangent space (e.g., via Euclidean layers), data can be projected back to valid SPD matrices.
Generative models: Sampling in tangent space and mapping to manifold.
Residual connections: Combined with LogEig for manifold-aware skip connections.
Since \(\exp(\cdot)\) always produces positive values, the output is guaranteed to be SPD regardless of the input symmetric matrix.
- Parameters:
upper (bool, default=False) – If True, assumes the input is an upper-triangular vectorized symmetric matrix of shape
(..., n(n+1)/2)and reconstructs the full symmetric matrix before applying the exponential.flatten (bool, default=False) – If True, assumes the input is a flattened symmetric matrix of shape
(..., n*n)and reshapes it to(..., n, n)before applying the exponential.autograd (bool, default=False) – Whether to use the autograd backend.
See also
LogEigInverse operation, maps SPD to tangent space.
ReEigEigenvalue rectification for numerical stability.
matrix_exp()Functional version.
LogEuclideanResidualUses exp/log for manifold residuals.
- forward(X: Tensor) Tensor[source]#
Forward pass of the ExpEig layer.
- Parameters:
X (torch.Tensor) – Input symmetric matrix or vectorized tangent vector. If
upper=True, expects upper-triangular vectorized input of shape(..., n(n+1)/2). Ifflatten=True, expects flattened input of shape(..., n*n). Otherwise, expects a full symmetric matrix(..., n, n).- Returns:
The output SPD matrix of shape
(..., n, n).- Return type: