Deep Metric Learning with Self-Supervised Ranking

Zheren Fu, Yan Li, Zhendong Mao, Quan Wang, Yongdong Zhang

Abstract

Deep Metric Learning (DML) typically focuses on maximizing inter-class variance to separate different categories in an embedding space. However, standard approaches often overlook intra-class variance, treating all positive samples as equidistant from an anchor. This paper introduces a Self-Supervised Ranking (SSR) framework that addresses this limitation by teaching models to respect the local manifold structure of classes. By utilizing synthetic transformations of varying intensities, the proposed method establishes a ground-truth ranking that guides the model to learn relative relationships between similar objects. Experimental results demonstrate a 2-4% boost in retrieval performance on standard benchmarks like CUB-200-2011 and Cars-196.

Introduction: The Challenge of Intra-Class Variance

The primary goal of DML is to learn an embedding space where similar objects are clustered together and dissimilar ones are pushed apart. While effective at separating "cats" from "dogs," traditional DML losses (like Triplet or Contrastive loss) often ignore the nuances within a single class. For instance, an image of a bird from a side view should ideally be closer to a frontal-view anchor than a heavily cropped or color-distorted version of the same bird.

Figure 1: (a) Examples of intra-class variance. (b) Previous methods treat all positive samples as equally distant from the anchor. (c) The proposed method preserves the ranking of positive samples based on their similarity to the anchor.

As shown in Figure 1, standard methods create a "flat" embedding space where the internal ranking of positive samples is arbitrary. This lack of structure can lead to disorganized retrieval results in real-world applications where the relative order of similarity is crucial.

Proposed Method: Self-Supervised Ranking (SSR)

The authors propose a "plug-and-play" SSR module that can be integrated into existing DML frameworks. The core idea is to use self-supervision to generate a ranking signal without requiring additional manual labels.

Dual-Head Architecture

The framework employs a shared backbone network (e.g., ResNet50) followed by two specialized heads:

  1. Metric Head ($q_\theta$): Optimizes standard DML objectives (e.g., Multi-Similarity or Margin loss) to ensure inter-class separation.
  2. Ranking Head ($g_\theta$): Learns to preserve the order of synthetic transformations applied to an image.
Figure 2: The SSR framework architecture. It consists of a shared backbone $f_\theta$ and two heads for metric learning and self-supervised ranking. Synthetic transformations $T_n$ with varying strengths $n$ are used to create the ranking task.

Synthetic Transformations and Ranking Loss

To create the ranking task, the model applies transformations such as random cropping, perspective shifts, and color jittering at varying intensity levels ($n$). A higher $n$ corresponds to a more severe distortion, which should logically be placed further from the original anchor in the embedding space.

The total loss is a multi-task objective: $$\mathcal{L}_{multi-task} = \mathcal{L}_{metric} + \lambda \mathcal{L}_{ranking}$$

The ranking loss $\mathcal{L}_{ranking}$ is further divided into:

  • Listwise Ranking Loss ($\mathcal{L}_{sort}$): Ensures that the distances in the embedding space follow the order of transformation intensity: $dist(z_0, z_1') < dist(z_0, z_2') < \dots < dist(z_0, z_N')$.
  • Pointwise Loss ($\mathcal{L}_{pos}$): Acts as a constraint to ensure that even highly transformed samples remain within a "positive boundary" ($\beta$), preventing them from drifting into the territory of other classes.

Experimental Results

The SSR framework was evaluated on three major DML benchmarks: CUB-200-2011, Cars-196, and Stanford Online Products (SOP).

  • Performance Gains: The method consistently improved baselines. For example, on Cars-196, adding SSR to a Margin loss baseline increased Recall@1 from 79.6% to 84.5%. On CUB-200-2011, it improved from 63.6% to 66.5%.
  • Ranking Quality: Beyond simple retrieval accuracy, the model showed significant improvements in Mean Average Precision (MAP) and R-Precision, indicating that the retrieved results are better ordered.
  • Universality: SSR proved to be loss-agnostic, providing benefits when paired with various base losses like Triplet, Margin, or Multi-Similarity loss.

Conclusion

By explicitly modeling intra-class variance through self-supervised ranking, this work provides a more nuanced approach to Deep Metric Learning. The SSR framework successfully regularizes the embedding space, leading to more robust feature representations and better-ordered retrieval results. While the gains are most pronounced in datasets with high intra-class variance (like fine-grained bird or car species), the method's "plug-and-play" nature makes it a valuable addition to the DML toolkit.

Summary updated

BibTeX
@inproceedings{fu2021deep,
  author = {Zheren Fu and Yan Li and Zhendong Mao and Quan Wang and Yongdong Zhang},
  title = {{Deep Metric Learning with Self-Supervised Ranking}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i2.16226},
}
Figure