Learning Distances from Data with Normalizing Flows and Score Matching

Abstract

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.

Cite

Text

Sorrenson et al. "Learning Distances from Data with Normalizing Flows and Score Matching." Proceedings of the 42nd International Conference on Machine Learning, 2025.

Markdown

[Sorrenson et al. "Learning Distances from Data with Normalizing Flows and Score Matching." Proceedings of the 42nd International Conference on Machine Learning, 2025.](https://mlanthology.org/icml/2025/sorrenson2025icml-learning/)

BibTeX

@inproceedings{sorrenson2025icml-learning,
  title     = {{Learning Distances from Data with Normalizing Flows and Score Matching}},
  author    = {Sorrenson, Peter and Behrend-Uriarte, Daniel and Schnoerr, Christoph and Koethe, Ullrich},
  booktitle = {Proceedings of the 42nd International Conference on Machine Learning},
  year      = {2025},
  pages     = {56531-56548},
  volume    = {267},
  url       = {https://mlanthology.org/icml/2025/sorrenson2025icml-learning/}
}