[论文解读] CAT: Cross Attention in Vision Transformer
本文提出了一种新型注意力机制——交叉注意力变换器(Cross Attention Transformer, CAT),通过在单通道特征图上交替使用块内自注意力和块间交叉注意力,降低计算成本,同时保持全局与局部特征表示能力。CAT在ImageNet-1K上达到82.8%的top-1准确率,性能达到当前最先进水平,并在COCO目标检测和ADE20K语义分割等下游任务中实现更低的计算量,表现优于标准Transformer模型。
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}.
研究动机与目标
- 解决标准自注意力机制在视觉Transformer中应用于图像时计算成本过高的问题。
- 将卷积神经网络(CNN)的局部不变性与高效性,与Transformer的全局建模能力相结合。
- 设计一种分层特征提取机制,生成类似CNN的多尺度特征,适用于多样化视觉任务。
- 通过用块级注意力和单通道注意力替代完整注意力机制,降低计算复杂度,同时不牺牲性能。
- 构建一种通用主干网络,在标准基准测试中超越现有的CNN和基于Transformer的模型。
提出的方法
- 通过在局部图像块上交替使用块内自注意力和使用单通道特征图的块间交叉注意力,引入交叉注意力机制。
- 采用4×4卷积核与步长为4的卷积块嵌入方法,降低空间分辨率并生成初始块标记。
- 在每个块内执行多头自注意力,以捕捉局部空间依赖关系,相比完整图像自注意力,计算量显著降低。
- 利用单通道特征图在块之间执行交叉注意力,以极低的计算量建模长程依赖关系。
- 构建分层架构(CAT),生成不同空间尺度的特征图,模仿CNN的特性,同时保留Transformer风格的全局建模能力。
- 在自注意力模块中使用绝对位置编码和dropout,以提升训练稳定性和泛化能力。
实验结果
研究问题
- RQ1是否可以通过交替使用块内与块间注意力机制,在保持性能的同时降低视觉Transformer中的计算成本?
- RQ2能否设计一种混合注意力机制,在计算开销极低的前提下,结合CNN的局部不变性与Transformer的全局建模能力?
- RQ3用块级注意力和单通道交叉注意力替代完整图像自注意力,是否能在标准视觉基准上实现更好的性能与效率?
- RQ4所提出的架构能否作为强大且通用的主干网络,适用于分类、检测和分割等多种视觉任务?
- RQ5块嵌入方式(卷积式 vs. 切片式)以及注意力组件的设计选择,如何影响模型性能与训练稳定性?
主要发现
- 基础CAT模型在ImageNet-1K上达到82.8%的top-1准确率,与当前最先进的CNN和基于Transformer的模型性能相当。
- 在COCO 2017目标检测任务中,当作为Semantic FPN主干网络使用时,CAT-B相比ResNet101的AP提升4.2%。
- 在ADE20K语义分割任务中,CAT-B在160k次迭代下达到44.9%的mIoU,相比ResNet101提升4.2%。
- 消融实验表明,卷积块嵌入方法与切片方法性能相当,多头注意力或移位窗口的选择对性能无显著影响。
- 在自注意力层中使用0.2的dropout率可提升泛化能力,表明基础架构存在轻微过拟合现象。
- 若省略绝对位置编码,top-1准确率下降0.2%,证实其对性能具有重要影响。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。