Normalizing flows are powerful tools for modeling complex probability distributions, but they traditionally assume data lives in a flat, Euclidean space. This paper introduces Riemannian Continuous Normalizing Flows (RCNFs), a method that natively models distributions on curved surfaces—like spheres and hyperbolic spaces—by defining flows as the solutions to ordinary differential equations (ODEs). By respecting the underlying geometry, RCNFs avoid the severe numerical artifacts of previous methods, leading to substantial performance gains on real-world manifold data like global earthquake and wildfire locations.
The Challenge of Curved Spaces
Many scientific domains generate data that naturally resides on curved surfaces, known mathematically as Riemannian manifolds. For example, global weather events happen on a sphere, and hierarchical biological processes are often best represented in hyperbolic space.
Standard normalizing flows implicitly assume a flat (Euclidean) geometry. If applied to manifold data, the model is "blind" to the geometry and boundaries, often placing probability mass outside the valid space. Previous attempts to fix this usually relied on projected methods: mapping the curved manifold onto a flat Euclidean space (e.g., using stereographic projection), applying a standard flow, and mapping it back.
However, you cannot perfectly map a sphere to a flat plane without creating singularities or distortions—much like how a Mercator map infinitely stretches the poles. This topological mismatch causes severe numerical instabilities during training, especially when data points are located near these projection singularities.
Riemannian Continuous Normalizing Flows (RCNFs)
The authors bypass the need for projection by building upon Continuous Normalizing Flows (CNFs). Instead of using discrete neural network layers to transform a simple distribution into a complex one, CNFs define the transformation as a continuous time-evolution of particles governed by an ODE.
To make this work natively on manifolds, the authors introduce several key innovations:
- Manifold Vector Fields: The flow is defined by a neural network that outputs a vector field on the manifold's tangent space. This tells a particle which direction to move along the curved surface.
- Projective ODE Solvers: Standard ODE solvers (like Runge-Kutta) don't respect manifold boundaries and will drift off the surface. The authors use a projective solver that computes the step in ambient space and immediately projects it back onto the manifold.
- Riemannian Change of Variables: In standard CNFs, calculating the likelihood requires computing the divergence of the vector field. The authors derive a new instantaneous change-of-variables formula that incorporates the Riemannian metric tensor, ensuring the density calculations correctly account for the curvature of the space.
- Geodesic Distance Layers: To help the neural network "understand" the space, the first layer computes geodesic (shortest-path) distances to learned hyperplanes, rather than standard Euclidean dot products.
Experimental Validation
The authors evaluated their model on both synthetic datasets (wrapped Gaussian distributions on the Poincaré disk and von Mises-Fisher distributions on a 2D sphere) and real-world Earth science data (locations of volcano eruptions, earthquakes, floods, and active fires).
Key Insights and Results
- Continuous flows sidestep topological roadblocks: Because RCNFs use ODEs to define the flow natively on the manifold, they don't require a bijective mapping between Euclidean space and the manifold. This elegantly avoids the mathematical impossibility of perfectly flattening a sphere.
- Immunity to Projection Failures: The authors demonstrated that when a target distribution is placed near the origin of a projection map, projected models suffer from exploding gradients and fail to fit the data. RCNFs are completely immune to this. On a synthetic sphere task, the RCNF achieved a Negative Log-Likelihood (NLL) of -1.78, completely crushing the stereographic baseline's NLL of 63.60.
- Superior Real-World Performance: The RCNF significantly outperformed both a Mixture of vMFs and a Stereographic CNF across all four Earth datasets. For example, on the Earthquake dataset, RCNF achieved an NLL of 0.19, compared to 0.43 for the stereographic model and 0.59 for the vMF mixture.
Qualitatively, visualizations of the learned distributions show that RCNFs produce much sharper, more accurate density maps (e.g., perfectly tracing the Pacific "Ring of Fire"). In contrast, projected baselines yield overly diffuse distributions that bleed into areas with no data. Furthermore, scaling the output vectors by the Riemannian metric and using geodesic input layers drastically improves convergence and prevents the ODE solver from requiring an exploding number of function evaluations (NFE).
Limitations and Future Work
While highly effective, RCNFs have some limitations. To scale to high dimensions, the authors use Hutchinson's trace estimator to approximate the divergence. However, on a sphere, the variance of this estimator scales with $1/\sin(\theta)$, which blows up near the poles. This forces the use of the exact (but computationally expensive) divergence calculation for some spherical tasks. Additionally, the custom geodesic distance layer improves performance but adds noticeable computational cost compared to a highly optimized standard linear layer.
Future work may involve choosing a different vector field basis—rather than the one induced by local coordinates—to alleviate the variance issues of the stochastic estimator, paving the way for scaling to massive spherical datasets.
Summary updated