[Paper Review] CAT: Cross Attention in Vision Transformer
This paper proposes Cross Attention Transformer (CAT), a novel attention mechanism that alternates between intra-patch self-attention and inter-patch cross-attention on single-channel feature maps to reduce computational cost while preserving global and local feature representation. CAT achieves state-of-the-art performance on ImageNet-1K (82.8% top-1 accuracy) and improves downstream tasks like COCO object detection and ADE20K semantic segmentation with lower computation than standard Transformers.
Since Transformer has found widespread use in NLP, the potential of Transformer in CV has been realized and has inspired many new approaches. However, the computation required for replacing word tokens with image patches for Transformer after the tokenization of the image is vast(e.g., ViT), which bottlenecks model training and inference. In this paper, we propose a new attention mechanism in Transformer termed Cross Attention, which alternates attention inner the image patch instead of the whole image to capture local information and apply attention between image patches which are divided from single-channel feature maps capture global information. Both operations have less computation than standard self-attention in Transformer. By alternately applying attention inner patch and between patches, we implement cross attention to maintain the performance with lower computational cost and build a hierarchical network called Cross Attention Transformer(CAT) for other vision tasks. Our base model achieves state-of-the-arts on ImageNet-1K, and improves the performance of other methods on COCO and ADE20K, illustrating that our network has the potential to serve as general backbones. The code and models are available at \url{https://github.com/linhezheng19/CAT}.
Motivation & Objective
- To address the high computational cost of standard self-attention in Vision Transformers when applied to images.
- To integrate the local invariance and efficiency of CNNs with the global modeling capability of Transformers.
- To design a hierarchical feature extraction mechanism that generates multi-scale features like CNNs, suitable for diverse vision tasks.
- To reduce computational complexity without sacrificing performance by replacing full-attention with patch-wise and single-channel attention.
- To create a general-purpose backbone that outperforms existing CNN and Transformer-based models on standard benchmarks.
Proposed method
- Introduces Cross Attention by alternating intra-patch self-attention on local image patches and cross-attention between patches using single-channel feature maps.
- Applies convolutional patch embedding with 4×4 kernels and stride 4 to reduce spatial resolution and generate initial patch tokens.
- Performs multi-head self-attention within each patch to capture local spatial dependencies, reducing computation compared to full image self-attention.
- Applies cross-attention across patches using single-channel feature maps to model long-range dependencies with significantly reduced computation.
- Constructs a hierarchical architecture (CAT) that produces feature maps of varying spatial scales, mimicking CNNs, while retaining Transformer-style global modeling.
- Employs absolute positional encoding and dropout in self-attention modules to improve training stability and generalization.
Experimental results
Research questions
- RQ1Can intra-patch and inter-patch attention mechanisms be alternated to reduce computational cost while maintaining performance in Vision Transformers?
- RQ2Can a hybrid attention mechanism combining CNN-like local invariance and Transformer-like global modeling be designed with minimal computational overhead?
- RQ3Does replacing full-image self-attention with patch-wise and single-channel cross-attention lead to better performance and efficiency on standard vision benchmarks?
- RQ4Can the proposed architecture serve as a strong, general-purpose backbone for diverse vision tasks such as classification, detection, and segmentation?
- RQ5How does the design choice of patch embedding (convolutional vs. slicing) and attention components affect model performance and training stability?
Key findings
- The base CAT model achieves 82.8% top-1 accuracy on ImageNet-1K, matching state-of-the-art performance of both CNN and Transformer-based models.
- On COCO 2017 object detection, CAT-B improves AP by 4.2% over ResNet101 when used as a backbone with Semantic FPN.
- On ADE20K semantic segmentation, CAT-B achieves 44.9% mIoU with 160k iterations, a 4.2% improvement over ResNet101.
- Ablation studies show that the convolutional patch embedding method performs equivalently to slicing, and the choice of multi-head attention or shifted windows does not significantly improve performance.
- Dropout with rate 0.2 in self-attention layers improves generalization, indicating mild overfitting in the base architecture.
- The absence of absolute positional encoding leads to a 0.2% drop in top-1 accuracy, confirming its importance for performance.
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.