arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2303.13755cs.CVcs.AIcs.LG
收藏

Sparsifiner:学习稀疏实例相关注意力以实现高效的视觉Transformer

Sparsifiner: Learning Sparse Instance-Dependent Attention for Efficient Vision Transformers

University of Toronto(多伦多大学);Modiface, Inc.(Modiface公司);University of Guelph(圭尔夫大学);Vector Institute(向量研究所)

Cong Wei, Brendan Duke, Ruowei Jiang, Parham Aarabi, Graham W. Taylor, Florian Shkurti

摘要:

与卷积神经网络(CNN)相比,视觉Transformer(ViT)在性能方面表现出了竞争优势,尽管它们通常具有很高的计算成本。为此,以前的方法探索不同的注意模式,通过限制固定数量的空间附近的令牌,以加速ViT的多头自注意(MHSA)操作。然而,这种结构化的注意力模式限制了标记到标记的连接到它们的空间相关性,这忽略了从完整的注意力掩码中学习到的语义连接。在这项工作中,我们提出了一种新的方法来学习依赖于实例的注意模式,通过设计一个轻量级的连接预测模块来估计每对令牌的连接得分。直觉上,如果特征被认为在空间上或语义上相关,则两个标记具有高连接性分数。由于每个令牌只涉及少量其他令牌,因此二值化连接掩码通常本质上非常稀疏,因此提供了通过稀疏计算加速网络的机会。配备了学习的非结构化注意力模式,稀疏注意力ViT(Sparsifiner)与令牌稀疏性相比,在FLOP和ImageNet上的top-1准确性之间产生了卓越的Pareto最优权衡。我们的方法减少了48%到69%的MHSA的FLOPs,而准确度下降在0.4%以内。我们还表明,将注意力和令牌稀疏性相结合,可以将ViT FLOPs降低60%以上。

英文摘要:

Vision Transformers (ViT) have shown their competitive advantages performance-wise compared to convolutional neural networks (CNNs) though they often come with high computational costs. To this end, previous methods explore different attention patterns by limiting a fixed number of spatially nearby tokens to accelerate the ViT's multi-head self-attention (MHSA) operations. However, such structured attention patterns limit the token-to-token connections to their spatial relevance, which disregards learned semantic connections from a full attention mask. In this work, we propose a novel approach to learn instance-dependent attention patterns, by devising a lightweight connectivity predictor module to estimate the connectivity score of each pair of tokens. Intuitively, two tokens have high connectivity scores if the features are considered relevant either spatially or semantically. As each token only attends to a small number of other tokens, the binarized connectivity masks are often very sparse by nature and therefore provide the opportunity to accelerate the network via sparse computations. Equipped with the learned unstructured attention pattern, sparse attention ViT (Sparsifiner) produces a superior Pareto-optimal trade-off between FLOPs and top-1 accuracy on ImageNet compared to token sparsity. Our method reduces 48% to 69% FLOPs of MHSA while the accuracy drop is within 0.4%. We also show that combining attention and token sparsity reduces ViT FLOPs by over 60%.

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

↑