Circle Loss: A Unified Perspective of Pair Similarity Optimization

Yifan Sun, Changmao Cheng, Yuhan Zhang, Chi Zhang, Liang Zheng, Zhongdao Wang, Yichen Wei

Abstract

This paper provides a pair similarity optimization viewpoint on deep feature learning, aiming to maximize the within-class similarity $s_p$ and minimize the between-class similarity $s_n$. We find a majority of loss functions, including the triplet loss and the softmax cross-entropy loss, embed $s_n$ and $s_p$ into similarity pairs and seek to reduce $(s_n - s_p)$. Such an optimization manner is inflexible, because the penalty strength on every single similarity score is restricted to be equal. Our intuition is that if a similarity score deviates far from the optimum, it should be emphasized. To this end, we simply re-weight each similarity to highlight the less-optimized similarity scores. It results in a Circle loss, which is named due to its circular decision boundary. The Circle loss has a unified formula for two elemental deep feature learning paradigms, i.e., learning with class-level labels and pair-wise labels. Analytically, we show that the Circle loss offers a more flexible optimization approach towards a more definite convergence target, compared with the loss functions optimizing $(s_n - s_p)$. Experimentally, we demonstrate the superiority of the Circle loss on a variety of deep feature learning tasks. On face recognition, person re-identification, as well as several fine-grained image retrieval datasets, the achieved performance is on par with the state of the art.

Introduction

In deep feature learning, the fundamental objective is to learn a feature space where samples from the same class are close together (high within-class similarity $s_p$) and samples from different classes are far apart (low between-class similarity $s_n$). Traditional loss functions, such as Triplet Loss and variants of Softmax (e.g., ArcFace, AM-Softmax), typically optimize the difference $(s_n - s_p)$ with a fixed margin.

However, this symmetric optimization approach suffers from two primary limitations. First, it lacks flexibility: it applies the same penalty strength to both $s_n$ and $s_p$ regardless of their current values. Second, it leads to ambiguous convergence: a linear decision boundary $(s_p - s_n = m)$ allows for multiple states to satisfy the margin, even if some states (e.g., lower absolute $s_n$) are clearly superior for feature separability.

Methodology: The Circle Loss

To address these issues, we propose Circle Loss, which introduces a dynamic re-weighting mechanism. It provides a unified formula that generalizes both "proxy-based" learning (class-level labels) and "pair-based" learning (pair-wise labels). Instead of a simple difference, Circle Loss optimizes $(\alpha_n s_n - \alpha_p s_p)$, where the weights $\alpha$ are self-paced functions of the similarity scores themselves:

  • $\alpha_p = [1 + m - s_p]_+$
  • $\alpha_n = [s_n + m]_+$

Circular Decision Boundary

By re-weighting the similarities, the decision boundary is transformed from a straight line into a circle. Mathematically, this can be expressed as $(s_n - 0)^2 + (s_p - 1)^2 = 2m^2$. Unlike linear boundaries that are indifferent to the absolute values of $s_n$ and $s_p$, the circular boundary naturally favors a specific convergence point that maximizes the gap between the two, leading to a more definite and optimized feature space.

Comparison of decision boundaries: (a) the linear boundary of traditional losses vs. (b) the circular boundary of Circle Loss.

Dynamic Re-weighting and Gradient Flexibility

The core innovation of Circle Loss is its ability to focus on the "weakest links" during training. If a similarity score deviates significantly from its optimum (0 for $s_n$, 1 for $s_p$), it receives a larger weight and, consequently, a larger gradient. This "self-paced" learning allows the model to prioritize less-optimized samples.

Gradient analysis showing the magnitude of gradients for $s_n$ and $s_p$ across (a) Triplet loss, (b) AMSoftmax loss, and (c) Circle loss.

As shown in the gradient analysis, Circle Loss (c) exhibits a much more flexible gradient distribution compared to Triplet (a) or AMSoftmax (b). This flexibility also provides an automatic attenuation effect; as scores approach their targets, the weights naturally decrease, making the training process more robust to hyper-parameter choices like the scale factor $\gamma$.

Experimental Evaluation

Circle Loss was evaluated across three major domains, demonstrating state-of-the-art or competitive performance:

  • Face Recognition: On the MegaFace (MF1) benchmark, Circle Loss achieved 97.81% Rank-1 accuracy using a ResNet34 backbone, outperforming ArcFace (97.68%). It also showed significant improvements on the IJB-C 1:1 verification task.
  • Person Re-identification: Combined with the MGN architecture, it reached 96.1% Rank-1 accuracy on the Market-1501 dataset.
  • Fine-grained Image Retrieval: Circle Loss set new benchmarks on CUB-200-2011 (66.7% R@1) and Stanford Online Products (78.3% R@1), surpassing complex multi-similarity methods.

Conclusion

Circle Loss offers a unified and flexible framework for pair similarity optimization. By replacing traditional linear boundaries with a circular one and introducing dynamic re-weighting, it achieves a more definite convergence target and superior feature separability. Its robust performance across diverse tasks confirms its effectiveness as a general-purpose loss function for deep feature learning.

Summary updated

BibTeX
@inproceedings{sun2020circle,
  author = {Yifan Sun and Changmao Cheng and Yuhan Zhang and Chi Zhang and Liang Zheng and Zhongdao Wang and Yichen Wei},
  title = {{Circle Loss: A Unified Perspective of Pair Similarity Optimization}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2020},
  url = {https://openreview.net/forum?id=Q3JXwaxK2p},
}
Figure