Learnable Visual Words for Interpreting Image Recognition Models

Wenxiao Xiao, Zhengming Ding, Hongfu Liu

TL;DR

This paper introduces Learnable Visual Words (LVW), a self-interpretable framework that explains deep image classifiers using shared, cross-category visual primitives. By removing rigid class-specific prototype constraints and enforcing an attention-guided alignment loss with the underlying model’s Grad-CAM maps, LVW achieves state-of-the-art predictive accuracy while generating explanations that remain faithful to where the base model actually looks.

What Problem Does This Paper Address?

Post-hoc explanation methods like Grad-CAM show where a convolutional neural network (CNN) looks, but not how it reasons. Conversely, prototype-based networks (e.g., ProtoPNet) explain decisions by matching image patches to prototypical training examples ("this looks like that"). However, existing prototype architectures suffer from two major flaws:

  1. Class-specific rigidity: Prototypes are strictly tied to single classes, harming generalizability and ignoring visual features shared across categories (e.g., tires on cars vs. trucks).
  2. Spurious alignment: Without spatial grounding, prototypes often latch onto background artifacts (like plates in food images) rather than discriminative foreground cues, leading to explanations disconnected from the base model's true attention.

Methods

LVW builds on the ProtoPNet formulation using a CNN backbone (e.g., ResNet-34), a prototype/visual word layer, and a linear prediction layer, introducing two major innovations:

  • Cross-Category Semantic Visual Words: Rather than forcing visual words to separate by class via a separation loss, LVW removes this constraint while keeping a clustering loss ($L_c$). This encourages visual words to represent reusable, generic visual concepts shared across classes.
  • Dual Fidelity Preservation (Attention-Guided Alignment): To ensure the explainer is faithful to the base network, the model aligns its top-$k$ most similar visual words' activation heatmaps with the base model's class-level attention map (derived from Grad-CAM). The alignment loss ($L_a$) minimizes the mean squared error between the base model's attention map $\bar{A}_i$ and the pooled visual words activation heatmap $\hat{A}^k_i$: $$L_a = \frac{1}{N}\sum_{i=1}^N \|\bar{A}_i - \hat{A}_i^k\|^2$$
  • IoU Coverage Metric: To quantitatively benchmark explanation fidelity, the authors propose an Intersection-over-Union metric ($\text{IoU}_{q,m}$) measuring the overlap between the thresholded base attention map and the top-$k$ visual words' activation map.
Input Image ──> Backbone Feature Map ──> Prototype Distances ──> Class Prediction
                       │                               │
                       │                        (Top-k Heatmaps)
                       ▼                               ▼
                 Base Grad-CAM ◀── Attention MSE ── Max-Pooled Map

Datasets

The authors evaluate LVW on six non-cropped image benchmarks:

  • STL10: 10 general object classes.
  • Oxford 102 Flower: 102 fine-grained flower classes.
  • Oxford-IIIT Pets: 37 cat and dog breeds.
  • Stanford Dogs: 120 fine-grained dog breeds.
  • Food-101: 101 food classes (large-scale fine-grained).
  • Animals with Attributes 2 (AwA2): 50 animal classes (used also for zero-shot composition tests).

Key Insights and Ideas

  • Simplification outperforms complexity: Removing the separation loss in ProtoPNet doesn't just enable cross-class feature sharing—it consistently boosts classification accuracy across all six datasets.
  • Explaining errors productively: When the base model makes an incorrect prediction, LVW’s attention alignment helps diagnose why. For instance, if a base model misclassifies a squirrel as a walrus because it fixated on a nearby soda can and tree stump, LVW flags visual words matching "walrus skin" on the bark and "seal skin" on the aluminum can.
  • Interpreting unseen categories: Because visual words are shared, the model can interpret classes it was never trained on. Tested on an unseen "Liger" image, LVW decomposed the animal into visual words for "lion face," "lion mane," and "tiger stripes."

Key Results

  • Superior Predictive Accuracy: Evaluated with a ResNet-34 backbone, LVW outperformed prototype baselines (ProtoPNet, ProtoTree, ProtoPShare, TesNet) on 5 out of 6 datasets, achieving 89.75% on STL10, 91.81% on Oxford Flowers, 86.20% on Oxford Pets, 73.81% on Stanford Dogs, and 76.33% on Food-101.
  • Drastically Higher Explanation Fidelity: LVW outperformed all baselines by substantial margins in IoU coverage:
  • On Oxford Flowers, LVW reached an IoU of 0.7967 (vs. 0.6708 for the best baseline, TesNet, and 0.3081 for ProtoPNet).
  • On Oxford Pets, LVW scored 0.8086 IoU (vs. 0.7038 for TesNet).
  • Across multiple binarization thresholds ($q \in [10, 90]$), LVW maintained high overlap, whereas baseline prototype heatmaps degraded rapidly toward zero at stricter thresholds.
  • Architecture Agnostic: Substituting the backbone with VGG-19 on Oxford-IIIT Pets yielded similar dominance (LVW: 87.93% accuracy, 0.6426 IoU vs. ProtoPNet's 86.24% / 0.3696).

Limitations and Future Work

  • Small Objects and Clutter: When an object occupies an exceptionally small region of the input, $L_2$-distance matching over feature patches can cause visual words to bind to background noise rather than the target subject.
  • Dependence on Base Attention Quality: The method relies on Grad-CAM maps as supervision; if base model attention maps are noisy or coarse, visual word spatial alignment may inherit those flaws.
  • Distance Metric: Relying strictly on $L_2$ distance in embedding space can occasionally yield semantically incongruent matches. The authors point to posture detection, refined similarity metrics, and vision transformer (ViT) backbones as avenues for future exploration.

Summary updated

BibTeX
@inproceedings{xiao2023learnable,
  author = {Wenxiao Xiao and Zhengming Ding and Hongfu Liu},
  title = {{Learnable Visual Words for Interpreting Image Recognition Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=lb8wXVGWn0E},
}
Figure