Abstract
We propose a novel algorithm for the task of supervised discriminative distance learning by nonlinearly embedding vectors into a low dimensional Euclidean space. We work in the challenging setting where supervision is with constraints on similar and dissimilar pairs while training. The proposed method is derived by an approximate kernelization of a linear Mahalanobis-like distance metric learning algorithm and can also be seen as a kernel neural network. The number of model parameters and test time evaluation complexity of the proposed method are O(dD) where D is the dimensionality of the input features and d is the dimension of the projection space - this is in contrast to the usual kernelization methods as, unlike them, the complexity does not scale linearly with the number of training examples. We propose a stochastic gradient based learning algorithm which makes the method scalable (w.r.t. the number of training examples), while being nonlinear. We train the method with up to half a million training pairs of 4096 dimensional CNN features. We give empirical comparisons with relevant baselines on seven challenging datasets for the task of low dimensional semantic category based image retrieval.
Introduction
Effective image retrieval hinges on the ability to accurately measure similarity between high-dimensional feature vectors. While linear distance metrics like Mahalanobis distance are computationally efficient, they often struggle to capture the complex, nonlinear semantic relationships inherent in visual data. Traditional "kernelized" nonlinear metrics offer greater expressive power but suffer from poor scalability; their computational cost typically grows linearly with the number of training examples ($O(N)$), making them impractical for large-scale applications.
This research introduces Nonlinear Metric Learning (NML), a method that provides the benefits of kernel-based nonlinearity while maintaining a constant computational complexity that is independent of the training set size.
Methodology: The Kernel Neural Network
The core innovation of NML is an "approximate kernelization" strategy that reinterprets metric learning as a specialized, shallow neural network.
Instead of defining the metric using all training points—a common requirement in kernel methods—the authors learn a fixed set of $d$ "basis" vectors (or "pre-images") in the input space. An input feature vector $x_i$ is compared against these learned basis vectors using a kernel function, such as the shifted $\chi^2$ kernel, which is particularly effective for histogram-like CNN features.
This process effectively projects high-dimensional inputs into a low-dimensional, nonlinear embedding space. The model is trained using Stochastic Gradient Descent (SGD) to minimize a max-margin hinge loss based on pairwise constraints (e.g., identifying similar vs. dissimilar pairs). Because the number of basis vectors $d$ is fixed and small, the complexity remains $O(dD)$, where $D$ is the input dimension, ensuring scalability even with millions of training pairs.
Experimental Results
The NML method was evaluated across seven diverse datasets, including Pascal VOC 2007, Scene-15, and Flickr Materials, using 4096-dimensional features from a pre-trained VGG-16 CNN.
Quantitative Performance
NML consistently outperformed linear metric learning (ML) and established baselines such as Large Margin Nearest Neighbor (LMNN) and Neighborhood Component Analysis (NCA). This superiority is particularly evident at low embedding dimensions (e.g., 16-D or 32-D), where NML captures more semantic information than its linear counterparts.
As shown in the figure above, the NML approach (cyan line) frequently achieves higher precision than even the original 4096-dimensional "No projection" baseline (dashed line), demonstrating that the learned nonlinear embedding can actually improve retrieval quality while significantly reducing data dimensionality.
Efficiency and Robustness
The proposed method is highly efficient, capable of training on 500,000 pairs in approximately one hour on a single CPU core. At test time, it enables real-time retrieval, processing 500 images in roughly 258ms. Furthermore, the model demonstrated robustness to hyperparameter variations, such as the margin and bias, making it a practical choice for varied real-world datasets.
Conclusion
Nonlinear Metric Learning (NML) successfully addresses the scalability bottleneck of traditional kernel methods. By framing the problem as a kernel neural network with a fixed number of basis vectors, it achieves state-of-the-art retrieval performance at low dimensions while remaining computationally efficient. Future work may explore end-to-end integration with deep CNN architectures and the use of data-driven kernels to further enhance embedding quality.
Summary updated