Introduction
Deep learning models are frequently criticized for being "black boxes," leading to the development of visual explanation methods like Class Activation Mapping (CAM) and Grad-CAM. These techniques highlight the pixels that most influence a model's decision. However, most existing methods are designed for softmax-based classifiers that utilize a Fully Connected (FC) layer to predict class labels.
In contrast, metric learning—widely used in few-shot learning and image retrieval—maps images into an embedding space where similarity is determined by distance metrics (e.g., Euclidean distance or Cosine similarity) rather than class scores. Because metric learning models lack a final classification layer, traditional CAM-based methods are inapplicable. The authors propose the Similar Feature Activation Map (SFAM) to address this gap, providing a metric-agnostic framework for explaining pairwise image similarities.
Methodology: Similar Feature Activation Map (SFAM)
The core innovation of SFAM is the Channel-wise Contribution Importance Score (CIS), which derives weights based on the similarity function itself rather than gradients from a class score.
The process follows three primary steps:
- Feature Extraction: A Query image ($Q$) and a Support image ($S$) are processed through a CNN backbone to generate high-dimensional feature maps.
- CIS Calculation: Weights are derived based on the specific distance metric used. For Euclidean Distance, the CIS measures how much the squared difference in a specific channel contributes to the total distance; channels with smaller differences receive higher weights. For Cosine Similarity, the CIS is derived from the channel-wise contribution to the dot product of normalized vectors.
- Map Generation: The final SFAM is a linear combination of the feature maps, weighted by the normalized CIS. This produces a heatmap highlighting regions where the two images share discriminative features, such as a bird's beak or wing patterns.
Experimental Setup and Results
The researchers evaluated SFAM using the CUB200-2011 dataset, a standard benchmark for fine-grained bird species recognition. The method was tested across two primary tasks: few-shot learning (using the FRN model) and image retrieval (using the GPW model).
Quantitative Performance
SFAM significantly outperformed existing baselines, including RAM, CG-RAM, and Grad-FAM, across both Mean Intersection over Union (IoU) and Localization Accuracy metrics.
As shown in the table above, SFAM achieved a 52.33% Mean IoU and 69.74% Localization Accuracy, surpassing the best baseline (Grad-FAM) by over 2% and 7%, respectively. In image retrieval tasks using Cosine similarity, SFAM reached 55.65% IoU, maintaining its lead over alternative explainers.
Qualitative Analysis and Sanity Checks
Qualitatively, SFAM produces "cleaner" heatmaps that tightly bound the object of interest, whereas baseline methods often highlight irrelevant background noise. To ensure the method explains learned features rather than simple edge detection, the authors performed a "cascading randomization" test. By randomly resetting CNN layer weights, they observed a degradation in heatmap quality, confirming that SFAM accurately reflects the model's internal logic.
Conclusion
SFAM provides a robust, metric-agnostic solution for visualizing explanations in metric learning. By focusing on pairwise similarity through the CIS, it successfully identifies shared discriminative features between images. Future work may involve extending this framework to Vision Transformers (ViTs) and evaluating its performance in complex, multi-object scenes.
Summary updated