spd_learn.functional.tangent_space_variance#

spd_learn.functional.tangent_space_variance(X_tangent: Tensor, mean_tangent: Tensor) → Tensor[source]#

Compute scalar dispersion in the tangent space.

Computes the mean squared Frobenius distance from the tangent space mean:

\[\sigma^2 = \frac{1}{N} \sum_{i=1}^N \|V_i - \bar{V}\|_F^2\]

where \(V_i = \log(M^{-1/2} X_i M^{-1/2})\) are the tangent vectors.

Parameters:
  • X_tangent (torch.Tensor) – Batch of tangent vectors (symmetric matrices) with shape (batch_size, …, n, n).

  • mean_tangent (torch.Tensor) – Mean tangent vector with shape (1, …, n, n).

Returns:

Scalar dispersion value (single number, not a variance matrix). This is the mean squared Frobenius distance from the tangent mean.

Return type:

torch.Tensor

Notes

This scalar dispersion is used for dispersion normalization in SPD batch normalization.

See also

karcher_mean_iteration()

Compute the Karcher mean.