[论文解读] Stand-Alone Self-Attention in Vision Models
该论文表明自注意力可以作为视觉模型的独立原语,替代卷积,构建完全基于注意力的网络,在 ImageNet 上以更少的参数和 FLOPS 超过卷积基线,在 COCO 上与 RetinaNet 相当但资源更少。
Convolutions are a fundamental building block of modern computer vision systems. Recent approaches have argued for going beyond convolutions in order to capture long-range dependencies. These efforts focus on augmenting convolutional models with content-based interactions, such as self-attention and non-local means, to achieve gains on a number of vision tasks. The natural question that arises is whether attention can be a stand-alone primitive for vision models instead of serving as just an augmentation on top of convolutions. In developing and testing a pure self-attention vision model, we verify that self-attention can indeed be an effective stand-alone layer. A simple procedure of replacing all instances of spatial convolutions with a form of self-attention applied to ResNet model produces a fully self-attentional model that outperforms the baseline on ImageNet classification with 12% fewer FLOPS and 29% fewer parameters. On COCO object detection, a pure self-attention model matches the mAP of a baseline RetinaNet while having 39% fewer FLOPS and 34% fewer parameters. Detailed ablation studies demonstrate that self-attention is especially impactful when used in later layers. These results establish that stand-alone self-attention is an important addition to the vision practitioner's toolbox.
研究动机与目标
- 展示通过独立自注意力进行的基于内容的交互能够替代视觉模型中的空间卷积。
- 通过将卷积替换为局部自注意力,构建完全基于注意力的视觉架构。
- 表明独立注意力在 ImageNet 上以更少的参数和 FLOPS 超越卷积基线。
- 通过消融研究表征独立注意力在网络中哪些位置能带来最大提高。
- 确定视觉变换器中干线层和相对位置编码的实际设计考量。
提出的方法
- 开发一个局部自注意力层,对每个像素关注大小为 k×k 的记忆块。
- 使用带有查询、键、值线性投影(W_Q、W_K、W_V)的多头自注意力。
- 引入二维相对位置嵌入,以实现平移等变性并提升表达能力。
- 将 ResNet 瓶颈块中的所有空间卷积替换为所提出的注意力层,保持下采样结构。
- 试验卷积干线与注意力干线之分,包括带有时空变换的值的干线,以缩小干线性能差距。
- 在 ImageNet 分类(ResNet 变体)和 COCO 目标检测(RetinaNet)上进行评估,并对空间范围、位置编码和干线设计进行消融。
实验结果
研究问题
- RQ1独立的局部自注意力能否替代空间卷积,形成一个完全基于注意力的视觉模型?
- RQ2相比卷积基线,完全基于注意力的 ResNet 在 ImageNet 和 COCO 上在准确率、FLOPS 和参数数方面的表现如何?
- RQ3在网络的哪个位置独立注意力最有益(干线与后续层)以及结构选择如何影响性能?
- RQ4空间范围(k)和位置编码类型对性能的影响?
- RQ5干线修改(具有空间感知的值)是否比简单的注意力干线改进基于注意力的网络?
主要发现
| 模型 | FLOPS (B) | Params (M) | Top-1 Acc (%) |
|---|---|---|---|
| Baseline (ResNet-26) | 4.7 | 13.7 | 74.5 |
| Conv-stem + Attention (ResNet-26) | 4.5 | 10.3 | 75.8 |
| Full Attention (ResNet-26) | 4.7 | 10.3 | 74.8 |
| Baseline (ResNet-38) | 6.5 | 19.6 | 76.2 |
| Conv-stem + Attention (ResNet-38) | 5.7 | 14.1 | 77.1 |
| Full Attention (ResNet-38) | 6.0 | 14.1 | 76.9 |
| Baseline (ResNet-50) | 8.2 | 25.6 | 76.9 |
| Conv-stem + Attention (ResNet-50) | 7.0 | 18.0 | 77.4 |
| Full Attention (ResNet-50) | 7.2 | 18.0 | 77.6 |
- 一个通过用局部自注意力替换卷积而得到的完全注意力模型,在 ImageNet Top-1 上取得更高的准确率,FLOPS 下降 12%,参数减少 29% 相较卷积基线。
- 在 COCO 检测上,完全基于注意力的骨干网在使用 39% 更少的 FLOPS 和 34% 更少的参数的情况下达到 RetinaNet 的 mAP。
- 消融研究表明将注意力层放在网络后部的收益更大,而不是前部,提示卷积更善于捕获低层特征,而注意力整合全局信息。
- 相对二维位置编码显著提升性能,优于绝对编码或无编码(相对为测试选项中的最佳)。
- 干线中的空间感知值变换在性能上优于简单的独立注意力干线和使用空间卷积作为值的干线。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。