arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2304.04237cs.CV
收藏

Slide-Transformer:基于局部自注意力的层级视觉Transformer

Slide-Transformer: Hierarchical Vision Transformer with Local Self-Attention

Tsinghua University(清华大学);BNRist(北京国家信息科学与技术研究中心)

Xuran Pan, Tianzhu Ye, Zhuofan Xia, Shiji Song, Gao Huang

AI总结:

本文提出Slide Attention局部注意力模块,利用卷积操作替代低效Im2Col或特定CUDA内核,实现高效、灵活且通用的局部注意力,在多种视觉Transformer模型和基准上取得一致性能提升。

摘要:

自注意力机制是近期视觉Transformer(ViT)进展的关键因素,它能够从全局上下文中进行自适应特征提取。然而,现有的自注意力方法要么采用稀疏全局注意力,要么采用窗口注意力来降低计算复杂度,这可能会损害局部特征学习或受制于一些手工设计。相比之下,局部注意力将每个查询的感受野限制在其相邻像素内,兼具卷积和自注意力的优势,即局部归纳偏置和动态特征选择。然而,当前的局部注意力模块要么使用低效的Im2Col函数,要么依赖难以推广到无CUDA支持设备的特定CUDA内核。在本文中,我们提出了一种新颖的局部注意力模块——Slide Attention,它利用常见的卷积操作来实现高效率、灵活性和通用性。具体而言,我们首先从新的基于行的视角重新解释基于列的Im2Col函数,并使用Depthwise Convolution作为高效替代。在此基础上,我们基于重参数化技术提出了一个形变移位模块,进一步将固定的键/值位置放宽为局部区域内的形变特征。通过这种方式,我们的模块以高效且灵活的方式实现了局部注意力范式。大量实验表明,我们的Slide Attention模块适用于多种先进的视觉Transformer模型,兼容各种硬件设备,并在综合基准上取得了一致提升的性能。代码可在https://github.com/LeapLabTHU/Slide-Transformer获取。

英文摘要:

Self-attention mechanism has been a key factor in the recent progress of Vision Transformer (ViT), which enables adaptive feature extraction from global contexts. However, existing self-attention methods either adopt sparse global attention or window attention to reduce the computation complexity, which may compromise the local feature learning or subject to some handcrafted designs. In contrast, local attention, which restricts the receptive field of each query to its own neighboring pixels, enjoys the benefits of both convolution and self-attention, namely local inductive bias and dynamic feature selection. Nevertheless, current local attention modules either use inefficient Im2Col function or rely on specific CUDA kernels that are hard to generalize to devices without CUDA support. In this paper, we propose a novel local attention module, Slide Attention, which leverages common convolution operations to achieve high efficiency, flexibility and generalizability. Specifically, we first re-interpret the column-based Im2Col function from a new row-based perspective and use Depthwise Convolution as an efficient substitution. On this basis, we propose a deformed shifting module based on the re-parameterization technique, which further relaxes the fixed key/value positions to deformed features in the local region. In this way, our module realizes the local attention paradigm in both efficient and flexible manner. Extensive experiments show that our slide attention module is applicable to a variety of advanced Vision Transformer models and compatible with various hardware devices, and achieves consistently improved performances on comprehensive benchmarks. Code is available at https://github.com/LeapLabTHU/Slide-Transformer.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑