[论文解读] Do We Really Need Explicit Position Encodings for Vision Transformers
本文提出条件位置编码(PEG),一种可学习的、基于局部邻域的位置编码方案,用于替代视觉变换器中的固定位置编码。通过从每个标记的空间上下文条件生成位置编码,PEG 实现了任意输入序列长度,并在 ImageNet 分类任务上实现了最先进性能,优于使用预定义位置编码的模型。
Almost all visual transformers such as ViT or DeiT rely on predefined positional encodings to incorporate the order of each input token. These encodings are often implemented as learnable fixed-dimension vectors or sinusoidal functions of different frequencies, which are not possible to accommodate variable-length input sequences. This inevitably limits a wider application of transformers in vision, where many tasks require changing the input size on-the-fly. In this paper, we propose to employ a conditional position encoding scheme, which is conditioned on the local neighborhood of the input token. It is effortlessly implemented as what we call Position Encoding Generator (PEG), which can be seamlessly incorporated into the current transformer framework. Our new model with PEG is named Conditional Position encoding Visual Transformer (CPVT) and can naturally process the input sequences of arbitrary length. We demonstrate that CPVT can result in visually similar attention maps and even better performance than those with predefined positional encodings. We obtain state-of-the-art results on the ImageNet classification task compared with visual Transformers to date. Our code will be made available at this https URL .
研究动机与目标
- 解决视觉变换器中固定位置编码的局限性,该局限性限制了序列长度的自适应能力。
- 消除视觉变换器中对预定义的固定维度正弦或可学习向量的需求。
- 使视觉变换器能够自然且高效地处理可变长度输入序列。
- 开发一种上下文感知且基于局部图像特征的空间条件位置编码机制。
- 在保持输入尺寸灵活性的同时,实现在 ImageNet 分类任务上的最先进性能。
提出的方法
- 提出位置编码生成器(PEG),基于每个输入标记的局部空间邻域计算位置编码。
- 使用小型卷积网络,根据每个标记周围的特征图生成条件位置嵌入。
- 将生成的位置编码直接集成到视觉变换器的自注意力机制中。
- 用 PEG 生成的嵌入替换标准的可学习或正弦位置编码,实现动态序列长度处理。
- 与变换器架构其余部分端到端联合训练 PEG 模块。
- 通过依赖局部上下文而非固定位置向量,实现在任意输入尺寸上的推理。
实验结果
研究问题
- RQ1是否能够从局部图像特征动态生成位置编码,而非预先定义?
- RQ2基于上下文的条件位置编码方案是否优于视觉变换器中的固定位置编码?
- RQ3带有条件位置编码的变换器模型是否能在不降低性能的情况下处理可变长度输入序列?
- RQ4是否可能在不使用固定位置嵌入的情况下实现在 ImageNet 上的最先进准确率?
- RQ5PEG 与传统位置编码方法在注意力图和模型行为方面有何异同?
主要发现
- 采用 PEG 的 CPVT 模型在 ImageNet 分类基准上实现了最先进性能,超越了先前的视觉变换器模型。
- CPVT 生成的注意力图与使用预定义位置编码的模型视觉上相似,表明特征定位能力相当。
- 采用 PEG 的模型在不同输入尺寸下均保持强大性能,体现出序列长度的灵活性。
- 条件位置编码机制实现了对任意长度输入序列的无缝处理,克服了标准视觉变换器的关键局限。
- 消融研究证实 PEG 有效且具备泛化能力,在固定位置编码基线之上保持一致的性能提升。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。