Abstract
Deep Metric Learning (DML) aims to map images into an embedding space where semantic similarity is preserved. However, evaluating how these models generalize to unseen classes often relies on aggregate metrics like Recall@1, which obscure the underlying structural changes in the embedding space. This paper introduces two novel visualization tools—jointly aligned (yoked) t-SNE plots and same-vs-different similarity scatter plots—to provide a more granular understanding of generalization. The authors find that selective triplet strategies, such as EPSHN, often outperform exhaustive methods by preventing overfitting to training-specific features.
Problem Statement: The Generalization Gap
Deep Metric Learning (DML) trains neural networks to map images into an embedding space where semantically similar items are close together and dissimilar items are far apart. The ultimate test for these models is generalization: the ability to handle entirely new categories of objects unseen during training. While researchers typically track generalization using single-number metrics like Recall@1, these numbers fail to explain why one method outperforms another. There is a lack of tools to visualize how the structure of the embedding space changes when moving from training data to new, unseen test classes.
Proposed Visualization Methods
The authors propose two primary visualization techniques to "peek inside" the DML black box:
- Joint (Yoked) t-SNE: Standard t-SNE visualizes high-dimensional data in 2D, but running it separately on training and test sets makes them impossible to compare due to the algorithm's stochastic nature. The authors use "Dynamic t-SNE" to "yoke" or align different embeddings. This allows them to overlay training (red) and testing (blue) data in the same space to see if new classes are being mapped into the same regions as old ones or forming their own distinct clusters.
- Same vs. Different Similarity Plots: For every point in the dataset, they plot its similarity to its nearest neighbor of the same class versus its similarity to its nearest neighbor of a different class. Points above the $y=x$ diagonal are correctly classified. This reveals whether a model is "overfitting" by creating hyper-tight clusters in training that fall apart during testing.
Experimental Setup
The study evaluates these methods on two standard fine-grained recognition benchmarks:
- CAR (Cars-196): A dataset of 196 car models.
- CUB (CUB-200-2011): A dataset of 200 bird species.
In both cases, models are trained on one set of classes and tested on a completely disjoint set of "new" classes to measure generalization. They compare several triplet selection strategies: Batch All, N-Pairs, Semi-Hard Negative (SHN), and Easy Positive Semi-Hard Negative (EPSHN).
Key Insights: Why "Less is More"
The visualizations reveal several critical insights into how DML models behave:
- The Overfitting Paradox: Surprisingly, methods that consider only a single, carefully selected triplet per example (like EPSHN) yield superior generalization compared to "Batch All" methods that optimize over thousands of possible triplets.
- Training Accuracy is Deceptive: Methods like N-Pairs produce incredibly tight, perfect clusters on training data. However, as seen in the scatter plots, these often fail to generalize because the model learns a representation that is too specific to the training classes.
- GAP vs. FC Layers: Features taken from the Global Average Pooling (GAP) layer generalize significantly better than those from the final Fully Connected (FC) layer. GAP features, which pass through a ReLU activation, preserve the relative similarity of new classes much better than the "noisier" FC features.
- Visualizing the Gap: The "Same vs. Different" plots clearly show a "downward shift" when moving from training to testing. A robust model is one where the test points stay as far above the $y=x$ diagonal as possible.
Quantitative Results
The quantitative results confirm the qualitative findings from the visualizations:
| Dataset | Method | FC (Test) | GAP (Test) |
|---|---|---|---|
| CAR | Batch All | 33.72 | 46.66 |
| CAR | EPSHN | 73.22 | 81.85 |
| CUB | Batch All | 38.86 | 59.70 |
| CUB | EPSHN | 56.23 | 63.51 |
EPSHN consistently outperforms other methods on test data, and using the GAP layer provides a massive boost in performance (often 10-15% absolute improvement) over the FC layer.
Conclusion and Future Work
This paper demonstrates that visualization tools can provide deep insights into the generalization of embedding spaces. While the focus here is on empirical visualization, future work could involve using these tools to design new loss functions that explicitly aim to maintain the "Same vs. Different" spread on validation sets, potentially leading to even more robust embeddings.
Summary updated