LookHere:具备定向注意力的视觉Transformer可实现泛化与外推
LookHere: Vision Transformers with Directed Attention Generalize and Extrapolate
AI总结:
针对ViT外推到更多图像patch时表现差的问题,提出LookHere位置编码方法,通过2D注意力掩码限制注意力头视野,提升分类、抗攻击等性能,外推表现远超现有最优方法,还发布了ImageNet-HR高分辨率测试集。
摘要:
高分辨率图像能提供更多场景信息,可提升模型准确率。但计算机视觉领域的主流模型架构视觉Transformer(ViT)在不进行微调的情况下无法有效利用更大尺寸的图像——尽管Transformer具备序列长度灵活性,ViT在测试时外推到更多patch的表现很差。我们将这一缺陷归因于当前的patch位置编码方法,这类方法在外推时会造成分布偏移。\n我们提出了一种可直接替换普通ViT位置编码的方案,该方案利用2D注意力掩码将注意力头限制在朝向不同方向的固定视野范围内。我们的新方法名为LookHere,具备平移等变性,能保证注意力头的多样性,还能限制外推时注意力头面临的分布偏移。我们证明,在无外推的ImageNet数据集上,LookHere提升了分类性能(平均1.6%)、增强了对抗攻击鲁棒性(平均5.4%),还降低了校准误差(平均1.5%)。在外推场景下,当以224²像素训练、1024²像素测试时,LookHere在ImageNet上的表现优于当前最优(SoTA)位置编码方法2D-RoPE 21.7%。此外,我们发布了一个名为ImageNet-HR的高分辨率测试集,用于改进高分辨率图像分类器的评估。
英文摘要:
High-resolution images offer more information about scenes that can improve model accuracy. However, the dominant model architecture in computer vision, the vision transformer (ViT), cannot effectively leverage larger images without finetuning -- ViTs poorly extrapolate to more patches at test time, although transformers offer sequence length flexibility. We attribute this shortcoming to the current patch position encoding methods, which create a distribution shift when extrapolating. We propose a drop-in replacement for the position encoding of plain ViTs that restricts attention heads to fixed fields of view, pointed in different directions, using 2D attention masks. Our novel method, called LookHere, provides translation-equivariance, ensures attention head diversity, and limits the distribution shift that attention heads face when extrapolating. We demonstrate that LookHere improves performance on classification (avg. 1.6%), against adversarial attack (avg. 5.4%), and decreases calibration error (avg. 1.5%) -- on ImageNet without extrapolation. With extrapolation, LookHere outperforms the current SoTA position encoding method, 2D-RoPE, by 21.7% on ImageNet when trained at $224^2$ px and tested at $1024^2$ px. Additionally, we release a high-resolution test set to improve the evaluation of high-resolution image classifiers, called ImageNet-HR.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。