CA-Stream: Attention-based Pooling for Interpretable Image Recognition

Felipe Torres, Hanwei Zhang, Ronan Sicre, Stéphane Ayache, Yannis Avrithis

Introduction

Convolutional Neural Networks (CNNs) are the workhorses of modern computer vision, yet they often function as "black boxes." While Vision Transformers (ViTs) offer inherent interpretability through self-attention and classification (CLS) tokens, CNNs typically rely on post-hoc saliency mapping techniques like Grad-CAM, which can be noisy or computationally intensive. This paper introduces CA-Stream (Cross-Attention Stream), a plug-and-play module designed to bring Transformer-like interpretability to CNNs by replacing standard Global Average Pooling (GAP) with a learnable attention mechanism.

The CA-Stream Architecture

The standard CNN approach uses GAP to aggregate spatial features into a single vector for classification. However, GAP is spatially "blind," treating all regions of a feature map with equal weight. CA-Stream addresses this by introducing a parallel attention-based branch.

The CA-Stream architecture integrates a parallel cross-attention branch with a learnable CLS token into a standard CNN backbone.

As shown in Figure 1, the architecture consists of:

  1. Learnable CLS Token: A vector ($q_0$) that evolves as it traverses the network, similar to the CLS token in ViTs.
  2. Cross-Attention Blocks: At various depths, the CLS token performs cross-attention with the backbone's feature maps ($F_0 \dots F_4$). This allows the token to selectively "query" relevant spatial information.
  3. Feature Masking: Mathematically, this process is equivalent to applying a "soft mask" to the features, effectively filtering out background noise and focusing the classifier on the most salient objects.

During training, the backbone and classifier remain frozen; only the CA-Stream parameters are optimized, ensuring the model's core logic is preserved while enhancing its transparency.

Experimental Results

The researchers evaluated CA-Stream on the ImageNet ILSVRC-2012 dataset using ResNet-50 and ConvNeXt-B architectures. The results demonstrate that CA-Stream significantly improves interpretability without compromising—and sometimes even improving—classification accuracy.

Accuracy and Interpretability Metrics

On ResNet-50, accuracy slightly increased from 74.55% to 74.70%. On the more modern ConvNeXt-B, accuracy remained stable (83.72% vs. 83.51%). However, the gains in interpretability were substantial. For ConvNeXt-B, the "Average Gain" (AG) metric—a measure of how well an explanation identifies important pixels—soared from 2.43 with standard GAP to 13.96 with CA-Stream when using Grad-CAM.

Qualitative Visualization

The visual impact of CA-Stream is most evident in the generated saliency maps. Compared to traditional GAP-based methods, CA-Stream produces heatmaps that are more tightly focused on the target objects.

Qualitative comparison of saliency maps generated using GAP versus CA-Stream across different attribution methods.

As illustrated in Figure 2, CA-Stream helps attribution methods like Grad-CAM and Score-CAM isolate objects (e.g., a snowboard or CRT screen) from cluttered backgrounds. This "raw attention" provides a class-agnostic view of what the model deems important, bridging the gap between how Transformers "attend" to data and how we explain CNN decisions.

Conclusion and Future Work

CA-Stream successfully integrates the interpretability of Transformers into CNN architectures. By making spatial aggregation an attention-driven process, it transforms interpretability from a post-hoc calculation into an inherent feature of the forward pass. While the method showed a slight decrease in performance on the Deletion (D) metric—likely due to out-of-distribution artifacts created when masking pixels—it outperformed standard pooling across nearly all other interpretability benchmarks. Future research may explore training the backbone and CA-Stream jointly to further refine the synergy between feature learning and spatial attention.

Summary updated

BibTeX
@inproceedings{torres2024ca,
  author = {Felipe Torres and Hanwei Zhang and Ronan Sicre and Stéphane Ayache and Yannis Avrithis},
  title = {{CA-Stream: Attention-based Pooling for Interpretable Image Recognition}},
  booktitle = {XAI4CV},
  year = {2024},
}
Figure