[论文解读] Fixed-point Quantization of Convolutional Neural Networks for Quantized Inference on Embedded Platforms
本文提出 OptSearchCNN,一种后训练、逐层的定点量化方法,通过联合优化网络中权重、偏置和激活的位宽与小数偏移,最小化精度损失。通过考虑跨参数量化误差,该方法在内存减少 53%、乘法计算成本降低 77.5% 的前提下,实现小于 1% 的精度损失,相较 8 位均匀量化。
Convolutional Neural Networks (CNNs) have proven to be a powerful state-of-the-art method for image classification tasks. One drawback however is the high computational complexity and high memory consumption of CNNs which makes them unfeasible for execution on embedded platforms which are constrained on physical resources needed to support CNNs. Quantization has often been used to efficiently optimize CNNs for memory and computational complexity at the cost of a loss of prediction accuracy. We therefore propose a method to optimally quantize the weights, biases and activations of each layer of a pre-trained CNN while controlling the loss in inference accuracy to enable quantized inference. We quantize the 32-bit floating-point precision parameters to low bitwidth fixed-point representations thereby finding optimal bitwidths and fractional offsets for parameters of each layer of a given CNN. We quantize parameters of a CNN post-training without re-training it. Our method is designed to quantize parameters of a CNN taking into account how other parameters are quantized because ignoring quantization errors due to other quantized parameters leads to a low precision CNN with accuracy losses of up to 50% which is far beyond what is acceptable. Our final method therefore gives a low precision CNN with accuracy losses of less than 1%. As compared to a method used by commercial tools that quantize all parameters to 8-bits, our approach provides quantized CNN with averages of 53% lower memory consumption and 77.5% lower cost of executing multiplications for the two CNNs trained on the four datasets that we tested our work on. We find that layer-wise quantization of parameters significantly helps in this process.
研究动机与目标
- 在资源受限的嵌入式平台上实现 CNN 的高效量化推理,且精度损失最小化。
- 解决均匀 8 位量化方法的局限性,该方法常因未考虑量化误差而导致显著精度下降。
- 开发一种后训练量化方法,逐层优化位宽与小数偏移,同时考虑参数间的量化影响。
- 在不牺牲模型精度的前提下,降低内存与计算成本,尤其是乘法运算的开销。
- 提供一种可推广的方法,适用于多种 CNN 架构及图像分类以外的任务。
提出的方法
- 该方法使用定点量化函数,将 32 位浮点参数映射为可配置小数偏移的低比特定点表示。
- 引入一种依赖感知的搜索策略(依赖优化搜索),在优化过程中考虑其他参数带来的量化误差。
- OptSearchCNN 采用逐层、顺序的搜索方式,对各层的位宽与小数偏移进行优化,以最小化每一步的精度损失。
- 该算法评估量化对推理精度的影响,并选择满足用户定义精度阈值的最优配置。
- 比较两种策略:独立(忽略跨参数误差)与依赖(考虑误差),优先选择后者以获得更优精度。
- 该方法在推理阶段无需微调,适用于任何嵌入式平台,且对硬件要求极低。
实验结果
研究问题
- RQ1考虑参数间量化误差后,对量化 CNN 最终精度的影响如何?
- RQ2与均匀 8 位量化相比,逐层自适应位宽量化是否能在内存与计算成本上实现更优表现?
- RQ3为每层的权重、偏置和激活找到位宽与小数偏移的最优平衡,以最小化精度损失?
- RQ4为何量化顺序在实现最小精度退化中至关重要?
- RQ5该方法找到的最优位宽在不同数据集和网络架构之间是否具有可推广性?
主要发现
- 考虑其他参数量化误差的依赖优化搜索策略,将精度损失降至 1% 以下;而忽略误差时,精度损失超过 50%。
- 与均匀 8 位量化相比,该方法在两个 CNN 和四个数据集上,平均实现 53% 的内存降低和 77.5% 的乘法计算成本降低。
- 逐层自适应位宽量化显著提升了效率与精度,优于均匀量化。
- 该方法成功实现了无需微调的后训练量化,在嵌入式平台上保持了高推理精度。
- 量化激活的精度损失高于量化权重,表明激活对量化更敏感。
- 最优位宽在各层间并非均匀分布,表明不同层对精度的需求不同,需采用差异化精度水平以实现最优性能。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。