Visual Explanation for Deep Metric Learning

Sijie Zhu, Taojiannan Yang, Chen Chen

TL;DR

This paper introduces an "activation decomposition" framework that explains why a deep metric learning model thinks two images are similar. By breaking down the final similarity score into spatial components, the authors generate "point-specific" maps that reveal exactly which regions in one image correspond to regions in another, enabling new applications like interactive, part-based image retrieval.

What Problem Does This Paper Address?

Deep Metric Learning (DML) is the engine behind face recognition, image retrieval, and person re-identification. Unlike standard classification, which asks "What is in this image?", DML asks "How similar are these two images?"

While we have tools like Grad-CAM to explain classifiers, explaining DML is trickier. Most existing methods only provide an "overall" heatmap for a single image. They fail to capture the relationship between two images. For example, if a model says two faces are similar, is it because of the eyes, the nose, or the chin? Standard tools can't tell you which part of Image A matched which part of Image B. Furthermore, the common architectural choices in DML—like L2 normalization—actually make standard explanation tools less accurate and more "scattered."

Methods

The authors propose a framework called Activation Decomposition.

  1. The Core Idea: In a typical Siamese network, the similarity score is calculated as the dot product (or cosine similarity) of two embedding vectors. These vectors are usually the result of Global Average Pooling (GAP) over spatial feature maps. The authors mathematically "undo" this pooling, tracing the final score back to the individual pixels in the feature maps.
  2. Point-Specific Maps: This is the "secret sauce." Instead of a single heatmap, they can generate a map for a specific point. You pick a pixel (e.g., a person's shoes) in the query image, and the framework generates a heatmap in the target image showing exactly which regions contributed to the similarity for that specific part.
  3. Handling Complexity: They show how to extend this to complex architectures involving Global Max Pooling (GMP) and ReLU activations by treating these non-linearities as linear masks during the inference phase.
  4. Fixing Grad-CAM: They provide a theoretical proof showing that Grad-CAM’s reliance on gradients from L2-normalized embeddings actually penalizes the most important features, leading to blurry, scattered explanations. Their decomposition method avoids this pitfall.

Datasets

The researchers validated their approach across several diverse tasks:

  • CUB-200-2011: A dataset of bird species used for weakly supervised localization and human preference studies.
  • CVUSA: A cross-view dataset (street-view vs. aerial) used for geo-localization.
  • Market-1501: A standard benchmark for person re-identification.
  • CASIA-WebFace & FIW: Datasets for face recognition and kinship verification.

Key Insights and Ideas

  • Similarity is a Two-Way Street: An explanation for DML shouldn't just highlight "important" regions; it should highlight "corresponding" regions. The point-to-point activation intensity is a much more granular way to understand model behavior.
  • The "Norm" Problem: The paper reveals that L2 normalization—ubiquitous in DML—actually breaks standard gradient-based explanation tools. By removing the normalization step during the explanation phase (but keeping it for the model), they get much sharper, more accurate heatmaps.
  • Interactive Retrieval: Because the method can isolate the similarity of specific parts, it enables "interactive retrieval." A user can draw a box around a specific region (like a unique bag or a specific beard style), and the system can retrieve images based only on that part's similarity, even if the model wasn't originally trained for part-based search.

Key Results

  • Superior Localization: On the CUB bird dataset, their method achieved a localization accuracy of 50.6% (at IoU=0.5), vastly outperforming standard Grad-CAM, which only hit 16.7%.
  • Human Approval: In Amazon Mechanical Turk (AMT) studies, human workers found the explanations from activation decomposition to be significantly more "reasonable" and intuitive than those from Grad-CAM variants.
  • Orientation Estimation: In cross-view geo-localization, using point-specific maps to align street and aerial images resulted in much higher accuracy. They achieved an angle error of less than ±3.5° for 16% of samples, compared to less than 12% using overall maps.
  • Model Diagnosis: The authors used their maps to show that a model trained with "Triplet Loss" was actually focusing more on background clutter than the actual object, explaining why it performed worse on validation sets compared to a model trained with "Multi-Similarity Loss."

Limitations and Future Work

  • Symmetry Issues: In applications like geo-localization, the maps can sometimes struggle with symmetric features (e.g., a road that looks identical in two opposite directions), leading to 180-degree orientation errors.
  • Differentiability: While the method handles most common layers, it relies on the network being differentiable. Extremely exotic, non-differentiable architectures might require further Taylor expansion approximations.
  • Future Directions: The authors suggest that these visual explanations could be used to improve models during training, perhaps by enforcing that models focus on the "right" regions through attention mechanisms or loss constraints.

Summary updated

BibTeX
@article{zhu2021visual,
  author = {Sijie Zhu and Taojiannan Yang and Chen Chen},
  title = {{Visual Explanation for Deep Metric Learning}},
  journal = {IEEE Trans. Image Process.},
  year = {2021},
  url = {https://openreview.net/forum?id=jH6HT8yRdQ},
}
Figure