Abstract
We show how to augment any convolutional network with an attention-based global map to achieve non-local reasoning. We replace the final average pooling by an attention-based aggregation layer akin to a single transformer block, that weights how the patches are involved in the classification decision. We plug this learned aggregation layer with a simplistic patch-based convolutional network parametrized by 2 parameters (width and depth). In contrast with a pyramidal design, this architecture family maintains the input patch resolution across all the layers. It yields surprisingly competitive trade-offs between accuracy and complexity, in particular in terms of memory consumption, as shown by our experiments on various computer vision tasks: object classification, image segmentation and detection.
Introduction
The computer vision landscape is currently characterized by a competition between Convolutional Neural Networks (ConvNets) and Vision Transformers (ViTs). Traditional ConvNets, such as ResNet, typically employ a pyramidal design where spatial resolution is progressively reduced. At the final stage, Global Average Pooling (GAP) is used to condense spatial information into a classification vector. However, GAP treats all spatial features equally, limiting the model's ability to perform non-local reasoning and reducing interpretability.
In contrast, ViTs utilize a "class token" that attends to all image patches, enabling built-in interpretability through attention maps and global context. However, this comes at the cost of quadratic computational complexity relative to image resolution. This work introduces PatchConvNet, an architecture designed to combine the efficiency of convolutions with the global reasoning and interpretability of Transformers.
Architecture and Methods
The proposed PatchConvNet architecture is defined by its simplicity, controlled primarily by two parameters: width ($d$) and depth ($N$). It consists of three primary components:
- Convolutional Stem: A lightweight stage comprising four $3 \times 3$ convolutions that transform the input image into $16 \times 16$ pixel patches.
- The Trunk (Column): Unlike standard pyramidal ConvNets, the trunk maintains a constant spatial resolution and embedding dimension across all $N$ layers. Each block integrates $1 \times 1$ convolutions for channel mixing, $3 \times 3$ convolutions for spatial processing, and Squeeze-and-Excitation layers.
- Attention-Based Pooling: The core innovation is the replacement of standard average pooling with a single cross-attention layer. A trainable class token acts as a query, attending to the final feature patches to produce a weighted aggregation.
By specializing this attention per class, the model can generate distinct saliency maps for different objects within a single image, providing high-resolution explainability without the need for post-processing techniques like Grad-CAM.
Experimental Results
PatchConvNet was evaluated across several benchmarks, including ImageNet classification, COCO object detection, and ADE20k semantic segmentation.
Performance and Efficiency
The S60 model (a "Small" variant with 60 layers) achieved 82.1% top-1 accuracy on ImageNet-1k, outperforming ResNet-50 (80.4%) while maintaining comparable FLOPs. A key advantage of the non-pyramidal design is its linear scaling with image resolution, which contrasts with the quadratic scaling of standard Transformers.
As shown in the memory benchmarks, PatchConvNet demonstrates significantly lower peak memory consumption at high resolutions compared to ViT and Swin Transformer models. This efficiency makes it particularly well-suited for dense prediction tasks like segmentation and detection on large-scale images.
Interpretability
The attention-based pooling layer provides direct insight into the model's decision-making process. Because the aggregation occurs in a single softmax-based layer, the attention weights represent the mathematical contribution of each patch to the final classification. The resulting saliency maps are cleaner and higher-resolution than those produced by pyramidal networks, as the high-resolution features are preserved throughout the trunk.
Conclusion
PatchConvNet demonstrates that augmenting simple convolutional trunks with attention-based aggregation can yield competitive performance and superior interpretability. By maintaining constant resolution and utilizing linear-scaling attention, the architecture offers a robust and memory-efficient alternative to both traditional ConvNets and modern Transformers. Future work may involve optimizing the width/depth balance for specific hardware and exploring the architecture's potential in generative tasks.
Summary updated