Self-attention has become a defacto choice for capturing global context in various vision applications. However, its quadratic computational complexity with respect to image resolution limits its use in real-time applications, especially for deployment on resource-constrained mobile devices. Although hybrid approaches have been proposed to combine the advantages of convolutions and self-attention for a better speed-accuracy trade-off, the expensive matrix multiplication operations in self-attention remain a bottleneck. In this work, we introduce a novel efficient additive attention mechanism that effectively replaces the quadratic matrix multiplication operations with linear element-wise multiplications. Our design shows that the key-value interaction can be replaced with a linear layer without sacrificing any accuracy. Unlike previous state-of-the-art methods, our efficient formulation of self-attention enables its usage at all stages of the network. Using our proposed efficient additive attention, we build a series of models called "SwiftFormer" which achieves state-of-the-art performance in terms of both accuracy and mobile inference speed. Our small variant achieves 78.5% top-1 ImageNet-1K accuracy with only 0.8 ms latency on iPhone 14, which is more accurate and 2x faster compared to MobileViT-v2. Code: https://github.com/Amshaker/SwiftFormer


翻译:自注意力机制已成为各类视觉应用中捕获全局上下文的事实标准。然而,其计算复杂度随图像分辨率呈二次增长,限制了它在实时应用中的使用,尤其是在资源受限的移动设备部署场景中。尽管已有混合方法试图结合卷积与自注意力的优势以实现速度与精度的更好平衡,但自注意力中昂贵的矩阵乘法运算仍是瓶颈。本文提出一种新型高效加性注意力机制,该机制将二次矩阵乘法运算有效替换为线性逐元素乘法。我们的设计表明,键值交互可通过线性层替代而不损失任何精度。与现有最先进方法不同,我们的高效自注意力公式可应用于网络的所有阶段。基于所提出的高效加性注意力,我们构建了一系列名为"SwiftFormer"的模型,其在精度和移动端推理速度方面均达到最优性能。小型变体在iPhone 14上仅需0.8毫秒延迟即可实现78.5%的ImageNet-1K top-1准确率,与MobileViT-v2相比精度更高且速度快2倍。代码:https://github.com/Amshaker/SwiftFormer

0
下载
关闭预览

相关内容

利用注意力机制来“动态”地生成不同连接的权重,这就是自注意力模型(Self-Attention Model). 注意力机制模仿了生物观察行为的内部过程,即一种将内部经验和外部感觉对齐从而增加部分区域的观察精细度的机制。注意力机制可以快速提取稀疏数据的重要特征,因而被广泛用于自然语言处理任务,特别是机器翻译。而自注意力机制是注意力机制的改进,其减少了对外部信息的依赖,更擅长捕捉数据或特征的内部相关性
用于识别任务的视觉 Transformer 综述
专知会员服务
75+阅读 · 2023年2月25日
【2022新书】高效深度学习,Efficient Deep Learning Book
专知会员服务
128+阅读 · 2022年4月21日
专知会员服务
30+阅读 · 2021年7月30日
【ICLR-2020】网络反卷积,NETWORK DECONVOLUTION
专知会员服务
39+阅读 · 2020年2月21日
【SIGGRAPH2019】TensorFlow 2.0深度学习计算机图形学应用
专知会员服务
41+阅读 · 2019年10月9日
Deep Compression/Acceleration:模型压缩加速论文汇总
极市平台
14+阅读 · 2019年5月15日
重磅!MobileNetV3 来了!
极市平台
18+阅读 · 2019年5月8日
TorchSeg:基于pytorch的语义分割算法开源了
极市平台
20+阅读 · 2019年1月28日
【跟踪Tracking】15篇论文+代码 | 中秋快乐~
专知
18+阅读 · 2018年9月24日
推荐中的序列化建模:Session-based neural recommendation
机器学习研究会
18+阅读 · 2017年11月5日
【推荐】YOLO实时目标检测(6fps)
机器学习研究会
20+阅读 · 2017年11月5日
【推荐】RNN/LSTM时序预测
机器学习研究会
25+阅读 · 2017年9月8日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
3+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2010年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
1+阅读 · 2008年12月31日
Arxiv
17+阅读 · 2022年2月23日
Arxiv
17+阅读 · 2021年3月29日
Arxiv
20+阅读 · 2021年2月28日
VIP会员
最新内容
军事欺骗:供作战战术指挥官使用的工具
专知会员服务
0+阅读 · 22分钟前
综述 | 世界动作模型:少做梦,多行动
专知会员服务
4+阅读 · 6月23日
美以伊冲突:无人机与人工智能的运用
专知会员服务
7+阅读 · 6月23日
《特种部队在透明战场中的生存力》最新报告
专知会员服务
4+阅读 · 6月23日
综述 | 3D场景图:开放挑战与未来方向
专知会员服务
8+阅读 · 6月22日
21世纪的无人机战争
专知会员服务
4+阅读 · 6月22日
相关论文
相关基金
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
3+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2010年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
1+阅读 · 2008年12月31日
Top
微信扫码咨询专知VIP会员