Learning Similarity Attention

Meng Zheng, Srikrishna Karanam, Terrence Chen, Richard J. Radke, Ziyan Wu

Abstract

Deep metric learning is a cornerstone of modern computer vision, yet its decision-making process remains largely opaque. This paper presents a gradient-based approach to generate "Similarity Attention" maps, providing visual explanations for image similarity decisions. By incorporating these maps into a "Similarity Mining" training strategy, the authors demonstrate that interpretability can directly drive performance improvements. The resulting models show enhanced robustness and state-of-the-art results across image retrieval, person re-identification, and one-shot segmentation tasks.

Introduction

Deep metric learning (DML) aims to map images into a high-dimensional space where semantic similarity corresponds to Euclidean distance. While DML powers critical applications like face recognition and product search, these models are often treated as "black boxes." Unlike image classification, which benefits from tools like Grad-CAM to highlight discriminative regions, DML has lacked a generic equivalent for explaining pairwise or triplet-based relationships.

Without understanding why two images are considered similar, it is difficult to debug models or ensure they aren't relying on spurious correlations (e.g., background features). Furthermore, models often over-fit to the most salient features, ignoring subtle but important details.

Proposed Methodology: Similarity Attention and Mining

The authors propose a dual-component framework to address both interpretability and feature robustness.

1. Similarity Attention Generation

Unlike previous interpretability methods that require auxiliary classification layers, Similarity Attention operates directly on the feature vectors used for distance metrics. The process involves:

  • Weight Calculation: A weight vector ($w$) is derived from the absolute differences between feature dimensions of two images. This vector highlights dimensions that contribute most to similarity or dissimilarity.
  • Gradient-Based Mapping: By computing the gradient of the similarity score with respect to the convolutional feature maps, the model generates a spatial heatmap. This heatmap identifies the specific pixels that influenced the similarity decision.

2. Similarity Mining

The framework leverages these attention maps during training through a process called Similarity Mining. Once the most salient features are identified via attention, the model applies a "soft mask" to these regions. This forces the network to discover additional, less obvious discriminative features to satisfy the metric learning objective. This iterative process leads to a more comprehensive and robust feature representation.

The proposed framework architecture, illustrating the generation of similarity attention maps and the subsequent similarity mining process using soft masking.

Applications and Generalization

The utility of Similarity Attention extends beyond simple explanation. The generated maps are precise enough to serve as cues for downstream tasks without additional training.

Overview of Similarity Attention applications, including retrieval, recognition, and weakly supervised one-shot detection and segmentation.
  • Cross-Domain Generalization: Models trained on specific categories (e.g., birds) can produce meaningful attention maps for entirely different domains (e.g., cars), indicating the learning of a general concept of visual similarity.
  • One-Shot Segmentation: The attention maps can be used for one-shot semantic segmentation, where the model identifies an object in a target image based on a single support example.

Experimental Results

The framework was evaluated on several benchmark datasets, including CUB200, Cars196, and CUHK03-NP.

  • Metric Learning Performance: On the CUB200 dataset, the Similarity Attention and Mining (SAM) approach improved the baseline Triplet network's Recall@1 from 66.4% to 68.3%.
  • State-of-the-Art in Re-ID: The method achieved a Rank-1 accuracy of 74.5% on CUHK03-NP, significantly outperforming specialized architectures like MGN (66.8%) and CASN (71.5%).
  • Zero-Shot Segmentation: In 2-way 1-shot segmentation on PASCAL-$5^i$, the model achieved a mean IOU of 56.9%, surpassing several task-specific supervised methods.

Conclusion

This work demonstrates that interpretability is not just a post-hoc diagnostic tool but a powerful signal for model improvement. By "peeking inside" the similarity network and forcing it to look beyond the obvious, the authors achieve more robust and generalizable DML models. Future research will explore extending this mechanism to set-to-set matching and refining adaptive masking techniques.

Summary updated

BibTeX
@inproceedings{zheng2022learning,
  author = {Meng Zheng and Srikrishna Karanam and Terrence Chen and Richard J. Radke and Ziyan Wu},
  title = {{Learning Similarity Attention}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.24963/ijcai.2022/241},
}
Figure