Abstract
We present a Gaussian kernel loss function and training algorithm for convolutional neural networks that can be directly applied to both distance metric learning and image classification problems. Our method treats all training features from a deep neural network as Gaussian kernel centres and computes loss by summing the influence of a feature's nearby centres in the feature embedding space. Our approach is made scalable by treating it as an approximate nearest neighbour search problem. We show how to make end-to-end learning feasible, resulting in a well formed embedding space, in which semantically related instances are likely to be located near one another, regardless of whether or not the network was trained on those classes. Our approach outperforms state-of-the-art deep metric learning approaches on embedding learning challenges, as well as conventional softmax classification on several datasets.
Introduction
In computer vision, image classification and metric learning have traditionally been treated as distinct tasks. Standard classification typically employs a softmax layer, which, while effective, is inherently rigid—requiring a fixed number of classes and enforcing axis-aligned decision boundaries. Conversely, metric learning methods like triplet loss focus on relative similarities but often struggle to match the raw accuracy of top-tier classifiers. Furthermore, triplet loss tends to collapse classes into single clusters, failing to account for intra-class variance (e.g., different perspectives of the same object).
This research bridges the gap by introducing a unified, scalable loss function based on Gaussian kernels. By focusing on local neighborhoods rather than global class averages, the proposed method excels at both classification and similarity measurement.
Methods
The core innovation is the Gaussian kernel loss function, which re-imagines the role of training data in the embedding space.
Instead of learning fixed weights for each class, the model treats the feature embeddings of the entire training set as Gaussian kernel centers. When an image is processed, the network calculates its distance to these centers. A Gaussian kernel assigns high influence to nearby centers and negligible influence to distant ones. Classification is achieved by summing the influence of nearby centers belonging to a specific class and normalizing by the total local influence.
To ensure scalability, the authors utilize Fast Approximate Nearest Neighbour Graphs (FANNG), restricting calculations to a small neighborhood (e.g., top 100 neighbors). To maintain efficiency during training, a "bank" of training embeddings is maintained and updated periodically, rather than recomputing all centers at every iteration.
Results and Discussion
The method was evaluated on standard benchmarks including CUB Birds200-2011, Stanford Cars196, Oxford 102 Flowers, and Leafsnap.
Key Findings
- Superior Metric Learning: On the Cars196 dataset, the method achieved a Recall@1 of 71.05% at 64 dimensions, significantly outperforming previous state-of-the-art metric learning methods. Performance continued to scale with dimensionality, reaching 79.65% at 1024 dimensions.
- Enhanced Classification: The Gaussian kernel approach consistently outperformed standard softmax. For instance, using a VGG16 backbone on the Birds200 dataset, it achieved 78.63% accuracy compared to 75.37% for softmax.
- Multi-Cluster Representation: Unlike triplet loss, this approach allows classes to form multiple "islands" in the embedding space, better capturing diverse intra-class appearances.
- Data Efficiency: The method demonstrated significant gains over softmax when training data was scarce, suggesting a superior ability to capture the underlying data distribution from fewer examples.
Conclusion
The proposed Gaussian kernel framework offers a robust, unified approach to classification and metric learning. While it introduces some memory overhead for storing embedding banks and requires hyperparameter tuning for kernel width, its performance gains and flexibility make it a compelling alternative to traditional softmax and triplet-based methods. Future work may explore more frequent asynchronous updates to further optimize the training process.
Summary updated