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

视觉Transformer的后培训Quantization

Post-Training Quantization for Vision Transformer

Peking University(北京大学);Huawei Technologies(华为技术有限公司);Peng Cheng Laboratory(鹏城实验室)

Zhenhua Liu, Yunhe Wang, Kai Han, Siwei Ma, Wen Gao

摘要:

最近,Transformer在各种计算机视觉应用中取得了显著的性能。与主流的卷积神经网络相比,视觉Transformer通常具有用于提取强大特征表示的复杂架构,这在移动设备上更难开发。在本文中,我们提出了一个有效的后训练量化算法,以减少内存存储和计算成本的视觉Transformer。基本上,量化任务可以被视为分别为权重和输入找到最佳低位量化间隔。为了保持注意力机制的功能,我们在传统的量化目标中引入了排名损失,旨在保持量化后自注意力结果的相对顺序。此外,我们深入分析了不同层的量化损失和特征多样性之间的关系,并探索了一种混合精度的量化方案,利用每个注意力图和输出特征的核范数。在几个基准模型和数据集上验证了该方法的有效性,其性能优于最先进的后训练量化算法。例如,我们可以在ImageNet数据集上使用DeiT-B模型获得81.29\%的top-1准确率,约为8位量化。

英文摘要:

Recently, transformer has achieved remarkable performance on a variety of computer vision applications. Compared with mainstream convolutional neural networks, vision transformers are often of sophisticated architectures for extracting powerful feature representations, which are more difficult to be developed on mobile devices. In this paper, we present an effective post-training quantization algorithm for reducing the memory storage and computational costs of vision transformers. Basically, the quantization task can be regarded as finding the optimal low-bit quantization intervals for weights and inputs, respectively. To preserve the functionality of the attention mechanism, we introduce a ranking loss into the conventional quantization objective that aims to keep the relative order of the self-attention results after quantization. Moreover, we thoroughly analyze the relationship between quantization loss of different layers and the feature diversity, and explore a mixed-precision quantization scheme by exploiting the nuclear norm of each attention map and output feature. The effectiveness of the proposed method is verified on several benchmark models and datasets, which outperforms the state-of-the-art post-training quantization algorithms. For instance, we can obtain an 81.29\% top-1 accuracy using DeiT-B model on ImageNet dataset with about 8-bit quantization.

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

↑