Source-linked AI summary

A Metric Learning Reality Check

Kevin Musgrave, Serge Belongie, Ser-Nam Lim

arXiv:2003.08505v3cs.CV

TL;DR

Reported accuracy gains in metric learning have lacked consistently controlled comparisons. This paper audits experimental flaws and reevaluates loss functions using cross-validated hyperparameter tuning, finding only marginal improvements over classic methods and sometimes equivalent performance.

  • Problem

    Metric learning papers lack consistently controlled comparisons needed to attribute reported accuracy gains to algorithms rather than other experimental parameters.

    Source: §2.1 · p. 5
  • Method

    The authors audit experimental flaws and compare loss functions using a revised evaluation protocol with class-disjoint cross-validation for hyperparameter tuning.

    Source: §1.7 · p. 5, §3.3 · p. 10
  • Results

    State-of-the-art loss functions perform marginally better than, and sometimes on par with, classic methods when the identified evaluation flaws are corrected.

    Source: §5 · p. 14
  • Takeaways & Limitations

    The findings cast doubt on theoretical explanations premised on the claimed performance gains in metric learning.

    Source: §4.2 · p. 14

    The study leaves unresolved why different losses perform similarly and how optimal hyperparameters relate to dataset/architecture combinations.

    Source: §5 · p. 14

Abstract

from arXiv · show

Deep metric learning papers from the past four years have consistently claimed great advances in accuracy, often more than doubling the performance of decade-old methods. In this paper, we take a closer look at the field to see if this is actually true. We find flaws in the experimental methodology of numerous metric learning papers, and show that the actual improvements over time have been marginal at best.

1 Metric Learning Overview

Metric learning builds embedding spaces for similarity-based tasks using embedding or classification losses, complemented by mining and advanced training methods. This paper proposes a training and evaluation protocol addressing methodological flaws and reports that most methods perform similarly when hyperparameters are properly tuned through cross-validation.

1.1 Why metric learning is important

  • Metric learning brings similar samples together and separates dissimilar ones, supporting retrieval and open-set recognition while accommodating relational supervision and self-supervised learning.Open-set recognition handles disjoint training/test classes through nearest-neighbor voting or distance thresholds, including face verification and person re-identification [20]. Pair/triplet supervision [64] and additional relational signals support embedding losses without explicit labels; self-supervised pseudo-labels [18] [6] favor them because their meaning does not persist across iterations.Source: §1.1 · pp. 1–2

1.2 Embedding losses

  • Contrastive loss enforces absolute pair-distance thresholds, whereas triplet margin loss enforces relative distances, allowing variation in interclass dissimilarities.Fixed contrastive thresholds ignore similarity variation; subsequent losses introduce angular margins, learnable thresholds, signal-to-noise comparisons, and softmax or LogSumExp aggregation. N-Pairs uses softmax; multi similarity, tuplet margin, and circle weight pairs; FastAP instead approximates batch average precision using soft histograms.Source: §1.2 · pp. 2–3

1.3 Classification losses

  • Classification losses transform embeddings into class logits through a weight matrix, with variants modifying normalization, distances, angular margins, or the number of representatives per class.Normalized softmax [72] uses L2-normalized weight columns, ProxyNCA substitutes Euclidean distances for cosine similarities, and SoftTriple uses multiple columns per class. SphereFace, CosFace, and ArcFace introduce multiplicative-angular, additive-cosine, and additive-angular margins, respectively, yet metric-learning experiments consistently omitted these non-face-specific losses.Source: §1.3 · p. 3

1.4 Pair and triplet mining

  • Mining selects informative pairs or triplets before batch construction or within batches, avoiding exhaustive combinations that consume memory and overrepresent easy examples.Selecting only the hardest examples [20] can produce noisy gradients and poor local optima; semihard mining selects negatives farther than positives, but progress declines as these negatives disappear. Distance-weighted sampling mixes negative difficulties, cascaded models reserve difficult pairs for complex models, and Wang et al. select pairs relative to the hardest opposite-type example.Source: §1.4 · pp. 3–4

1.5 Advanced training methods

  • Advanced training methods extend loss design and mining with generators, hierarchical margins, attention ensembles, disentanglement, and separately trained embedding-space partitions.Generators model class centers and variance, create hard negatives, or adapt negative difficulty to model strength. HTL estimates per-class margins from a hierarchical class tree; ABE learns different attention masks; MIC separates class-specific from shared properties; DCES trains separate embedding layers for partitions.Source: §1.5 · p. 4

1.6 Related work

  • Cross-validation and Bayesian optimization substantially reduce performance differences between loss functions, distinguishing this paper’s methodology from earlier comparison studies.Fehervari et al. [13] mainly examined methods from 2017 or earlier; neither that study nor concurrent Roth et al. addressed training with test-set feedback. Roth et al. tuned hyperparameters using a small grid around originally published values.Source: §1.6 · pp. 4–5

1.7 Contributions of this paper

  • Most methods perform similarly when hyperparameters are properly tuned through cross-validation, motivating a protocol that addresses unfair comparisons, weak accuracy metrics, and test-set feedback.The findings raise questions about hyperparameter–dataset relationships and whether particular dataset/architecture combinations inherently limit open-set accuracy.Source: §1.7 · p. 5

2 Flaws in the existing literature

Metric learning comparisons are weakened by inconsistent experimental settings, test-set-driven model selection, and accuracy metrics that obscure differences in embedding quality. Unreported implementation choices and missing confidence intervals further complicate claims of improvement.

2.1 Unfair comparisons

  • Changing network architectures and embedding dimensions confounds attribution of reported accuracy gains to new metric learning algorithms.A 2017 paper compared ResNet50 against GoogleNet-based methods, so much of its gain likely reflected architecture choice. Increasing embedding dimensionality also improves accuracy, making controlled comparisons essential.Source: §2.1 · pp. 5–6
  • Optimizer and learning-rate inconsistencies obstruct fair comparisons, while missing confidence intervals leave low-single-digit accuracy improvements difficult to assess.Optimizer effects on test accuracy are unclear: Adam and RMSprop converge faster, whereas SGD may generalize better. Averaging multiple runs and reporting confidence intervals would make small improvements more meaningful.Source: §2.1 · p. 6
  • A 2-point CUB200 performance boost was attributed to freezing BatchNorm in a 2019 paper’s code, but omitted from the paper.Some implementations also use more sophisticated cropping than reported, varying crop location, size, and aspect ratio to increase training-data variability and combat overfitting.Source: §2.1 · p. 6

2.2 Weakness of commonly used accuracy metrics

  • Nearly 100% Recall@1 and roughly equal NMI and F1 scores fail to distinguish toy embedding spaces with different class separation.NMI and F1 additionally depend on clustering algorithm choice and initialization; typical k-means evaluation produces uninformative scores in these examples. The authors seek a more nuanced metric operating directly on embeddings.Source: Figure 1 · p. 7, §2.2 · p. 7
  • NMI tends to score datasets with many classes highly regardless of true accuracy; Adjusted Mutual Information corrects this bias but still requires clustering.Source: §2.2 · p. 7

2.3 Training with test set feedback

  • Test-set feedback guides model selection and hyperparameter tuning without a validation set, causing test-set overfitting and calling reported progress into question.Most papers train on the first 50% of classes and report the best periodically checked accuracy on the remaining classes. Reporting results after predetermined training lengths still leaves test-based hyperparameter tuning and unclear iteration selection.Source: §2.3 · pp. 7–8

3 Proposed evaluation method

The proposed evaluation method addresses earlier methodological flaws through standardized experiments, informative retrieval metrics, and class-disjoint cross-validation. Repeated training runs and confidence intervals reduce sensitivity to random seeds.

3.1 Fair comparisons and reproducibility

  • 128-dimensional embeddings come from an ImageNet pretrained BN-Inception network, with BatchNorm parameters frozen to reduce overfitting.All batches contain 32 images. Embedding losses sample eight classes with four images each, whereas classification losses sample 32 classes with one image each.Source: §3.1 · p. 8
  • 1e-6 is the RMSprop network learning rate; learning rates for loss-specific learnable weights are tuned.Training resizes images to a 256-pixel shorter side, randomly crops sizes 40–256 with aspect ratios 3/4–4/3, resizes to 227x227, and flips horizontally with 50% probability. Evaluation resizes to 256 and center-crops to 227; embeddings are L2-normalized before computing the loss.Source: §3.1 · p. 8

3.2 Informative accuracy metrics

  • MAP@R accounts for retrieval ranking by computing mean average precision over R neighbors, where R counts references sharing the query’s class.R-precision instead measures the fraction of those R neighbors belonging to the query’s class, without accounting for their ranking. Results report both metrics and Precision@1, previously called Recall@1, for comparison with earlier papers.Source: §3.2 · p. 9
  • 0.81 for MAP@R versus 0.73 for Recall@1 in lag-one validation-accuracy autocorrelation indicates less noise, easing checkpoint selection.Table 3 illustrates Recall@1’s limited informativeness: all four hypothetical retrieval results score 100% despite clear differences, assuming R = 10. MAP@R also requires no clustering step and rewards well-clustered embedding spaces.Source: §3.2 · p. 9, Table 3 · p. 9

3.3 Hyperparameter search via cross validation

  • 50 Bayesian optimization iterations use four-fold, class-disjoint cross-validation to select loss-function hyperparameters.The first half of classes forms four deterministic, contiguous partitions; training uses three partitions, validates on the remaining partition, and stops when validation accuracy plateaus. The second half remains the test set, preserving comparability with earlier papers.Source: §3.3 · pp. 9–10
  • 10 training runs with the best hyperparameters provide mean accuracies and confidence intervals to reduce random-seed noise.Hyperparameters maximize average validation accuracy, and each fold’s highest-accuracy checkpoint produces L2-normalized test embeddings. Evaluation either concatenates four 128-dimensional embeddings into a normalized 512-dimensional embedding or averages the four separate 128-dimensional embedding accuracies.Source: §3.3 · p. 10

4 Experiments

With good baseline implementations and matched evaluation, metric learning methods introduced from 2006 to 2019 performed similarly rather than showing dramatic progress. Papers’ overstated improvements relied on weak contrastive and triplet baselines.

4.1 Losses and datasets

  • 13 losses and one loss-plus-miner combination were evaluated using common settings on CUB200, Cars196, and Stanford Online Products.Results report mean accuracy across 10 runs and applicable 95% confidence intervals, alongside pretrained embeddings reduced by PCA to 512 or 128 dimensions. Increasing CUB200 batch size from 32 to 256 changed little except significantly improving FastAP to match other methods.Source: §4.1 · p. 10
  • The comparison included CosFace and ArcFace face-verification losses, shared versus per-class learned Margin β, and NT-Xent, also called N-Pairs or InfoNCE.Only the CosFace and ArcFace loss functions were used, without face datasets or face-trained models.Source: Table 7 · p. 12

4.2 Papers versus reality

  • N/2 pairs and N/3 triplets per batch in the lifted structure implementation used little available information, while its triplet margin was 1 rather than approximately 0.1.N denotes batch size; approximately 0.1 tended to be optimal. Most subsequent papers reused the low baseline numbers rather than implementing more reasonable baselines themselves.Source: §4.2 · p. 12
  • Under matched evaluation, Precision@1 followed a nearly flat trend across methods introduced from 2006 to 2019, indicating similar performance rather than spectacular progress.The authors also question results of unevaluated cutting-edge papers and theoretical explanations premised on performance gains that disappear under proper evaluation.Source: §4.2 · pp. 12, 14, Figure 2 · p. 13
  • Over 100% relative improvements over contrastive loss and nearly 50% over triplet loss were claimed in many papers because their reported baseline accuracies were extremely low.Figure 3 compares published relative improvements with those obtained under the authors’ separated 128-dimensional and concatenated 512-dimensional settings, excluding FastAP and the other baseline loss.Source: §4.2 · p. 12, Figure 3 · p. 13

5 Conclusion

After correcting unfair comparisons, misleading or incomplete metrics, and test-set feedback, state-of-the-art metric learning losses performed only marginally better than, and sometimes on par with, classic methods.

5 Conclusion

  • The paper identifies unfair comparisons caused by changes in network architecture, embedding size, image augmentation, and optimizers.Source: §5 · p. 14
  • Accuracy metrics used in the literature can be misleading or fail to provide a complete picture of the embedding space.Source: §5 · p. 14
  • Training without a validation set introduces test-set feedback, another methodological flaw identified in the literature.Source: §5 · p. 14
  • State-of-the-art loss functions performed marginally better than, and sometimes on par with, classic methods after experimental flaws were corrected.This contrasts with published claims of dramatic accuracy improvements over time.Source: §5 · p. 14
  • Future work could investigate optimal hyperparameters across dataset–architecture combinations, explain similar performance across losses, and pursue accuracy improvements.Proper machine learning practices and fair comparisons should make results more realistic and more likely to generalize to areas such as self-supervised learning.Source: §5 · p. 14
Loading 2003.08505v3…