# Learning Distances from Data with Normalizing Flows and Score Matching

arXiv: https://arxiv.org/abs/2407.09297 · HTML: https://mlsanity.com/paper/2407.09297/

## Key facts

- Cited by 10 papers in the map (data through 14 Oct 2026).
- Builds on 15 of its 33 references that are in the map.
- First posted on arXiv 12 Jul 2024.

## Builds on (most cited first, 15 of 15)

- [PyTorch: An Imperative Style, High-Performance Deep Learning Library](https://mlsanity.com/paper/1912.01703/) (2019)
- [Score-Based Generative Modeling through Stochastic Differential Equations](https://mlsanity.com/paper/2011.13456/) (2020)
- [Variational Inference with Normalizing Flows](https://mlsanity.com/paper/1505.05770/) (2015)
- [Density estimation using Real NVP](https://mlsanity.com/paper/1605.08803/) (2016)
- [Normalizing Flows for Probabilistic Modeling and Inference](https://mlsanity.com/paper/1912.02762/) (2019)
- [NICE: Non-linear Independent Components Estimation](https://mlsanity.com/paper/1410.8516/) (2014)
- [Neural Spline Flows](https://mlsanity.com/paper/1906.04032/) (2019)
- [Sliced Score Matching: A Scalable Approach to Density and Score Estimation](https://mlsanity.com/paper/1905.07088/) (2019)
- [Metric Flow Matching for Smooth Interpolations on the Data Manifold](https://mlsanity.com/paper/2405.14780/) (2024)
- [Path-Based Spectral Clustering: Guarantees, Robustness to Outliers, and Fast Algorithms](https://mlsanity.com/paper/1712.06206/) (2017)
- [Balancing Geometry and Density: Path Distances on High-Dimensional Data](https://mlsanity.com/paper/2012.09385/) (2020)
- [Fermat Distances: Metric Approximation, Spectral Convergence, and Clustering Algorithms](https://mlsanity.com/paper/2307.05750/) (2023)
- [Power Weighted Shortest Paths for Clustering Euclidean Data](https://mlsanity.com/paper/1905.13345/) (2019)
- [Minimax-optimal semi-supervised regression on unknown manifolds](https://mlsanity.com/paper/1611.02221/) (2016)
- [Exact Computation of a Manifold Metric, via Lipschitz Embeddings and Shortest Paths on a Graph](https://mlsanity.com/paper/1709.07797/) (2017)

## Built on by (most cited first, 10 of 10)

- [Probability Density Geodesics in Image Diffusion Latent Space](https://mlsanity.com/paper/2504.06675/) (2025)
- [Iso-Riemannian Optimization on Learned Data Manifolds](https://mlsanity.com/paper/2510.21033/) (2025)
- [Score-based Pullback Riemannian Geometry: Extracting the Data Manifold Geometry using Anisotropic Flows](https://mlsanity.com/paper/2410.01950/) (2024)
- [Be Tangential to Manifold: Discovering Riemannian Metric for Diffusion Models](https://mlsanity.com/paper/2510.05509/) (2025)
- [Geodesic Calculus on Implicitly Defined Latent Manifolds](https://mlsanity.com/paper/2510.09468/) (2025)
- [GeodesicNVS: Probability Density Geodesic Flow Matching for Novel View Synthesis](https://mlsanity.com/paper/2603.01010/) (2026)
- [Riemannian AmbientFlow: Towards Simultaneous Manifold Learning and Generative Modeling from Corrupted Data](https://mlsanity.com/paper/2601.18728/) (2026)
- [Riemannian Archetypal Analysis: Interpretable non-linear data analysis on deformed star distributions](https://mlsanity.com/paper/2605.24113/) (2026)
- [Learning Locally Adaptive Metrics that Enhance Structural Representation with textttLAMINAR](https://mlsanity.com/paper/2411.08557/) (2024)
- [Energy Guided Geometric Flow Matching](https://mlsanity.com/paper/2509.25230/) (2025)

## Abstract (arXiv)

Density-based distances (DBDs) provide a principled approach to metric learning by defining distances in terms of the underlying data distribution. By employing a Riemannian metric that increases in regions of low probability density, shortest paths naturally follow the data manifold. Fermat distances, a specific type of DBD, have attractive properties, but existing estimators based on nearest neighbor graphs suffer from poor convergence due to inaccurate density estimates. Moreover, graph-based methods scale poorly to high dimensions, as the proposed geodesics are often insufficiently smooth. We address these challenges in two key ways. First, we learn densities using normalizing flows. Second, we refine geodesics through relaxation, guided by a learned score model. Additionally, we introduce a dimension-adapted Fermat distance that scales intuitively to high dimensions and improves numerical stability. Our work paves the way for the practical use of density-based distances, especially in high-dimensional spaces.
