Source-linked AI summary
Deep Metric Learning with Angular Loss
Jian Wang, Feng Zhou, Shilei Wen, Xiao Liu, Yuanqing Lin
TL;DR
Image search needs metrics that capture semantic similarity, yet existing pairwise distance objectives struggle with feature variation and high-order triplet structure. The paper proposes angular loss, which constrains the negative-point angle in triplets and adds scale-invariant, third-order geometric information. Experiments on three public datasets verify better convergence and superiority over existing methods.
Problem
Existing contrastive and triplet objectives rely on pairwise distance or relative similarity, limiting robustness to feature variance and omitting third-order triplet structure.
Method
Angular loss constrains the angle at the negative point of a triplet and can augment conventional distance-based metric-learning frameworks.
Results
The angular loss consistently achieves better results than previous methods on three benchmark datasets, with superiority verified across retrieval and clustering evaluations.
Takeaways & Limitations
Scale-invariant angular constraints add third-order geometric information and make the objective more robust to feature-map variation.
Takeaways & Limitations
The method is derived from triplet loss, and extending its third-order relation to four or more samples remains future work.
Abstract
from arXiv · showhide
The modern image search system requires semantic understanding of image, and a key yet under-addressed problem is to learn a good metric for measuring the similarity between images. While deep metric learning has yielded impressive performance gains by extracting high level abstractions from image data, a proper objective loss function becomes the central issue to boost the performance. In this paper, we propose a novel angular loss, which takes angle relationship into account, for learning better similarity metric. Whereas previous metric learning methods focus on optimizing the similarity (contrastive loss) or relative similarity (triplet loss) of image pairs, our proposed method aims at constraining the angle at the negative point of triplet triangles. Several favorable properties are observed when compared with conventional methods. First, scale invariance is introduced, improving the robustness of objective against feature variance. Second, a third-order geometric constraint is inherently imposed, capturing additional local structure of triplet triangles than contrastive loss or triplet loss. Third, better convergence has been demonstrated by experiments on three publicly available datasets.
1. Introduction
Deep metric learning seeks image similarities that preserve semantic distance structure, but distance-based objectives struggle with unbalanced feature variation and high-order relationships. The proposed angular loss addresses these issues by constraining a scale-invariant angle within triplets.
- Metric learning aims to learn image similarities that preserve desired distance structure, supporting image search when categories are numerous or unknown.
- Unbalanced intra-class variation makes conventional triplet loss difficult to optimize, as illustrated by differing feature distributions in the Stanford car dataset.
- Deep metric learning commonly minimizes contrastive or triplet loss, but direct distance optimization is difficult and often requires practical training techniques.
- Distance-based objectives use only second-order information, and stochastic optimization can therefore converge sub-optimally in high-order solution space.
- Angular loss encodes third-order triplet relations by constraining the angle at the negative point, while gaining scale invariance and robustness to local feature-map variation.
2. Related work
Prior metric-learning work centers on contrastive and triplet embeddings, alongside sampling, auxiliary supervision, and distribution-based approaches. These methods address pairwise similarity learning and training difficulty through different objectives and data-selection strategies.
- Metric learning has longstanding roots in learning Mahalanobis distances and connects to dimensionality reduction and clustering in discriminative settings.
- Siamese networks learn contrastive embeddings by minimizing distances for positive pairs and penalizing small distances for negative pairs.
- Contrastive embedding has been applied to signature verification and later gained attention for face verification.
- Triplet embedding avoids requiring precise pairwise similarities by comparing positive and negative pair distances within three-sample configurations.
- Hard-sample mining improves training efficiency by focusing on difficult examples, including semihard negatives selected within minibatches.
- Other approaches combine embedding and classification losses or model class distributions, while NCA is limited in minibatch training because it requires the entire training set each iteration.
3. Proposed method
The method replaces or augments distance-based triplet learning with an angular constraint on the negative point, using a reconstructed triangle for stability and batch-level optimization for richer comparisons.
- Motivation: The conventional triplet objective separates an anchor-positive pair from a negative by a distance margin, but stochastic optimization suffers from sampling, variable intra-class distances, and poor convergence.The method review identifies the distance-margin formulation and its optimization difficulties as the motivation for angular loss.
- Angular constraint: The angular loss constrains the angle at the negative point, encoding third-order relations among all three triplet samples.Unlike pairwise distance objectives, the angular constraint uses the triplet's triangle geometry.
- Advantages: The angular constraint is scale-invariant, incorporates all three triangle edges, and gives the margin α a concrete geometric interpretation.These properties address feature rescaling, limited pairwise information, and the difficulty of selecting a meaningful global distance margin.
- Stable reconstruction: Directly minimizing the negative-point angle can be unstable when the anchor angle exceeds 90°, potentially pulling the negative toward the anchor.The paper fixes this case by reconstructing the triplet triangle around the local distribution defined by the anchor and positive.
- Optimization: The reconstructed angular gradient pushes the negative away from the local cluster center while pulling the anchor and positive together, using all three points simultaneously.This contrasts with the original triplet gradients, which depend on two points at a time.
- Batch optimization: For mini-batches, the method uses N-pair sampling to compare each anchor-positive pair with multiple negatives and replaces the multi-negative hinge with a smooth log-sum-exp upper bound.The angular loss can also be combined with N-pair loss; experiments fix the trade-off weight at λ = 2.
4. Experiments
Experiments evaluate angular-loss variants against established metric-learning baselines on three datasets using unseen-class retrieval and clustering protocols. The proposed methods consistently outperform prior methods, with NL&AL achieving the best results across reported metrics.
- Datasets and protocol: Experiments use CUB-200-2011, Stanford Car, and Online Products, splitting each dataset into disjoint training and testing classes.Testing measures generalization to unseen classes.
- Compared methods: The comparison includes Triplet-I, Triplet-II, Lifted Structure, N-pair Loss, Angular Loss, and N-pair & Angular Loss.Triplet-II and the angular-loss variants use N-pair sampling for comparability.
- Datasets and protocol: Retrieval is evaluated with Recall@R, while clustering uses k-means and reports F1 and NMI.Recall@R measures whether the R nearest neighbors include a same-class example.
- Results: Angular Loss consistently achieves better results than previous methods across all three benchmark datasets, while NL&AL performs best across all reported metrics.The result holds while AL uses the same sampling strategies as Triplet-II and N-pair Loss.
- Results: NL&AL retrieves four correct same-class images among the top five for a FIAT 500 query, whereas N-pair fails to identify them.The example illustrates improved retrieval when intra-class variance is large.
- Parameter study: NL&AL performs best with α = 45° on Stanford Car and α = 36° on Online Products, remaining consistently effective for 36°≤α≤55°.Without N-pair integration, AL performs comparably with NL and can perform better at a suitable α.
5. Conclusion
The paper proposes angular loss as an angle-based alternative to distance objectives, introducing scale-invariant and third-order constraints. It reports superiority on benchmark datasets while identifying extensions beyond triplets and combinations with practical training methods as future work.
- Angular loss constrains the angle of a triplet triangle rather than relying solely on pair-wise distance.
- Angle is rotation- and scale-invariant, making the objective more robust to large variation in feature maps.
- The angle encodes the geometry of three points simultaneously and supplies additional constraints for separating dissimilar points.
- The method can be integrated into frameworks such as N-pair loss and outperforms existing state-of-the-art methods on several benchmark datasets.
- Future work includes extending the triplet-based formulation to four or more samples and combining it with hard negative mining or clustering-like frameworks.