LoOp: Looking for Optimal Hard Negative Embeddings for Deep Metric Learning

Bhavya Vasudeva, Puneesh Deora, Saumik Bhattacharya, Umapada Pal, Sukalpa ChandaICCV 2021

Abstract

Deep metric learning has been effectively used to learn distance metrics for different visual tasks like image retrieval, clustering, etc. In order to aid the training process, existing methods either use a hard mining strategy to extract the most informative samples or seek to generate hard synthetics using an additional network. Such approaches face different challenges and can lead to biased embeddings in the former case, and (i) harder optimization (ii) slower training speed (iii) higher model complexity in the latter case. In order to overcome these challenges, we propose a novel approach that looks for optimal hard negatives (LoOp) in the embedding space, taking full advantage of each tuple by calculating the minimum distance between a pair of positives and a pair of negatives. Unlike mining-based methods, our approach considers the entire space between pairs of embeddings to calculate the optimal hard negatives. Extensive experiments combining our approach and representative metric learning losses reveal a significant boost in performance on three benchmark datasets.

Introduction

Deep Metric Learning (DML) aims to map data into an embedding space where similar items are clustered and dissimilar items are separated. A critical component of successful DML is the handling of hard negatives—dissimilar samples that are positioned closely in the embedding space. Traditional approaches typically rely on hard negative mining (limited by batch size) or hard negative generation (computationally expensive GAN-based methods).

LoOp (Looking for Optimal) introduces a geometric alternative that finds the "hardest" possible negative examples by calculating the minimum distance between geometric curves connecting pairs of samples. By treating the space between samples as a continuous manifold rather than discrete points, LoOp provides the benefits of synthetic negatives without the overhead of generative models.

Methodology: Geometric Hard Negatives

In DML, embeddings are typically $l_2$-normalized, residing on the surface of a high-dimensional hypersphere. LoOp leverages this geometry by considering pairs of points. For two samples of Class A ($x_1, x_2$) and two of Class B ($y_1, y_2$), LoOp analyzes the geodesic arcs connecting them. The core assumption is that any point on the arc between two samples of the same class is likely to represent that class.

Geometric concept of LoOp on a hypersphere, showing the search for optimal points $p_1$ and $p_2$ on class-specific arcs.

The "Optimal Hard Negative" is defined as the pair of points ($p_1$ on the Class A arc and $p_2$ on the Class B arc) that minimize the distance between the two classes. To solve this efficiently during training, the authors utilize Gram-Schmidt orthogonalization and Rodriguez's rotation theorem to define the arcs, then apply Karush-Kuhn-Tucker (KKT) conditions to find the exact points of minimum distance.

The nine possible geometric cases for finding optimal points $p_1$ and $p_2$ based on arc boundaries and interior solutions.

This approach allows the model to learn from the entire region a class might occupy, rather than just the specific samples present in a batch. Because it relies on closed-form geometric solutions, it adds negligible overhead to training time compared to generative approaches.

Experimental Results

The authors evaluated LoOp on three standard benchmarks: CUB-200-2011, Cars196, and Stanford Online Products (SOP), using a zero-shot protocol. LoOp consistently outperformed both standard baselines and state-of-the-art generative methods:

  • Cars196: Using Triplet Loss, LoOp improved Recall@1 from 45.1% to 61.7%, surpassing complex generative methods like DAML (60.6%) and HDML (61.0%).
  • Stanford Online Products: LoOp achieved a Recall@1 of 69.6% with Triplet Loss, a substantial increase from the 53.9% baseline.
  • Versatility: The method showed consistent improvements across various loss functions, including Triplet, HPHN, Lifted Structure (LS), and Multi-Similarity (MS) loss.

Conclusion

LoOp demonstrates that pure mathematics and optimization theory can effectively replace complex generative models for creating hard negatives in DML. While the method relies on a "spherical-homoscedastic" assumption regarding class distributions, its empirical success across diverse datasets suggests it is a robust and efficient "plug-and-play" enhancement for modern metric learning pipelines.

Summary updated

BibTeX
@inproceedings{vasudeva2021loop,
  author = {Bhavya Vasudeva and Puneesh Deora and Saumik Bhattacharya and Umapada Pal and Sukalpa Chanda},
  title = {{LoOp: Looking for Optimal Hard Negative Embeddings for Deep Metric Learning}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2021},
  url = {https://openreview.net/forum?id=4LEIunnLuG},
}
Figure