Page 110 - 《软件学报》2021年第8期
P. 110

2392                                   Journal of Software  软件学报 Vol.32, No.8,  August 2021

                 4 (State Key Laboratory of Computer Architecture (Institute of Computing Technology, Chinese Academy of Sciences), Beijing 100190,
                  China)

                 Abstract:    Deep neural network (DNN) quantization is an efficient model compression method, in which parameters and intermediate
                 results are expressed  by  low  bit  width. The  bit width of  data will  directly affect  the memory  footprint, computing  power and energy
                 consumption. Previous researches on model quantization lack effective quantitative analysis, which leads to unpredictable quantization
                 loss of these  methods.  This study proposes  an ultra-low loss quantization (μL2Q) method  for DNN compression, which reveals the
                 internal relationship between quantization bit width and quantization loss, effectively guiding the selection of quantization bit width and
                 reducing quantization loss. First, the original data is mapped to the data with standard normal distribution and then the optimal parameter
                 configuration is sought to reduce the quantization loss under the target bit width. Finally, μL2Q has been encapsulated and integrated into
                 two popular deep  learning training frameworks, including Caffe  and  Keras, to support  the design  and training of  end-to-end  model
                 compression. The experimental results show that compared with the state-of-the-art three clusters of quantization solutions, μL2Q can still
                 guarantee the accuracy and deliver 1.94%, 3.73%, and 8.24% of accuracy improvements under the typical neural networks with the same
                 quantization bit width, respectively. In addition, it is also verified that μL2Q can be competent for more complex computer vision tasks
                 through salient object detection experiments.
                 Key words:   neural  network compression; neural network  quantization; weight distribution;  uniform quantization; extremum of
                          quantizationloss

                    随着深度神经网络(DNN)在多个研究领域取得实质性突破,边缘智能场景下 DNN 模型的应用和部署,吸引
                 了研究人员的广泛关注.为了追求更高的推理精度,近年来,DNN 模型的计算规模变得愈加庞大、网络结构愈加
                                                                                     [3]
                 复杂且不规则     [12] 、参数量巨大  [3−13] ,其运行时需要强大的计算能力支持并且极其耗能 .然而,边缘智能设备的
                 计算资源与存储资源有限,并且对能耗及延迟具有严格的约束.因此,在资源受限的边缘设备上部署庞大而复杂
                 的 DNN 模型极具挑战      [11] .将 DNN 模型进行压缩,可以有效减少模型的复杂度,使 DNN 模型得以应用于边缘智
                 能计算场景.
                    DNN 模型压缩的主要目的是:在确保 DNN 模型推理精度的前提下,消除冗余的模型参数,减少中间结果并
                 降低网络结构的复杂度,从而得到满足精度要求的精简模型.DNN 量化是 DNN 模型压缩的一种重要方法                                 [14] ,它
                 利用低位宽的参数来表示原始的全精度模型,显著降低 DNN 模型的计算复杂度和内存占用,使得 DNN 模型能
                 够直接在资源受限的边缘设备上进行部署.当原始的模型被量化到极低的位宽时,模型压缩效果尤为明显                                    [15−18] .
                 例如,二值神经网络 BNN      [15] 和三值神经网络 TWNs    [16] 可分别将 32 位全精度模型的尺寸压缩 32 倍和 16 倍.
                    但是,现有的 DNN 量化方法存在诸多问题,通常依赖于经验猜测和实验尝试                         [15−17,19] ,缺乏有效的理论支撑.
                 具体表现如下:
                    •   第一,现有量化方法难以在数据位宽和模型精度之间进行有效权衡.通过极少量的比特位表示 DNN 模
                        型,将导致模型精度明显下降而失去应用价值.例如,利用二值量化或三值量化的 DNN 可以获得极高的
                        压缩比,但在实际应用中无法满足精度要求               [15−18,20] ;而保留较多数量的比特位    [19,21] ,虽然能够防止精度
                        显著下降,但量化后的 DNN 模型仍然过于庞大,难以直接部署                  [22,23] .
                    •   第二,启发式的参数选择需要大量的人工尝试,而现有的量化方法在将全精度模型数据转换成低位宽
                        数据之前,需要寻找恰当的参数来限制中间结果数据的表示范围.该步骤通常需要引入缩放参数                                  [18] ,而
                        现有的量化方法在确定缩放参数时,往往是启发式的                  [17,22] .
                    •   第三,对权值数据分布的拟合程度会直接影响量化后的模型精度,而现有量化方法通常会忽视权值数
                        据的分布规律.例如,Dorefa-Net    [17] 和 FP [19] 等工作由于量化后的权值不拟合原始的权值分布,从而导致
                        精度显著下降.尽管 DNN 模型中各层数据的分布规律不同,但均可通过数学变换而近似满足标准正态
                        分布.本文例举了 4 种典型的 DNN 模型的各层的权值数据,如图 1 所示,其数据皆近似服从标准正态分
                        布.量化方法的设计应该充分利用权值数据分布规律,以有效提高 DNN 模型量化后的精度.
                    为了解决上述问题,本文提出一种超低损失的模型量化方法(ultra-low loss quantization,简称μL2Q).该方法
                 在模型量化时充分考虑了原始权值数据的分布规律并进行了定量分析,并在确定缩放参数时有效地减少了人
   105   106   107   108   109   110   111   112   113   114   115