Quantization is one of the most effective methods to compress neural networks, which has achieved great success on convolutional neural networks (CNNs). Recently, vision transformers have demonstrated great potential in computer vision. However, previous post-training quantization methods performed not well on vision transformer, resulting in more than 1% accuracy drop even in 8-bit quantization. Therefore, we analyze the problems of quantization on vision transformers. We observe the distributions of activation values after softmax and GELU functions are quite different from the Gaussian distribution. We also observe that common quantization metrics, such as MSE and cosine distance, are inaccurate to determine the optimal scaling factor. In this paper, we propose the twin uniform quantization method to reduce the quantization error on these activation values. And we propose to use a Hessian guided metric to evaluate different scaling factors, which improves the accuracy of calibration with a small cost. To enable the fast quantization of vision transformers, we develop an efficient framework, PTQ4ViT. Experiments show the quantized vision transformers achieve near-lossless prediction accuracy (less than 0.5% drop at 8-bit quantization) on the ImageNet classification task.


翻译:量化是压缩神经网络的最有效方法之一,它在进化神经网络(CNNs)上取得了巨大成功。最近,视觉变异器在计算机视觉上表现出巨大的潜力。然而,以前的训练后量化方法在视觉变异器上表现不佳,导致即使在8位位数的变异器上也出现超过1%的精度下降。因此,我们分析了视觉变异器的量化问题。我们观察到软式成像和GELU功能后激活值的分布与高斯分布大相径庭。我们还注意到,共同的量化指标,如MSE和Comesine距离,在确定最佳缩放系数方面表现不准确。在本文件中,我们建议采用双一致的量化方法来减少这些振动值上的微误差。我们提议使用赫斯指南度来评估不同的缩放系数,这些系数能提高校准的精确度,而成本小。为了能够快速量化愿景变异器的配置,我们还开发了一个高效框架,即MSE和CEV4T。实验显示,在近低位图像变异的图像等级上,可实现近位的图像变异性预测。

0
下载
关闭预览

相关内容

【Tutorial】计算机视觉中的Transformer,98页ppt
专知会员服务
139+阅读 · 2021年10月25日
【CVPR2021】用Transformers无监督预训练进行目标检测
专知会员服务
55+阅读 · 2021年3月3日
最新《Transformers模型》教程,64页ppt
专知会员服务
274+阅读 · 2020年11月26日
Transformer模型-深度学习自然语言处理,17页ppt
专知会员服务
97+阅读 · 2020年8月30日
【Google】平滑对抗训练,Smooth Adversarial Training
专知会员服务
46+阅读 · 2020年7月4日
专知会员服务
44+阅读 · 2020年3月6日
BERT 瘦身之路:Distillation,Quantization,Pruning
Hierarchically Structured Meta-learning
CreateAMind
23+阅读 · 2019年5月22日
逆强化学习-学习人先验的动机
CreateAMind
15+阅读 · 2019年1月18日
强化学习的Unsupervised Meta-Learning
CreateAMind
17+阅读 · 2019年1月7日
Unsupervised Learning via Meta-Learning
CreateAMind
41+阅读 · 2019年1月3日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
15+阅读 · 2018年12月24日
已删除
将门创投
8+阅读 · 2018年10月31日
Auto-Encoding GAN
CreateAMind
7+阅读 · 2017年8月4日
Arxiv
0+阅读 · 2022年1月26日
Arxiv
0+阅读 · 2022年1月26日
Arxiv
19+阅读 · 2021年4月8日
Universal Transformers
Arxiv
5+阅读 · 2019年3月5日
The Evolved Transformer
Arxiv
5+阅读 · 2019年1月30日
VIP会员
相关VIP内容
相关资讯
BERT 瘦身之路:Distillation,Quantization,Pruning
Hierarchically Structured Meta-learning
CreateAMind
23+阅读 · 2019年5月22日
逆强化学习-学习人先验的动机
CreateAMind
15+阅读 · 2019年1月18日
强化学习的Unsupervised Meta-Learning
CreateAMind
17+阅读 · 2019年1月7日
Unsupervised Learning via Meta-Learning
CreateAMind
41+阅读 · 2019年1月3日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
15+阅读 · 2018年12月24日
已删除
将门创投
8+阅读 · 2018年10月31日
Auto-Encoding GAN
CreateAMind
7+阅读 · 2017年8月4日
相关论文
Arxiv
0+阅读 · 2022年1月26日
Arxiv
0+阅读 · 2022年1月26日
Arxiv
19+阅读 · 2021年4月8日
Universal Transformers
Arxiv
5+阅读 · 2019年3月5日
The Evolved Transformer
Arxiv
5+阅读 · 2019年1月30日
Top
微信扫码咨询专知VIP会员