Score Matching Riemannian Diffusion Means

Frederik Möbius Rygaard, Steen Markvorsen, Søren Hauberg, Stefan SommerarXiv 2025 · DOI

TL;DR

Calculating the average of data on curved surfaces (manifolds) is notoriously slow because it usually requires computing complex "shortest-path" distances. This paper adapts the score matching techniques used in modern generative AI to learn the "score" (gradient) of Brownian motion on manifolds, enabling fast, scalable estimation of both diffusion and Fréchet means with linear rather than cubic complexity.

What Problem Does This Paper Address?

In standard Euclidean space, finding the mean is easy: just sum the points and divide by $N$. However, much of our most interesting data lives on Riemannian manifolds—curved spaces like the surface of a sphere (global coordinates), the space of human poses (landmarks), or symmetric positive definite matrices (brain imaging).

On these manifolds, the standard "average" is the Fréchet mean, which minimizes the sum of squared geodesic (shortest-path) distances. The challenge is that for most manifolds, we don't have a simple formula for these distances. Calculating them requires solving complex differential equations, which is computationally expensive and scales poorly ($O(d^3)$) as the dimension $d$ of the data increases.

An alternative is the diffusion $t$-mean, which is the "most likely" starting point for a Brownian motion process that ends up at your data points. While theoretically elegant, it requires knowing the "heat kernel" (transition density), which is also rarely available in closed form.

Methods

The authors propose using Riemannian Score Matching to bypass the need for closed-form distance functions or densities.

  1. Learning the Score: Instead of trying to calculate the transition density $p_t(x, y)$ directly, they train a neural network to learn its gradient, $\nabla_y \log p_t(x, y)$, known as the score.
  2. Denoising Score Matching (DSM): They adapt DSM to manifolds. This allows them to train the network using only sampled paths of Brownian motion (which are relatively easy to simulate) without ever needing to know the underlying density function.
  3. Gradient Descent for Means: Once the score network is trained, finding the diffusion mean becomes a simple gradient descent problem. The network provides the "direction" to move toward the mean at every step.
  4. The Fréchet Connection: The authors leverage a key mathematical insight: as the diffusion time $t$ approaches zero, the score-based gradient converges to the gradient needed to find the Fréchet mean. Thus, one trained model can estimate both types of means.

Datasets

The paper evaluates the method across a variety of synthetic and real-world manifold datasets:

  • Synthetic Manifolds: Standard Euclidean spaces ($\mathbb{R}^d$), spheres ($S^d$), and spaces of symmetric/positive definite matrices ($Sym(n)$, $P(n)$).
  • AFLW-2000: A dataset of 2,000 images with 3D facial landmarks and head-pose Euler angles (mapped to $S^3$).
  • Biological Landmarks: Shape spaces for butterfly wings and cardiac data (30 × 2 landmarks).
  • DTI Tensors: Diffusion Tensor Imaging data from the Human Connectome Project (HCP), represented as $3 \times 3$ positive definite matrices.
  • Learned Manifolds: Rotated MNIST images where the manifold structure is learned via a Gaussian Process.

Key Insights and Ideas

  • Linear Scaling: This is the biggest "aha" moment. Traditional methods like bridge sampling scale cubically ($O(d^3)$) with the manifold's dimension. By using a fixed neural network architecture, the inference time for the mean scales linearly ($O(d)$).
  • Score as a Universal Proxy: The score function acts as a universal "compass" on the manifold. It doesn't just find means; it can be used to implement $k$-means clustering and geodesic regression without ever explicitly calculating a geodesic distance.
  • Robustness to "Smeariness": Fréchet means can sometimes be "smeary" (exhibiting slow convergence to the true distribution mean). Diffusion means, especially when the variance $t$ is estimated simultaneously, tend to be more robust and require fewer samples for a precise estimate.

Key Results

  • Massive Speedups: On a 10-dimensional sphere ($S^{10}$), the score-based method estimated the mean in ~1.8 seconds, compared to ~91.7 seconds for traditional bridge sampling—a ~50x speedup while maintaining similar accuracy.
  • High-Dimensional Scaling: The method successfully computed means for landmark spaces (butterfly and cardiac data) where bridge sampling was too computationally expensive to even attempt.
  • Practical Applications: The authors demonstrated a Riemannian $k$-means algorithm that correctly clustered head-pose data into "looking left," "looking right," and "straight ahead" categories using the learned scores.

Limitations and Future Work

  • Manifold Constraints: The current framework assumes manifolds are geodesically complete, orientable, and boundaryless. It may fail on manifolds with "edges" or singularities.
  • Training Overhead: While inference is fast, training the score network still requires simulating many Brownian paths. If the manifold metric is extremely complex, this initial training phase can be expensive.
  • Out-of-Distribution Scores: In very high-dimensional spaces, the score network might become inaccurate in regions where it didn't see any training samples (Brownian paths), potentially leading to biased mean estimates.
  • Higher-Order Derivatives: The authors suggest that investigating higher-order derivatives of the score could further stabilize and speed up the optimization schemes.

Summary updated

Abstract

Estimating means on Riemannian manifolds is generally computationally expensive because the Riemannian distance function is not known in closed-form for most manifolds. To overcome this, we show that Riemannian diffusion means can be efficiently estimated using score matching with the gradient of Brownian motion transition densities using the same principle as in Riemannian diffusion models. Empirically, we show that this is more efficient than Monte Carlo simulation while retaining accuracy and is also applicable to learned manifolds. Our method, furthermore, extends to computing the Fréchet mean and the logarithmic map for general Riemannian manifolds. We illustrate the applicability of the estimation of diffusion mean by efficiently extending Euclidean algorithms to general Riemannian manifolds with a Riemannian $k$-means algorithm and maximum likelihood Riemannian regression.
BibTeX
@misc{rygaard2025score,
  author = {Frederik Möbius Rygaard and Steen Markvorsen and Søren Hauberg and Stefan Sommer},
  title = {{Score Matching Riemannian Diffusion Means}},
  year = {2025},
  eprint = {2502.13106},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.13106},
}
Figure