[论文解读] SP-ViT: Learning 2D Spatial Priors for Vision Transformers
本文提出空间先验增强的自注意力机制(SP-SA),一种可学习的注意力机制,通过神经网络参数化空间关系函数,自动发现视觉变换器中的2D空间归纳偏置。采用SP-SA的SP-ViT模型在ImageNet-1K上实现了86.3%的Top-1准确率,参数量比之前SOTA模型减少50%。
Recently, transformers have shown great potential in image classification and established state-of-the-art results on the ImageNet benchmark. However, compared to CNNs, transformers converge slowly and are prone to overfitting in low-data regimes due to the lack of spatial inductive biases. Such spatial inductive biases can be especially beneficial since the 2D structure of an input image is not well preserved in transformers. In this work, we present Spatial Prior-enhanced Self-Attention (SP-SA), a novel variant of vanilla Self-Attention (SA) tailored for vision transformers. Spatial Priors (SPs) are our proposed family of inductive biases that highlight certain groups of spatial relations. Unlike convolutional inductive biases, which are forced to focus exclusively on hard-coded local regions, our proposed SPs are learned by the model itself and take a variety of spatial relations into account. Specifically, the attention score is calculated with emphasis on certain kinds of spatial relations at each head, and such learned spatial foci can be complementary to each other. Based on SP-SA we propose the SP-ViT family, which consistently outperforms other ViT models with similar GFlops or parameters. Our largest model SP-ViT-L achieves a record-breaking 86.3% Top-1 accuracy with a reduction in the number of parameters by almost 50% compared to previous state-of-the-art model (150M for SP-ViT-L vs 271M for CaiT-M-36) among all ImageNet-1K models trained on 224x224 and fine-tuned on 384x384 resolution w/o extra data.
研究动机与目标
- 为解决视觉变换器在低数据场景下因缺乏空间归纳偏置而导致的收敛缓慢和过拟合问题。
- 开发一种可学习的替代方案,以替代手工设计的卷积归纳偏置,从而捕捉超出局部感受野的多样化空间关系。
- 在保持全局感受野的同时,通过动态、数据驱动的注意力机制学习互补的空间先验。
- 通过用自适应、神经参数化的空间关系函数替代固定归纳偏置,提升模型效率与准确率。
提出的方法
- SP-SA通过引入可学习的空间关系函数来增强原始自注意力机制,该函数将相对块坐标映射为注意力分数,实现对特定空间关系的动态聚焦。
- 空间关系函数由多层感知机(MLP)参数化,并与ViT在训练过程中联合优化,使模型能够自主发现有效的空间先验。
- 每个注意力头学习独特的空间先验,从而在网络中互补地建模局部与非局部的空间依赖关系。
- 该方法将固定的位置嵌入替换为可学习的非线性空间先验,同时适应输入内容和相对位置。
- SP-ViT通过将ViT中的标准注意力模块替换为SP-SA模块构建而成,保持架构简洁的同时增强归纳偏置。
- 模型在224×224分辨率的ImageNet-1K上进行训练,并在384×384分辨率上微调,无需额外数据或在更大分辨率上的预训练。
实验结果
研究问题
- RQ1可学习的非线性空间先验是否能通过捕捉超越固定局部感受野的多样化2D空间关系,提升视觉变换器的性能?
- RQ2将神经空间关系函数与ViT架构联合优化,是否能带来比固定位置嵌入或手工设计偏置更好的泛化能力与更快的收敛速度?
- RQ3每个注意力头和层使用独立的空间先验,是否能优于共享或单一先验,在建模互补空间归纳偏置方面表现更优?
- RQ4SP-ViT在与现有SOTA ViT模型相比时,能在多大程度上减少模型参数量,同时保持或提升准确率?
主要发现
- SP-ViT-L在ImageNet-1K上实现了新的SOTA 86.3% Top-1准确率,优于先前SOTA模型如CaiT-M-36。
- 与CaiT-M-36(271M参数)相比,SP-ViT-L将模型参数量减少了近50%(降至150M),展现出显著的效率优势。
- 采用每头每层独立空间先验的模型达到83.6% Top-1准确率,优于使用共享或单一先验的设置。
- SP-SA显著优于使用1D或2D相对位置嵌入的原始自注意力机制,证明了可学习非线性空间先验的优越性。
- 消融实验确认非线性空间关系函数至关重要——线性或固定参数的替代方案性能更差。
- SP-SA优于手工设计的方法如Positional Self-Attention和Local SA,表明可学习先验可替代人工设计并取得更优结果。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。