[论文解读] How Do Vision Transformers Work?
本文分析 Vision Transformers (ViTs) 中的多头自注意力如何拉平损失景观并充当数据特定的空间平滑,提出 AlterNet 将 CNN 块与 MSA 融合,以在大数据和小数据场景下提升性能。
The success of multi-head self-attentions (MSAs) for computer vision is now indisputable. However, little is known about how MSAs work. We present fundamental explanations to help better understand the nature of MSAs. In particular, we demonstrate the following properties of MSAs and Vision Transformers (ViTs): (1) MSAs improve not only accuracy but also generalization by flattening the loss landscapes. Such improvement is primarily attributable to their data specificity, not long-range dependency. On the other hand, ViTs suffer from non-convex losses. Large datasets and loss landscape smoothing methods alleviate this problem; (2) MSAs and Convs exhibit opposite behaviors. For example, MSAs are low-pass filters, but Convs are high-pass filters. Therefore, MSAs and Convs are complementary; (3) Multi-stage neural networks behave like a series connection of small individual models. In addition, MSAs at the end of a stage play a key role in prediction. Based on these insights, we propose AlterNet, a model in which Conv blocks at the end of a stage are replaced with MSA blocks. AlterNet outperforms CNNs not only in large data regimes but also in small data regimes. The code is available at https://github.com/xxxnell/how-do-vits-work.
研究动机与目标
- 研究 MSAs 如何提升泛化能力以及它们如何影响损失景观。
- 在频率行为和数据特异性方面比较 MSAs 与 Convs。
- 解释如何在混合架构中使 MSAs 与 Convs 相协调。
- 提出将 CNN 块与 MSA 块融合的架构设计准则。
- 证明分阶段的交替 CNN/MSA 模式在不同数据规模下可优于 CNN。
提出的方法
- 将 MSAs 视为对特征图的可训练空间平滑,使用自注意力方程。
- 使用损失景观可视化和 Hessian 谱来评估优化性质。
- 对特征图进行傅里叶分析,比较 MSAs 与 Convs 之间的高频内容。
- 在局部性约束的 MSAs 与多阶段架构(PiT、Swin)与 CNN 的对比中进行实验。
- 通过在阶段末端用 MSAs 替代 Convs,遵循构建规则提出 AlterNet。
- 在 CIFAR-100 和 ImageNet 上评估 AlterNet,以与 CNN 和 ViTs 进行比较。
实验结果
研究问题
- RQ1MSAs 是作为长程依赖还是数据特定的空间平滑器?
- RQ2MSAs 与 Convs 在对损失景观和优化动力学的影响上有何差异?
- RQ3一个在 CNN 块和 MSA 块之间交替的混合架构是否能在不同数据规模下提升性能?
- RQ4哪些架构规则可最大化多阶段网络中 MSAs 的益处?
主要发现
- MSAs 能拉平损失景观并提升泛化能力,主要源于数据特异性而非长程依赖。
- MSAs 充当低通滤波器,而 Convs 充当高通滤波器;二者是互补的。
- 多阶段网络表现为一系列小模型,阶段末端的 MSA 扮演关键预测角色。
- 局部 MSA 结合合适的感受野可通过减少负 Hessian 特征值来改善优化。
- 在末阶段放置的卷积与更多阶段后段的高头数的 MSA 的卷积化,在小数据和大数据场景下均有更好表现(AlterNet)。
- AlterNet 在 CIFAR-100 上优于 CNNs 和 ViTs,并且可扩展到 ImageNet,即使在小数据场景中也如此。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。