Abstract
Loss functions play a crucial role in deep metric learning thus a variety of them have been proposed. Some supervise the learning process by pairwise or tripletwise similarity constraints while others take advantage of structured similarity information among multiple data points. In this work, we approach deep metric learning from a novel perspective. We propose instance cross entropy (ICE) which measures the difference between an estimated instance-level matching distribution and its ground-truth one. ICE has three main appealing properties. Firstly, similar to categorical cross entropy (CCE), ICE has clear probabilistic interpretation and exploits structured semantic similarity information for learning supervision. Secondly, ICE is scalable to infinite training data as it learns on mini-batches iteratively and is independent of the training set size. Thirdly, motivated by our relative weight analysis, seamless sample reweighting is incorporated. It rescales samples' gradients to control the differentiation degree over training examples instead of truncating them by sample mining. In addition to its simplicity and intuitiveness, extensive experiments on three real-world benchmarks demonstrate the superiority of ICE.
Introduction
Deep Metric Learning (DML) aims to learn a mapping from images to a feature space where semantically similar items are clustered together and dissimilar ones are separated. This is fundamental for tasks like image retrieval and face verification. Traditional DML approaches often rely on pairwise or triplet losses. However, these methods face a combinatorial explosion of possible tuples as dataset sizes increase. Most of these tuples are "easy" and contribute little to the learning signal, necessitating complex and often unstable "hard mining" strategies.
While Categorical Cross Entropy (CCE) is highly effective for classification, its application to DML is limited by the requirement for fixed class centers (proxies). This is problematic for "open-set" scenarios where testing classes are unseen during training.
Methodology: Instance Cross Entropy (ICE)
The proposed Instance Cross Entropy (ICE) loss bridges the gap between instance-level matching and the probabilistic framework of cross-entropy. Unlike methods that match queries to fixed class centers, ICE computes the probability of a query matching other specific instances of the same class within a mini-batch.
Core Components
- Instance-Level Matching: ICE treats every similar image in a mini-batch as an individual target. It aims to maximize the matching probability for every positive pair simultaneously.
- Probabilistic Supervision: By adopting the cross-entropy formulation, ICE leverages structured semantic similarity information within the batch, providing a more informative signal than simple binary constraints.
- Seamless Sample Reweighting: ICE incorporates a scaling parameter ($s$) that automatically rescales gradients. This mechanism acts as a "soft mining" tool, where harder examples (those with lower matching probabilities) naturally receive larger gradients, focusing the optimization on difficult cases without explicit sample truncation.
- Hypersphere Embedding: Embeddings are $L_2$ normalized, ensuring that the dot product used in the loss function corresponds to cosine similarity. This focuses learning on the angular relationship between features.
Experimental Evaluation
The effectiveness of ICE was validated on three standard benchmarks for fine-grained image retrieval: CARS196, CUB-200-2011, and Stanford Online Products (SOP). In these tests, training and evaluation classes are disjoint to assess generalization to new categories.
Results
Using a GoogLeNet V2 backbone, ICE achieved state-of-the-art results:
- CARS196: 77.0% Recall@1 (surpassing the previous best of 74.0%).
- CUB-200-2011: 58.3% Recall@1.
- Stanford Online Products: 77.3% Recall@1, significantly outperforming Proxy NCA (73.7%) and N-pair-mc (66.4%).
Ablation studies highlighted the importance of the scaling parameter $s$. Without proper scaling ($s=1$), convergence is poor, whereas optimal scaling (e.g., $s=64$) leads to substantial performance gains.
Discussion
ICE's optimization objective is inherently more challenging than predecessors like S-NCA. While S-NCA considers the aggregate similarity of all positive instances, ICE requires the model to correctly identify each similar sample individually. This more rigorous task encourages the learning of more robust and discriminative feature representations. Furthermore, because ICE operates solely on mini-batches without global class proxies, it scales seamlessly to datasets with an arbitrary number of classes.
Conclusion and Future Work
Instance Cross Entropy offers a simple yet powerful alternative to traditional DML losses. It combines the probabilistic benefits of cross-entropy with instance-level matching and built-in sample reweighting. While highly effective, performance can be sensitive to the scaling parameter $s$, particularly on smaller datasets where over-tuning may lead to overfitting or over-emphasis on outliers. Future research could explore adaptive scaling mechanisms or extending ICE to continuous label spaces.
Summary updated