[论文解读] QuadTree Attention for Vision Transformers
QuadTree Attention 将 vision-transformer 的计算复杂度从二次方降低到线性,通过构建令牌金字塔并执行自粗到细的注意力,在特征匹配、立体、图像分类和对象检测等任务上以更低的计算量实现最新性能。
Transformers have been successful in many vision tasks, thanks to their capability of capturing long-range dependency. However, their quadratic computational complexity poses a major obstacle for applying them to vision tasks requiring dense predictions, such as object detection, feature matching, stereo, etc. We introduce QuadTree Attention, which reduces the computational complexity from quadratic to linear. Our quadtree transformer builds token pyramids and computes attention in a coarse-to-fine manner. At each level, the top K patches with the highest attention scores are selected, such that at the next level, attention is only evaluated within the relevant regions corresponding to these top K patches. We demonstrate that quadtree attention achieves state-of-the-art performance in various vision tasks, e.g. with 4.0% improvement in feature matching on ScanNet, about 50% flops reduction in stereo matching, 0.4-1.5% improvement in top-1 accuracy on ImageNet classification, 1.2-1.8% improvement on COCO object detection, and 0.7-2.4% improvement on semantic segmentation over previous state-of-the-art transformers. The codes are available at https://github.com/Tangshitao/QuadtreeAttention.
研究动机与目标
- Motivate and address the quadratic computational cost of standard vision transformers for dense prediction tasks.
- Propose a coarse-to-fine quadtree attention mechanism to skip irrelevant regions and reduce computations.
- Enable both cross-attention and self-attention within a single efficient framework.
- Demonstrate state-of-the-art performance gains across feature matching, stereo, image classification, and object detection.
提出的方法
- Construct token pyramids by downsampling queries, keys, and values to L levels.
- At each level, select the top K patches with highest attention scores to restrict fine-level attention to corresponding regions.
- Aggregate messages across levels via two architectures: QuadTree-A (sum of level-wise messages) and QuadTree-B (learned-weighted combination of level-wise messages).
- Compute attention scores recursively with s_ij^l = s_ij^{l-1} t_ij^l and t_ij^l from 2x2 local patches, enabling linear complexity in N.
- Incorporate multiscale position encoding (LePE) using unshared depth-wise convolutions to preserve positional information across levels.]
- 将查询、键、值下采样至 L 个层级来构建令牌金字塔。
- 在每个层级,选择注意力分数最高的前 K 个补丁,以将细粒度注意力限制在相应区域。
- 通过两种架构在层级之间聚合信息:QuadTree-A(层级消息之和)和 QuadTree-B(层级消息的学习加权组合)。
- 以递归方式计算注意力分数,s_ij^l = s_ij^{l-1} t_ij^l,且 t_ij^l 来自 2x2 局部补丁,使复杂度在 N 线性。
- 结合多尺度位置信息编码(LePE),使用非共享的逐通道卷积以在各层之间保持位置信息。
实验结果
研究问题
- RQ1Can QuadTree Attention reduce the quadratic complexity of vision transformers to linear without sacrificing performance on dense vision tasks?
- RQ2Does the coarse-to-fine selective attention approach retain long-range dependencies while maintaining efficiency in cross- and self-attention scenarios?
- RQ3How do the two aggregation schemes (QuadTree-A and QuadTree-B) compare in terms of accuracy and efficiency?
- RQ4Can QuadTree Attention achieve state-of-the-art results across feature matching, stereo, classification, and detection tasks compared to existing efficient transformers?
主要发现
- QuadTree Attention achieves comparable or superior performance to linear transformers with significantly reduced FLOPs and memory in feature matching and stereo.
- On feature matching (ScanNet), QuadTree-B improves AUC@20 by 1.8–4.0 points over linear and SR attention variants depending on setup.
- In stereo, QuadTree-B attains similar EPE to vanilla STTR while using about 52% FLOPs and 63% memory.
- For ImageNet classification, QuadTree-B-b2 reaches 84.0% top-1, outperforming PVTv2 and Swin Transformer baselines.
- In COCO object detection, QuadTree Attention + RetinaNet achieves 47.9 AP, about 1.8 higher than PVTv2 with fewer FLOPs.
- Semantic segmentation shows improvements of 0.7–2.4% over prior transformers.
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。