As the core building block of vision transformers, attention is a powerful tool to capture long-range dependency. However, such power comes at a cost: it incurs a huge computation burden and heavy memory footprint as pairwise token interaction across all spatial locations is computed. A series of works attempt to alleviate this problem by introducing handcrafted and content-agnostic sparsity into attention, such as restricting the attention operation to be inside local windows, axial stripes, or dilated windows. In contrast to these approaches, we propose a novel dynamic sparse attention via bi-level routing to enable a more flexible allocation of computations with content awareness. Specifically, for a query, irrelevant key-value pairs are first filtered out at a coarse region level, and then fine-grained token-to-token attention is applied in the union of remaining candidate regions (\ie, routed regions). We provide a simple yet effective implementation of the proposed bi-level routing attention, which utilizes the sparsity to save both computation and memory while involving only GPU-friendly dense matrix multiplications. Built with the proposed bi-level routing attention, a new general vision transformer, named BiFormer, is then presented. As BiFormer attends to a small subset of relevant tokens in a \textbf{query adaptive} manner without distraction from other irrelevant ones, it enjoys both good performance and high computational efficiency, especially in dense prediction tasks. Empirical results across several computer vision tasks such as image classification, object detection, and semantic segmentation verify the effectiveness of our design. Code is available at \url{https://github.com/rayleizhu/BiFormer}.


翻译:作为视觉Transformer的核心构建模块,注意力机制是捕获长程依赖关系的强大工具。然而,这种能力伴随着代价:由于需要计算所有空间位置上的成对令牌交互,导致巨大的计算负担和沉重的内存占用。一系列研究尝试通过在手工艺设计的、与内容无关的稀疏性注意力机制(例如将注意力操作限制在局部窗口、轴向条纹或膨胀窗口内)来缓解这一问题。与这些方法不同,我们提出一种基于双层路由的新型动态稀疏注意力机制,以实现更具灵活性的内容感知计算分配。具体而言,对于某个查询,首先在粗粒度区域级别过滤掉无关的键值对,然后在剩余候选区域(即路由区域)的并集中应用细粒度的令牌到令牌注意力。我们为所提出的双层路由注意力提供了简单有效的实现,它利用稀疏性节省计算与内存,同时仅涉及GPU友好的密集矩阵乘法。基于所提出的双层路由注意力,我们构建了名为BiFormer的新型通用视觉Transformer。由于BiFormer以查询自适应方式关注相关令牌的小子集,且不受无关令牌干扰,它在密集预测任务中兼具优异性能与高计算效率。在图像分类、目标检测和语义分割等多项计算机视觉任务上的实验结果验证了我们设计的有效性。代码见:\url{https://github.com/rayleizhu/BiFormer}。

3
下载
关闭预览

相关内容

【CVPR2023】BiFormer:基于双层路由注意力的视觉Transformer
专知会员服务
35+阅读 · 2023年3月20日
抢鲜看!13篇CVPR2020论文链接/开源代码/解读
专知会员服务
50+阅读 · 2020年2月26日
Transformer文本分类代码
专知会员服务
118+阅读 · 2020年2月3日
【SIGGRAPH2019】TensorFlow 2.0深度学习计算机图形学应用
专知会员服务
41+阅读 · 2019年10月9日
Hierarchically Structured Meta-learning
CreateAMind
27+阅读 · 2019年5月22日
Transferring Knowledge across Learning Processes
CreateAMind
29+阅读 · 2019年5月18日
强化学习的Unsupervised Meta-Learning
CreateAMind
18+阅读 · 2019年1月7日
无监督元学习表示学习
CreateAMind
27+阅读 · 2019年1月4日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
18+阅读 · 2018年12月24日
Capsule Networks解析
机器学习研究会
11+阅读 · 2017年11月12日
国家自然科学基金
1+阅读 · 2016年12月31日
国家自然科学基金
1+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2008年12月31日
Arxiv
17+阅读 · 2022年2月23日
Arxiv
17+阅读 · 2021年3月29日
On Feature Normalization and Data Augmentation
Arxiv
15+阅读 · 2020年2月25日
Arxiv
19+阅读 · 2018年3月28日
VIP会员
最新内容
对抗环境下超视距目标打击的情报支援
专知会员服务
3+阅读 · 今天14:49
《无人机对海面作战影响评估》
专知会员服务
11+阅读 · 7月21日
印度精确打击与指挥架构的断层
专知会员服务
6+阅读 · 7月20日
美空军AI完成F-16战斗机自主空战历史性试飞
专知会员服务
6+阅读 · 7月20日
相关基金
国家自然科学基金
1+阅读 · 2016年12月31日
国家自然科学基金
1+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2008年12月31日
Top
微信扫码咨询专知VIP会员