spd_learn.functional.lie_group_variance#

spd_learn.functional.lie_group_variance(X_centered: Tensor, metric: str, alpha: float = 1.0, beta: float = 0.0, theta: float = 1.0) → Tensor[source]#

Fréchet variance under a Lie group structure on the SPD manifold.

Computes the scalar dispersion of centered data in the Lie algebra, using the bi-invariant distance of Chen et al. [Chen et al., 2024]:

\[\sigma^2 = \frac{1}{N} \sum_i \bigl(\alpha \lVert V_i \rVert_F^2 + \beta \, g(V_i)^2\bigr) \;/\; \theta^2\]

where the auxiliary term \(g\) depends on the metric:

  • AIM: \(V_i = \log(X_i)\), \(g(V) = \log\det(X)\)

  • LEM: \(V_i = X_i\) (already in log space), \(g(V) = \operatorname{tr}(V)\), no \(\theta\) scaling

  • LCM: same as LEM but with \(\theta\) scaling

Parameters:
  • X_centered (torch.Tensor) – Centered data in the Lie algebra with shape (batch_size, …, n, n). For AIM these are SPD matrices (centered around identity); for LEM/LCM these are symmetric / lower-triangular matrices.

  • metric ({"AIM", "LEM", "LCM"}) – Lie group structure.

  • alpha (float, default=1.0) – Frobenius-norm weight.

  • beta (float, default=0.0) – Trace / log-determinant weight.

  • theta (float, default=1.0) – Power deformation parameter.

Returns:

Scalar variance (0-d tensor).

Return type:

torch.Tensor

See also

tangent_space_variance()

Unweighted tangent-space dispersion used

by

class:~spd_learn.modules.SPDBatchNormMeanVar.