阅读笔记:Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference
论文pdf:https://arxiv.org/abs/1712.05877
github:https://github.com/google/gemmlowp
1、论文中提出的问题即所解决的问题
尽管已经有很多量化方法,但在做到高准确率的同时还能权衡推理延时的非常欠缺。
-
以前的方法没有在合理基准的网络架构上评估,之前都是在过参数化严重的网络例如AlexNet等等。
-
许多方法在实际硬件上并不能提升效率。(The rising popularity of intelligent mobile devices and the daunting computational cost of deep learning-based models call for efficient and accurate on-device inference schemes)这句话没理解,什么叫操作数比较宽的时候,乘法消失是啥意思。
2、创新点
-
提出一种量化方案,只有整数计算,既量化权重也量化激活值。
-
提出了一个量化推理框架,可以高效地部署到只有整数计算的硬件设备上,例如高通Hexagon。
-
提出了一个量化训练的方案,基于最小化acc的损失。
3、重要的相关论文
灵感的来源:
-
S. Gupta, A. Agrawal, K. Gopalakrishnan, and P. Narayanan. Deep learning with limited numerical precision. In Proceedings of the 32nd International Conference on Machine Learning (ICML-15), pages 1737–1746, 2015.
-
V. Vanhoucke, A. Senior, and M. Z. Mao. Improving the speed of neural networks on cpus. In Proc. Deep Learning and Unsupervised Feature Learning NIPS Workshop, volume 1, page 4, 2011
4、具体实现
4.1 量化推理
4.1.1量化方案
r = S ( q − Z ) (1) r = S(q-Z) \tag{1} r=S(q−Z)(1)
bias vectors是量化到32bit的整型值。S是浮点值,Z是整型值,和q同数据类型,是实数0对应的量化值。
4.1.2只包含整形运算的矩阵乘
将两个矩阵的乘法表示为 r 3 = r 1 r 2 r_3=r_1r_2 r3=r1r2(忽略了bias,有BN层的网络conv的bias一般都是false),则可以将矩阵乘表示成如下公式:
S 3 ( q 3 ( i , k ) − Z 3 ) = ∑ j = 1 N S 1 ( q 1 ( i , j ) − Z 1 ) S 2 ( q 2 ( j , k ) − Z 2 ) (2) S_3(q_3^{(i,k)} - Z_3) = \sum_{j=1}^N S_1(q_1^{(i,j)} - Z_1)S_2(q_2^{(j,k)} - Z_2) \tag{2} S3(q3(i,k)−Z3)=j=1∑NS1(q1(i,j)−Z1)S2(q2(j,k)−Z2)(2)
进一步整理为:
q 3 ( i , k ) = Z 3 + M ∑ j = 1 N ( q 1 ( i , j ) − Z 1 ) ( q 2 ( j , k ) − Z 2 ) (3) q_3^{(i,k)} = Z_3 + M\sum_{j=1}^N (q_1^{(i,j)} - Z_1)(q_2^{(j,k)} - Z_2)\tag{3} q

最低0.47元/天 解锁文章

363

被折叠的 条评论
为什么被折叠?



