NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Closed Form Distance Metric Learning

56 concepts41 papers1 proposal

At the heart of many machine learning tasks—such as clustering, image retrieval, and person re-identification—is the need to measure the distance between data points. Standard Euclidean distance treats all dimensions equally, which rarely aligns with semantic reality. To fix this, distance metric learning aims to find a transformation matrix $M$ that defines a Mahalanobis distance:

$$d_M(x, y) = \sqrt{(x-y)^T M (x-y)}$$

For $d_M$ to be a valid metric, $M$ must be a Symmetric Positive Semidefinite (PSD) matrix. Traditionally, enforcing this PSD constraint requires Semidefinite Programming (SDP) or iterative gradient descent with costly projections back onto the PSD cone. These iterative approaches scale poorly, often requiring hours or days of computation, and are highly sensitive to hyperparameter tuning.

A powerful alternative paradigm bypasses iterative optimization entirely. By reframing the core objective functions of metric learning, we can derive closed-form analytical solutions. Instead of searching the space of matrices step-by-step, these methods compute the globally optimal metric in a single mathematical operation—reducing training times from hours to seconds.


The Spectral Shortcut: Generalized Eigenvalue Problems

The most intuitive way to eliminate iterative optimization is to reframe metric learning as a generalized eigenvalue problem. The goal is simple: find a projection that minimizes the distance between similar data pairs while maximizing the distance between dissimilar pairs.

When we express this objective as a ratio of quadratic forms (specifically, a ratio of trace functions capturing between-class and within-class variance), it takes the form of a Generalized Rayleigh Quotient:

$$\max_W \frac{\text{Tr}(W^T S_b W)}{\text{Tr}(W^T S_w W)}$$

Setting the derivative of this ratio to zero yields the generalized eigenvalue equation: $S_b w = \lambda S_w w$.

As demonstrated by Alipanahi et al. in Distance Metric Learning Versus Fisher Discriminant Analysis, this formulation unifies modern metric learning with classical Fisher Discriminant Analysis (FDA). Instead of running an iterative solver, the optimal transformation matrix is constructed directly from the top eigenvectors of $S_w^{-1} S_b$.

This spectral shortcut provides massive computational speedups while maintaining or improving classification accuracy. The mechanism has been adapted across several domains:


From Pairwise Constraints to Linear Regression

Traditional metric learning relies on pairwise or triplet constraints ("point $A$ should be closer to $B$ than to $C$"). This introduces an $O(n^2)$ or $O(n^3)$ combinatorial explosion in the number of constraints.

To circumvent this, we can reframe metric learning as a regression task. Instead of optimizing relative distances between all pairs, we map each data point directly to a predefined target in an "ideal" space. This converts a highly constrained optimization problem into an unconstrained least-squares or ridge regression problem, which can be solved globally via direct matrix inversion.

Pairwise Constraints (Iterative, O(n²))
[Point A] <---> [Point B] (Must be close)
[Point A] <---> [Point C] (Must be far)

Virtual/Reference Regression (Closed-Form, O(n))
[Point A] -------> [Predefined Target Vector A]
[Point B] -------> [Predefined Target Vector B]

In Regressive Virtual Metric Learning, Perrot et al. introduced the concept of mapping data points to "virtual points." By minimizing the squared Frobenius norm between the projected data and these targets, the optimal transformation matrix drops out via a single closed-form matrix inversion, completely avoiding projections onto the PSD cone.

Similarly, Zhou et al. proposed a regression framework against learned "reference points" in Easy Identification From Better Constraints: Multi-Shot Person Re-Identification From Reference Constraints, reducing the constraint complexity from $O(n^2)$ to $O(n)$ while guaranteeing global optimality.

This regression perspective yields massive practical advantages across diverse applications:


Bypassing Sampling with Closed-Form Distributional Metrics

When data objects are complex—such as images containing a "bag of pixels" or words with multiple meanings—it is often more accurate to represent them as probability distributions (like Gaussians or Gaussian Mixture Models) rather than single points. However, calculating the distance or similarity between two continuous distributions typically requires expensive numerical integration or Monte Carlo sampling.

To maintain efficiency, researchers choose specific kernel functions or distance metrics whose overlap integrals evaluate to an exact, closed-form algebraic expression.

The premier tool for this is the Expected Likelihood Kernel (ELK), which defines the similarity between two distributions $p(x)$ and $q(x)$ as the integral of their product:

$$K(p, q) = \int p(x)q(x)dx$$

In A Kernel Between Unordered Sets of Data: The Gaussian Mixture Approach, Siwei Lyu demonstrated that when $p(x)$ and $q(x)$ are Gaussian Mixture Models (GMMs), this integral evaluates to a simple closed-form sum of exponentials involving only the means and covariances of the mixtures. This allows exact similarity computations via basic matrix algebra, completely bypassing stochastic simulations.

This strategy of exploiting analytical integrals spans several domains:

  • Representation Learning: Athiwaratkun et al. leveraged the ELK in Multimodal Word Distributions to train Gaussian mixtures representing polysemous words, using the closed-form kernel as an efficient energy function during training.
  • Image-Text Matching: In Improved Probabilistic Image-Text Representations, Sanghyuk Chun used a closed-form metric combining mean Euclidean distance and variance sums to scale up probabilistic image-caption retrieval without the overhead of Monte Carlo sampling.
  • Statistical Reductions: Sajedi et al. introduced a symmetric, triangle-inequality-compliant probabilistic distance metric in A New Probabilistic Distance Metric with Application in Gaussian Mixture Reduction. Because it offers a closed-form solution for Gaussian mixtures, it enables highly stable and rapid mixture reduction algorithms.
  • Exponential Families: Nielsen et al. proved in On the Chi square and higher-order Chi distances for approximating f-divergences that for any distributions belonging to an affine exponential family, the integral of the density ratio can be solved analytically using the log-normalizer function, allowing exact Chi-square distance calculations.

Information Geometry and Manifold Optimization

The principle of closed-form optimization also extends to non-Euclidean spaces, such as information geometries (where kernel matrices are treated as probability distributions) and Riemannian manifolds (such as spaces of Symmetric Positive Definite matrices).

Instead of performing iterative Riemannian gradient descent—which requires expensive matrix decompositions at every step to stay on the curved manifold—the optimization problem can often be reframed so that the global optimum is found analytically.

In An Information Geometry Approach for Distance Metric Learning, Rong Jin minimized the Kullback-Leibler (KL) divergence between a data-driven kernel and an ideal label kernel. By framing the objective within information geometry, the optimal transformation matrix can be calculated via a closed-form solution, keeping training times nearly constant even as the number of samples grows.

For metric learning directly on Riemannian manifolds, Zhu et al. demonstrated in Towards Generalized and Efficient Metric Learning on Riemannian Manifold that the optimal transformation matrix can be derived as the closed-form solution to a algebraic Riccati equation. This geometric mean approach eliminates the need for iterative manifold projections entirely, providing a mathematically exact global optimum with minimal computational overhead.

Key Foundational Work

A Kernel Between Unordered Sets of Data: The Gaussian Mixture Approach (2005) — contributed 2 concept elements to this direction.
Learning Nonstructural Distance Metric by Minimum Cluster Distortion (2004) — contributed 1 concept elements to this direction.
History & citationVersion 2 · 2026-10-04

Current · Permanent link

  1. Version 2 (latest) · 2026-10-04 · 41 papers
  2. Version 1 · 2026-10-04 · 37 papers
Cite this direction

Latest version (a living page):

@misc{lacuna_closed_form_metric_optimization_ef6453be,
  title = {closed-form metric optimization},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/closed-form-metric-optimization/rdr_ef6453be7413424db8c97ff41b28677e},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-28},
}

This exact version (version 2, frozen text):

@misc{lacuna_closed_form_metric_optimization_ef6453be_v2,
  title = {closed-form metric optimization},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/closed-form-metric-optimization/rdr_ef6453be7413424db8c97ff41b28677e/v/2},
  note = {Version 2, frozen 2026-10-04. Accessed 2026-11-28},
}
About

These directions overlap with this one through shared papers.

See something wrong? Report a mistake