CrossFormer:一种基于跨尺度注意力的多功能视觉Transformer
CrossFormer: A Versatile Vision Transformer Hinging on Cross-scale Attention
摘要:
Transformers在处理计算机视觉任务方面取得了很大进展。然而,现有的视觉Transformer还不具备建立不同尺度的特征之间的交互的能力,这是视觉输入的感知重要。原因有两个方面:(1)每层的输入嵌入是等尺度的,因此不能提取跨尺度特征;(2)为了降低计算成本,一些视觉Transformer在自注意模块内合并相邻的嵌入,从而牺牲嵌入的小尺度(细粒度)特征,并且还禁用跨尺度交互。为此,我们提出了跨尺度嵌入层(CEL)和长短距离注意(LSDA)。一方面,CEL将每个嵌入与不同尺度的多个补丁混合,为自我注意模块本身提供跨尺度特征。另一方面,LSDA将自注意模块分为短距离和长距离两部分,这不仅减少了计算负担,而且在嵌入中同时保留了小尺度和大尺度特征。通过以上两种设计,实现了跨尺度注意。此外,我们提出了一种动态的视觉Transformer的位置偏差,使流行的相对位置偏差适用于可变大小的图像。在跨尺度注意力模块的基础上,我们构建了一个通用的视觉架构,称为CrossFormer,它可以容纳可变大小的输入。大量的实验表明,CrossFormer在图像分类、目标检测、实例分割和语义分割任务上优于其他视觉Transformer。代码已发布:https://github.com/cheerss/CrossFormer。
英文摘要:
Transformers have made great progress in dealing with computer vision tasks. However, existing vision transformers do not yet possess the ability of building the interactions among features of different scales, which is perceptually important to visual inputs. The reasons are two-fold: (1) Input embeddings of each layer are equal-scale, so no cross-scale feature can be extracted; (2) to lower the computational cost, some vision transformers merge adjacent embeddings inside the self-attention module, thus sacrificing small-scale (fine-grained) features of the embeddings and also disabling the cross-scale interactions. To this end, we propose Cross-scale Embedding Layer (CEL) and Long Short Distance Attention (LSDA). On the one hand, CEL blends each embedding with multiple patches of different scales, providing the self-attention module itself with cross-scale features. On the other hand, LSDA splits the self-attention module into a short-distance one and a long-distance counterpart, which not only reduces the computational burden but also keeps both small-scale and large-scale features in the embeddings. Through the above two designs, we achieve cross-scale attention. Besides, we put forward a dynamic position bias for vision transformers to make the popular relative position bias apply to variable-sized images. Hinging on the cross-scale attention module, we construct a versatile vision architecture, dubbed CrossFormer, which accommodates variable-sized inputs. Extensive experiments show that CrossFormer outperforms the other vision transformers on image classification, object detection, instance segmentation, and semantic segmentation tasks. The code has been released: https://github.com/cheerss/CrossFormer.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。