[Paper Review] Transformer in Convolutional Neural Networks
This paper proposes Hierarchical Multi-Head Self-Attention (H-MHSA), a method that reduces computational complexity in vision transformers by learning feature relationships hierarchically across spatial grids. By progressively merging small image patches into larger grids and treating each group as a single token, H-MHSA enables efficient attention computation while maintaining high accuracy, leading to a new CNN-backbone architecture called TransCNN that achieves state-of-the-art image recognition performance.
We tackle the low-efficiency flaw of vision transformer caused by the high computational/space complexity in Multi-Head Self-Attention (MHSA). To this end, we propose the Hierarchical MHSA (H-MHSA), whose representation is computed in a hierarchical manner. Specifically, our H-MHSA first learns feature relationships within small grids by viewing image patches as tokens. Then, small grids are merged into larger ones, within which feature relationship is learned by viewing each small grid at the preceding step as a token. This process is iterated to gradually reduce the number of tokens. The H-MHSA module is readily pluggable into any CNN architectures and amenable to training via backpropagation. We call this new backbone TransCNN, and it essentially inherits the advantages of both transformer and CNN. Experiments demonstrate that TransCNN achieves state-of-the-art accuracy for image recognition. Code and pretrained models are available at this https URL. This technical report will keep updating by adding more experiments.
Motivation & Objective
- To address the high computational and memory complexity of Multi-Head Self-Attention (MHSA) in vision transformers.
- To design a more efficient attention mechanism that maintains representational power while reducing computational load.
- To integrate the new mechanism into CNN architectures without architectural overhaul.
- To achieve state-of-the-art accuracy in image recognition using a hybrid CNN-transformer backbone.
- To enable end-to-end training via backpropagation for the proposed architecture.
Proposed method
- H-MHSA computes attention hierarchically by first processing small image patches as tokens within local grids.
- After learning intra-grid relationships, adjacent small grids are merged into larger grids, which are then treated as single tokens in the next level of attention computation.
- This hierarchical merging reduces the number of tokens at each level, progressively decreasing computational complexity.
- The H-MHSA module is designed to be plug-and-play into existing CNN architectures, preserving their inductive bias.
- The full architecture, named TransCNN, combines CNN feature extraction with hierarchical self-attention for improved representation learning.
- The model is trained end-to-end using standard backpropagation, enabling joint optimization of CNN and attention components.
Experimental results
Research questions
- RQ1Can hierarchical attention mechanisms reduce the computational cost of self-attention in vision transformers without sacrificing performance?
- RQ2How does hierarchical feature aggregation in H-MHSA compare to standard MHSA in terms of efficiency and accuracy?
- RQ3To what extent can a hybrid CNN-transformer backbone like TransCNN outperform pure CNN or vision transformer models?
- RQ4Is the H-MHSA module compatible with standard CNN training pipelines and backpropagation?
- RQ5What is the impact of hierarchical token merging on representation quality and model generalization?
Key findings
- TransCNN achieves state-of-the-art accuracy on image recognition benchmarks, outperforming existing models.
- The hierarchical attention mechanism significantly reduces computational complexity compared to standard MHSA.
- H-MHSA enables efficient attention computation by progressively reducing the number of tokens through grid merging.
- The proposed TransCNN architecture is compatible with standard CNN training and backpropagation.
- The method maintains strong representational capacity while improving efficiency, as demonstrated by performance gains.
- Code and pretrained models are publicly available, supporting reproducibility and further research.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.