WO2021258752A1 - 一种神经网络的4比特量化方法及系统 - Google Patents

一种神经网络的4比特量化方法及系统 Download PDF

Info

Publication number
WO2021258752A1
WO2021258752A1 PCT/CN2021/076982 CN2021076982W WO2021258752A1 WO 2021258752 A1 WO2021258752 A1 WO 2021258752A1 CN 2021076982 W CN2021076982 W CN 2021076982W WO 2021258752 A1 WO2021258752 A1 WO 2021258752A1
Authority
WO
WIPO (PCT)
Prior art keywords
quantization
neural network
activation
satrelu
pseudo
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2021/076982
Other languages
English (en)
French (fr)
Inventor
王曦辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Wave Intelligent Technology Co Ltd
Original Assignee
Suzhou Wave Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Wave Intelligent Technology Co Ltd filed Critical Suzhou Wave Intelligent Technology Co Ltd
Publication of WO2021258752A1 publication Critical patent/WO2021258752A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/082Learning methods modifying the architecture, e.g. adding, deleting or silencing nodes or connections
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent

Definitions

  • This application relates to the technical field of neural network model compression, in particular to a neural network 4-bit quantization method and system.
  • the Neural Network model In the neural network, the Neural Network model generally takes up a lot of disk space. For example, the model file of AlexNet exceeds 200MB (MByte, megabyte). The model contains millions of parameters, and most of the disk space is used to store model parameters. Because the model parameters are of floating-point type, it is difficult for ordinary compression algorithms to compress their space. Therefore, the introduction of model quantization to compress the original network by reducing the number of bits required to represent each weight can greatly improve the operating speed of the network. Therefore, how to quantify the neural network is an important technical problem.
  • the mainstream method of neural network quantization is 8-bit quantization, and most training and inference frameworks support 8-bit quantization.
  • 4-bit quantization can continue to compress the volume of the model by a factor of 1 on the 8-bit basis, and the running speed can be increased by 50%. Therefore, 4-bit quantization has gradually attracted people's attention.
  • the current 4-bit quantization algorithm usually trains a network from scratch until the entire network is trained. Large data sets such as imagenet generally require training for more than 100 cycles to complete the training. And the non-linear quantization method is used to improve the accuracy of the model.
  • This application provides a neural network 4-bit quantization method and system to solve the problem of low quantization efficiency of neural network quantization methods in the prior art.
  • a 4-bit quantization method of neural network includes:
  • the pre-inference processing process includes: constant folding, secondary quantization, and activation equivalent transformation;
  • the method of calculating the initial value of each saturated activation layer satRelu includes:
  • the activation value at the 99.999% point in the histogram is selected as the initial value of the parameter max in the saturated activation layer satRelu, where satRelu is defined as:
  • the gradient of satRelu to the parameter max is:
  • the gradient of satRelu to the input x is max is the maximum value of the saturated active layer satRelu.
  • the parameter max is compressed using the L2 regularization method.
  • the retraining period is less than or equal to 10, and the value of the parameter max is less than or equal to 1.
  • adding a pseudo-quantization node to the neural network and using the initial value of satRelu to retrain the neural network to obtain the pseudo-quantization model includes:
  • the through estimator is used to calculate the gradient in the back propagation process.
  • a neural network 4-bit quantization system includes:
  • the loading module is used to load the pre-trained model of the neural network
  • the statistics module is used to count the initial value of each saturated activation layer satRelu in the pre-training model
  • the retraining module is used to add a pseudo-quantization node to the neural network, and use the initial value of satRelu to retrain the neural network to obtain a pseudo-quantization model;
  • a judging module for judging whether the accuracy of the pseudo-quantization model converges to a set accuracy
  • the conversion module is used to perform pre-inference processing on the pseudo-quantization model when the accuracy of the pseudo-quantization model converges to the set accuracy, and convert it into a 4-bit inference model that can be used for inference operations, the pre-inference processing
  • the process includes: constant folding, secondary quantization, and activation of equivalent transformations.
  • the statistics module includes:
  • the replacement unit is used to replace all activation layers relu in the neural network with saturated activation layers satRelu;
  • the activation value obtaining unit is used to obtain the activation value of each saturated activation layer satRelu according to the obtained command;
  • a statistical unit configured to use a histogram to calculate distribution data according to the activation value
  • the initial value selection unit is used to select the activation value at the 99.999% point in the histogram as the initial value of the parameter max in the saturated activation layer satRelu, where satRelu is defined as:
  • the gradient of satRelu to the parameter max is:
  • the gradient of satRelu to the input x is max is the maximum value of the saturated active layer satRelu.
  • the retraining module includes:
  • the pseudo-quantization layer insertion unit is used to insert the weight pseudo-quantization layer before the weight layer of the neural network, and insert the activation pseudo-quantization layer before the activation layer;
  • the pre-inference processing module includes:
  • the calculation formula of the merged new convolution is:
  • the secondary quantization unit is used to perform secondary quantization on the weight, and obtain the quantization scale coefficient scale of the secondary quantization weight;
  • This application provides a 4-bit quantization method for neural networks.
  • the quantization method first loads the pre-training model of the neural network, calculates the initial value of each satRelu layer in the pre-training model, adds pseudo-quantization nodes to the neural network, and uses satRelu Retrain the neural network with the initial value of, obtain the pseudo-quantized model through several cycles of re-training, and use the inference method to convert the pseudo-quantized model into a 4-bit inference model, and use the inference algorithm to complete all 4-bit inference before inference
  • the process is beneficial to improve the calculation speed, and ensures that the final inference model can be directly applied to a 4-bit GPU, and supports 4-bit GPU operations, which is beneficial to improving the practicability of the present invention.
  • This method uses pseudo-quantization during retraining.
  • the corresponding pseudo-quantization layer before the weight layer and activation layer, it is used to simulate the influence of model quantization on the entire neural network, and the model can learn and adapt through training.
  • the influence on the neural network can greatly improve the accuracy of the quantization model, and the accuracy loss of the acquired model can be controlled within 1%, ensuring that the 4-bit quantization result meets the accuracy requirements.
  • the retraining period in this embodiment is 10, that is, the neural network is retrained 10 times, which greatly saves training time, can effectively improve the training efficiency on the basis of ensuring accuracy, and further improves the 4-bit quantization efficiency of the neural network.
  • the neural network is retrained, and linear pseudo-quantization is used for the weight layer and the activation layer, and the calculation speed is increased on the basis of ensuring the training accuracy, thereby effectively improving the quantization efficiency of the neural network.
  • the application also provides a 4-bit quantization system of neural network.
  • the system mainly includes: loading module, statistics module, retraining module, judgment module and conversion module.
  • loading module Through the loading module and the retraining module, it is possible to load a pre-training model through retraining, and perform several cycles of retraining on it to obtain the pseudo-quantization model.
  • judgment module determines that the accuracy of the pseudo-quantization model converges to the set accuracy
  • Start the conversion module to perform inference pre-processing on the pseudo-quantization model and convert it into a 4-bit inference model that can be used for inference operations.
  • This embodiment uses a small number of retraining times, usually 10 cycles, which can effectively save training time, thereby greatly improving the quantization efficiency of the neural network.
  • using the pre-inference processing module to process the pseudo-quantization model in the inference state can complete the full 4-bit inference before inference, which is beneficial to further increase the calculation speed and thereby improve the quantization efficiency.
  • FIG. 1 is a schematic flowchart of a neural network 4-bit quantization method provided by an embodiment of this application;
  • Fig. 2 is a schematic structural diagram of a neural network 4-bit quantization system provided by an embodiment of the application.
  • FIG. 1 is a schematic flowchart of a neural network 4-bit quantization method provided by an embodiment of the application. It can be seen from FIG. 1 that the 4-bit quantization method of the neural network in this embodiment mainly includes the following processes:
  • step S2 further includes:
  • S24 Select the activation value at the 99.999% point in the histogram as the initial value of the parameter max in the saturated activation layer satRelu.
  • satRelu is defined as:
  • the pre-training model of the neural network is first loaded, which can be implemented in the form of running a network script.
  • the activation value distribution of each layer is counted.
  • 4096 sampling points can be used to calculate the histogram distribution, and the activation value at 99.999% of the points in the histogram distribution can be selected as the only one in satRelu
  • the initial value of the parameter max is used for subsequent iterative training.
  • the lower limit of satRelu is 0, and the lower limit of satRelu is max, that is, the maximum value of satRelu is max.
  • max is a variable, which gradually becomes smaller during the neural network training process, and max is required here. The initial value of.
  • satRelu The definition of satRelu is as follows:
  • max is the initial value of each layer calculated by the histogram.
  • the gradient of satRelu to the parameter max is: The gradient for input x is
  • L2 regularization is used to compress it, which can effectively reduce the quantization error and increase the network accuracy.
  • the retraining period is less than or equal to 10, and the value of the parameter max is less than or equal to 1, wherein the preferred value is: the retraining period is 10, and the parameter max is 1.
  • the value setting of the parameter max in this embodiment can ensure that the output of each layer is appropriate, which is beneficial to improve the accuracy of the network. In the training process, it is necessary to observe the max value and adopt appropriate regularization parameters to ensure that the max value is around 1 when the network converges.
  • step S3 is performed: adding a pseudo-quantization node to the neural network, and using the initial value of satRelu to retrain the neural network to obtain a pseudo-quantization model.
  • a pseudo-quantization node is added to the neural network, specifically: adding a pseudo-quantization node to the input and weight of the convolution of the neural network, and the input and weight of the fully connected neural network.
  • the entire neural network is trained using pseudo-quantization, that is, in a conventional neural network, a pseudo-quantization layer is inserted before the weight layer and the activation layer, and the weight pseudo-quantization layer and the activation pseudo-quantization layer are used. It can simulate the impact of model quantization on the entire neural network, and through training, the model can learn and adapt to this impact, thereby effectively improving the accuracy of the most quantified model.
  • w is the weight value
  • n takes the value 4
  • scale factor scale is:
  • this embodiment after retraining the neural network on the weight pseudo-quantization layer, the pseudo-quantization model is obtained, and the weight value in the pseudo-quantization model changes due to the training.
  • this embodiment is neural network 4-bit quantization, and the quantized value range is -8 to 7. Therefore, the upper limit of clip is 7 and the lower limit is -8.
  • the round function is used to round the input, and the scale is The value adopts the way that each output channel shares a scale.
  • x is the activation value of each layer
  • max is the maximum value of satRelu
  • n is 4, and the scale factor scale is:
  • the quantized value range is between 0 and 15. Therefore, the upper limit of the clip is 15 and the lower limit is 0. The subsequent inference needs to continue.
  • the activation is mapped between -8 and 7, so as to facilitate GPU (Graphics Processing Unit, graphics processor) calculations.
  • the value of scale is a way that each layer shares a scale.
  • a straight-through estimator is used to calculate the gradient in the back propagation process, that is, a straight-through estimator (STE).
  • a straight-through estimator is used to calculate the gradient, and the number of bits quantized by the network is gradually reduced to 4 bits.
  • the number of quantized bits n is 8, 6, 5, 4, that is Start training with 8bit quantization first, and gradually reduce the number of bits to 4bit during the training process.
  • Using this method can reduce the problem of gradient mismatch, so that the network gradually adapts to the error caused by quantization, thereby effectively improving the operation accuracy and quantization efficiency.
  • step S4 is executed: judging whether the accuracy of the pseudo-quantization model converges to the set accuracy.
  • step S5 pre-inference processing is performed on the pseudo-quantization model, and converted into a 4-bit inference model that can be used for inference operations.
  • the training model is reloaded first, and the satRelu layer is changed back to the ordinary Relu layer, so as to ensure that the network structure does not change.
  • the pre-inference process includes: constant folding, secondary quantization, and activation of equivalent transformations.
  • the calculation formula for the constant folding process includes:
  • this embodiment can improve the accuracy of calculation by performing secondary quantization on the weight.
  • the quantization method here is the same as the quantization method of the weight during training, the quantized scale of the weight is re-obtained, and the activated scale is unchanged, and the scale obtained by the training is still used.
  • TensorCore can support 4-bit operations on the GPU, so TensorCore code can be used for inference calculations, but TensorCore only supports signed 4bit and 4bit or unsigned 4bit and unsigned 4bit operations, but the network is activated after training It is an unsigned 4-bit number, and the weight is a signed 4-bit number.
  • the specific activation equivalent transformation is: subtract the intermediate value of 8 from the activation, transform it into signed 4bit data and then perform inference.
  • the equivalent transformation of convolution is
  • the weight and input here are in int32 format, but the data range is int4, that is, the data range is between -8 and 7, and there is no data type of int4 in the cpu, so the weight and activation need to be separately Take the low 4bit data, and re-splice the 8 data into an int32 through a shift operation to reduce the space occupied by the data storage and facilitate the GPU to fetch the data for calculation.
  • step S3 If the accuracy of the pseudo-quantization model does not converge to the set accuracy, return to step S3 to re-train the neural network and obtain a new pseudo-quantization model until the accuracy of the new pseudo-quantization model converges to the set accuracy.
  • FIG. 2 is a schematic structural diagram of a neural network 4-bit quantization system provided by an embodiment of the application. It can be seen from FIG. 2 that the 4-bit quantization system of the neural network in this embodiment mainly includes: a loading module, a statistics module, a retraining module, a judgment module, and a conversion module.
  • the loading module is used to load the pre-training model of the neural network;
  • the statistics module is used to calculate the initial value of each saturated activation layer satRelu in the pre-training model;
  • the retraining module is used to add pseudo-quantization nodes to the neural network , And use the initial value of satRelu to retrain the neural network to obtain the pseudo-quantization model;
  • the judgment module is used to judge whether the accuracy of the pseudo-quantization model converges to the set accuracy;
  • the conversion module is used when the accuracy of the pseudo-quantization model converges
  • the pseudo-quantization model is pre-processed for inference and converted into a 4-bit inference model that can be used for inference operations.
  • the pre-inference process includes: constant folding, secondary quantization, and activation equivalent transformation.
  • the statistics module includes: a replacement unit, an activation value acquisition unit, a statistics unit, and an initial value selection unit.
  • the replacement unit is used to replace all the activation layers relu in the neural network with the saturated activation layer satRelu;
  • the activation value acquisition unit is used to obtain the activation value of each saturated activation layer satRelu according to the acquired command;
  • the statistical unit Used to use the histogram statistics distribution data according to the activation value;
  • an initial value selection unit used to select the activation value located at the 99.999% point in the histogram as the initial value of the parameter max in the saturated activation layer satRelu, where , SatRelu is defined as:
  • the retraining module includes: a pseudo-quantization layer insertion unit, a first retraining unit, and a second retraining unit.
  • the pseudo-quantization layer insertion unit is used to insert the weight pseudo-quantization layer before the weight layer of the neural network, and the activation pseudo-quantization layer is inserted before the activation layer;
  • the pre-inference processing module includes: constant folding unit, secondary quantization unit and activation equivalent transformation unit.
  • the calculation formula of the merged new convolution is:
  • the secondary quantization unit is used to re-quantize the weight to obtain the quantization scale coefficient scale of the weight after the secondary quantization; activate the equivalent transformation unit to use the formula Make an equivalent transformation to the activation.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

一种神经网络的4比特量化方法及系统,该方法包括:加载神经网络的预训练模型(S1);在预训练模型中,统计各饱和激活层satRelu的初始值(S2);在神经网络中添加伪量化节点,并利用satRelu的初始值进行神经网络的重训练,获取伪量化模型(S3);判断伪量化模型的精度是否收敛到设定的精度(S4);如果是,对伪量化模型进行推理前处理,转换为可用于推理运算的4比特的推理模型(S5);否则返回进行神经网络的重训练。该系统主要包括:加载模块、统计模块、重训练模块、判断模块和转换模块。通过该方法及系统能够在确保训练结果准确性的基础上,有效提高训练效率。

Description

一种神经网络的4比特量化方法及系统
本申请要求于2020年06月24日提交中国专利局、申请号为202010589233.5、发明名称为“一种神经网络的4比特量化方法及系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及神经网络模型压缩技术领域,特别是涉及一种神经网络的4比特量化方法及系统。
背景技术
在神经网络中,Neural Network模型一般会占用很大的磁盘空间,比如AlexNet的模型文件超过了200MB(MByte,兆字节)。模型包含了数百万的参数,绝大部分的磁盘空间都用于存储模型参数。由于模型参数是浮点数类型的,普通的压缩算法很难压缩其空间,因此,引入模型量化,通过减少表示每个权重所需的比特数来压缩原始网络,能够大大提高网络的运行速度。因此,如何对神经网络进行量化是个重要的技术问题。
目前神经网络量化的主流方法是8bit量化,大多数训练和推理框架都支持8比特量化。然而相比于8比特量化,4比特量化可以在8比特的基础上将模型的体积继续压缩1倍,运行速度提升50%。因此,4比特量化也逐渐引起人们重视。
目前的4比特量化算法通常是从头开始训练一个网络,直到整个网络训练完毕,以imagenet这种大型数据集一般需要训练100个以上的周期数才能训练完毕。且采用非线性量化的方式提升模型精度。
然而,目前的4比特量化算法中,由于量化周期数较多,训练时间较长,使得量化效率较低。
发明内容
本申请提供了一种神经网络的4比特量化方法及系统,以解决现有技术中的神经网络量化方法量化效率较低的问题。
为了解决上述技术问题,本申请实施例公开了如下技术方案:
一种神经网络的4比特量化方法,所述方法包括:
加载神经网络的预训练模型;
在所述预训练模型中,统计各饱和激活层satRelu的初始值;
在所述神经网络中添加伪量化节点,并利用satRelu的初始值进行神经网络的重训练,获取伪量化模型;
判断所述伪量化模型的精度是否收敛到设定的精度;
如果是,对所述伪量化模型进行推理前处理,转换为可用于推理运算的4比特的推理模型,所述推理前处理过程包括:常量折叠、二次量化以及激活等价变换;
如果否,继续进行神经网络的重训练。
可选地,在所述预训练模型中,统计各饱和激活层satRelu的初始值的方法,包括:
将所述神经网络中所有的激活层relu替换为饱和激活层satRelu;
根据所获取的命令,获取各饱和激活层satRelu的激活值;
根据所述激活值,利用直方图统计分布数据;
选取所述直方图中位于99.999%点位的激活值作为饱和激活层satRelu中参数max的初始值,其中,satRelu定义为:
Figure PCTCN2021076982-appb-000001
且反向传播中,satRelu对于参数max的梯度为:
Figure PCTCN2021076982-appb-000002
satRelu对于输入x的梯度为
Figure PCTCN2021076982-appb-000003
max为饱和激活层satRelu的最大值。
可选地,在神经网络重训练过程中,采用L2正则化的方法对参数max进行压缩。
可选地,重训练周期≤10,参数max的取值≤1。
可选地,在所述神经网络中添加伪量化节点,并利用satRelu的初始值进行神经网络的重训练,获取伪量化模型的方法,包括:
在神经网络的权重层之前插入权重伪量化层,且在激活层之前插入激活伪量化层;
利用公式y=quant(w)=clip(round(w*scale))/scale,对权重伪量化层进行神经网络的重训练,其中,w为权重值,n取值为4,比例系数scale为:
Figure PCTCN2021076982-appb-000004
利用公式y=quant(x)=clip(round(x*scale))/scale,对激活伪量化层进行神经网络的重训练,其中,x为每层的激活值,max为satRelu的最大值,n取值为4,比例系数scale为:
Figure PCTCN2021076982-appb-000005
可选地,进行神经网络的重训练时,反向传播过程采用直通估计器计算梯度。
一种神经网络的4比特量化系统,所述系统包括:
加载模块,用于加载神经网络的预训练模型;
统计模块,用于在所述预训练模型中,统计各饱和激活层satRelu的初始值;
重训练模块,用于在所述神经网络中添加伪量化节点,并利用satRelu的初始值进行神经网络的重训练,获取伪量化模型;
判断模块,用于判断所述伪量化模型的精度是否收敛到设定的精度;
转换模块,用于当所述伪量化模型的精度收敛到设定的精度时,对所述伪量化模型进行推理前处理,转换为可用于推理运算的4比特的推理模型,所述推理前处理过程包括:常量折叠、二次量化以及激活等价变换。
可选地,所述统计模块包括:
替换单元,用于将所述神经网络中所有的激活层relu替换为饱和激活层satRelu;
激活值获取单元,用于根据所获取的命令,获取各饱和激活层satRelu的激活值;
统计单元,用于根据所述激活值,利用直方图统计分布数据;
初始值选取单元,用于选取所述直方图中位于99.999%点位的激活值作为饱和激活层satRelu中参数max的初始值,其中,satRelu定义为:
Figure PCTCN2021076982-appb-000006
且反向传播中,satRelu对于参数max的梯度为:
Figure PCTCN2021076982-appb-000007
satRelu对于输入x的梯度为
Figure PCTCN2021076982-appb-000008
max为饱和激活层satRelu的最大值。
可选地,所述重训练模块包括:
伪量化层插入单元,用于在神经网络的权重层之前插入权重伪量化层,且在激活层之前插入激活伪量化层;
第一重训练单元,用于利用公式y=quant(w)=clip(round(w*scale))/scale,对权重伪量化层进行神经网络的重训练,其中,w为权重值,n取值为4,比例系数scale为:
Figure PCTCN2021076982-appb-000009
第二重训练单元,用于利用公式y=quant(x)=clip(round(x*scale))/scale,对激活伪量化层进行神经网络的重训练,其中,x为每层的激活值,max为satRelu的最大值,n取值为4,比例系数scale为:
Figure PCTCN2021076982-appb-000010
可选地,所述推理前处理模块包括:
常量折叠单元,用于将batchNorm层融合进卷积中,其中,卷积的计算公式为:z=w*x+b,batchNorm的计算公式为:
Figure PCTCN2021076982-appb-000011
合并 后的新卷积的计算公式为:
Figure PCTCN2021076982-appb-000012
二次量化单元,用于对权重进行二次量化,获取二次量化后权重的量化比例系数scale;
激活等价变换单元,用于利用公式
Figure PCTCN2021076982-appb-000013
对激活做等价变换。
本申请的实施例提供的技术方案可以包括以下有益效果:
本申请提供一种神经网络的4比特量化方法,该量化方法首先加载神经网络的预训练模型,在预训练模型中统计各satRelu层的初始值,在神经网络中添加伪量化节点,并利用satRelu的初始值进行神经网络的重训练,通过几个周期的重训练获取伪量化模型,并利用推理方法将伪量化模型转换为4比特的推理模型,通过推理算法使在推理前完成全4比特推理过程,有利于提高计算速度,并确保最终的推理模型能够直接应用于4比特的GPU上,支持4比特的GPU运算,有利于提高本发明的实用性。该方法在重训练时,采用伪量化的方式进行,通过在权重层和激活层之前插入相应的伪量化层,用于模拟模型量化对整个神经网络的影响,借由训练来使模型学习并适应对神经网络的影响,从而能够大大提高量化模型的准确率,获取到的模型精度损失能够控制在1%以内,确保4比特量化结果满足精度要求。而且,本实施例中重训练的周期为10,即:对神经网络进行10次重训练,大大节省训练时间,能够在确保精度的基础上有效提高训练效率,进而提高神经网络4比特量化效率。
本实施例中对神经网络进行重训练,对权重层和激活层采用线性伪量化,在确保训练精度的基础上提高计算速度,从而有效提高神经网络量化效率。
本申请还提供一种神经网络的4比特量化系统。该系统主要包括:加载模块、统计模块、重训练模块、判断模块和转换模块。通过加载模块和重训练模块,能够通过重训练的方式加载一预训练模型,对其进行几个周期的重训练,获取伪量化模型,当判断模块判定伪量化模型的精度收敛到 设定精度时,启动转换模块将对伪量化模型进行推理前处理,转换为可用于推理运算的4比特的推理模型。本实施例采用较少的重训练次数,通常为10个周期,能够有效节省训练时间,从而大大提高神经网络量化效率。而且,利用推理前处理模块在推理态对伪量化模型进行处理,能够在推理前完成全4比特推理,有利于进一步提高计算速度,从而提高量化效率。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本申请。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本申请实施例所提供的一种神经网络的4比特量化方法的流程示意图;
图2为本申请实施例所提供的一种神经网络的4比特量化系统的结构示意图。
具体实施方式
为了使本技术领域的人员更好地理解本申请中的技术方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。
为了更好地理解本申请,下面结合附图来详细解释本申请的实施方式。
实施例一
参见图1,图1为本申请实施例所提供的一种神经网络的4比特量化方法的流程示意图。由图1可知,本实施例中神经网络的4比特量化方法, 主要包括如下过程:
S1:加载神经网络的预训练模型。
S2:在预训练模型中,统计各饱和激活层satRelu的初始值。
具体地,步骤S2又包括:
S21:将神经网络中所有的激活层relu替换为饱和激活层satRelu。
S22:根据所获取的命令,获取各饱和激活层satRelu的激活值。
S23:根据激活值,利用直方图统计分布数据。
S24:选取直方图中位于99.999%点位的激活值作为饱和激活层satRelu中参数max的初始值。其中,satRelu定义为:
Figure PCTCN2021076982-appb-000014
且反向传播中,satRelu对于参数max的梯度为:
Figure PCTCN2021076982-appb-000015
satRelu对于输入x的梯度为
Figure PCTCN2021076982-appb-000016
由步骤S1和S2可知,本实施例在进行训练前,首先加载神经网络的预训练模型,可以通过运行网络脚本的形式实现。通过运行网络脚本,统计各层激活值的分布情况,对于每层激活值,可以采用4096个采样点统计直方图分布,选取直方图分布中位于99.999%的点位的激活值,作为satRelu中唯一参数max的初始值,用于后续的迭代训练。
本实施例中satRelu的下限值为0,satRelu的下限值为max,也就是satRelu的最大值为max,max是一个变量,在神经网络训练的过程逐渐变小,此处需要求取max的初始值。
本实施例在训练时,需要将原网络中的所有relu层替换为satRelu层,satRelu的定义如下:
Figure PCTCN2021076982-appb-000017
其中,max为直方图统计出的各层的初始值。且反向传播中,satRelu 对于参数max的梯度为:
Figure PCTCN2021076982-appb-000018
对于输入x的梯度为
Figure PCTCN2021076982-appb-000019
进一步地,本实施例在神经网络重训练过程中,对于max参数,采用L2正则化对其进行压缩,能够有效减小量化误差,增加网络精度。
本实施例中重训练周期≤10,参数max的取值小于等于1,其中优选取值为:重训练周期为10,参数max为1。本实施例中参数max的取值设置,能够确保每层输出适当,有利于提高网络精度。在训练过程中,需要观察max值,采用合适的正则化参数,保证在网络收敛时,max取值在1附近。
继续参见图1可知,统计各饱和激活层satRelu的初始值之后,执行步骤S3:在神经网络中添加伪量化节点,并利用satRelu的初始值进行神经网络的重训练,获取伪量化模型。
本实施例在神经网络中添加伪量化节点,具体是:对神经网络的卷积的输入和权重,以及,神经网络的全连接的输入和权重添加伪量化节点。
S31:在神经网络的权重层之前插入权重伪量化层,且在激活层之前插入激活伪量化层。
本实施例在模型训练中,整个神经网络采用伪量化的方式进行训练,即:在常规神经网络中,在权重层和激活层之前插入伪量化层,通过权重伪量化层和激活伪量化层,能够模拟模型量化对整个神经网络的影响,并通过训练使得模型学习并适应这种影响,从而能够有效提高最种量化模型的准确率。
S32:利用公式y=quant(w)=clip(round(w*scale))/scale,对权重伪量化层进行神经网络的重训练。
其中,w为权重值,n取值为4,比例系数scale为:
Figure PCTCN2021076982-appb-000020
本实施例中对权重伪量化层进行神经网络的重训练之后,获取到伪量化模型,伪量化模型中的权重值因为训而发生变化。另外,本实施例为神 经网络4比特量化,量化后的取值范围为-8~7,因此,clip的上限为7,下限为-8,round函数用于对输入进行四舍五入取整,scale的取值采用每个输出通道共享一个scale的方式。
S33:利用公式y=quant(x)=clip(round(x*scale))/scale,对激活伪量化层进行神经网络的重训练。
其中,x为每层的激活值,max为satRelu的最大值,n取值为4,比例系数scale为:
Figure PCTCN2021076982-appb-000021
由于每层激活后面会有一个relu层,因此激活值不会出现负值,量化后的取值范围在0~15之间,因此clip的上限为15,下限为0,后续在推理时需要继续将激活映射到-8~7之间,从而便于GPU(Graphics Processing Unit,图形处理器)计算,scale的取值是每个层共享一个scale的方式。
本实施例中进行神经网络的重训练时,反向传播过程采用直通估计器计算梯度,即STE(straight-through estimator)。具体地,由于量化函数为离散不可导函数,采用直通估计器计算梯度,利用网络量化的bit数逐渐降低到4比特的方式,量化的bit数n取值为8,6,5,4,即先从8bit量化开始训练,在训练过程中逐渐将bit数降低到4bit。使用该方式可以减小梯度不匹配的问题,使网络逐渐适应由于量化带来的误差,从而有效提高运行精度和量化效率。
继续参见图1可知,本实施例中进行神经网络的重训练,获取伪量化模型之后,执行步骤S4:判断伪量化模型的精度是否收敛到设定的精度。
如果伪量化模型的精度收敛到设定的精度,执行步骤S5:对伪量化模型进行推理前处理,转换为可用于推理运算的4比特的推理模型。
本实施例先重新加载训练模型,将satRelu层重新更改为普通的Relu层,从而确保网络结构不改变。推理前处理过程包括:常量折叠、二次量化以及激活等价变换。
具体地,在训练过程中,batchNorm层不做任何处理,不会影响网络的精度。在训练后,需将batchNorm层融合进卷积中,常量折叠过程的计算公式包括:
1)卷积的计算过程:z=w*x+b;
2)batchNorm的计算过程:
Figure PCTCN2021076982-appb-000022
3)合并后的新卷积的计算过程采用公式:
Figure PCTCN2021076982-appb-000023
Figure PCTCN2021076982-appb-000024
由于batchnorm层折叠后,权重参数发生变化,本实施例通过对权重做二次量化,能够提高计算的精度。此处量化方法与训练时权重的量化方式一致,重新得到权重的量化scale,而激活的scale不变,仍采用训练获得的scale。
本实施例中TensorCore可以支持GPU上的4比特的运算,因此可用TensorCore代码进行推理计算,但TensorCore仅支持有符号的4bit与4bit或者无符号4bit与无符号4bit的运算,但训练后的网络激活为无符号4bit数,权重为有符号4bit数,通过将激活做等价变换,能够支持GPU运算,提高本方法的实用性。具体的激活等价变换为:对激活减掉中间值8,变换为有符号4bit数据后进行推理。卷积的等价变换为
Figure PCTCN2021076982-appb-000025
根据上述卷积等价变换公式,卷积的推理计算过程分为以下几步:
1)首先对卷积的输入做pad操作。
2)对输入和权重分别乘以各自的scale,得到4bit的量化值。即W q=scale wW,x q=scale a(x-8)。
3)此处的权重和输入均为int32格式,但其中的数据范围均为int4,即数据范围在-8~7之间,而cpu中没有int4这种数据类型,因此需分别将 权重和激活取低4bit的数据,通过移位操作将8个数据重新拼接为一个int32,减少数据存储占用的空间,方便GPU取数据进行运算。
4)进行4bit卷积运算,即W q*x q,然后加上偏置W q*scale a*8+b q
5)进行反量化,即除以scale w*scale a,由于反量化的操作可与下一层的卷积输入做常量折叠合并,即可隐藏掉该运算。
最后,需要一些网络的整体检查:如常量折叠,合并一些常量计算,去除冗余算子后,将该模型保存下来,直接保存出来即是全int4推理模型,即可用该模型进行推理计算。
如果伪量化模型的精度没有收敛到设定的精度,返回步骤S3,重新进行神经网络的重训练,并获取新的伪量化模型,直到新的伪量化模型的精度收敛到设定的精度为止。
实施例二
在图1所示实施例的基础之上参见图2,图2为本申请实施例所提供的一种神经网络的4比特量化系统的结构示意图。由图2可知,本实施例中神经网络的4比特量化系统中主要包括:加载模块、统计模块、重训练模块、判断模块和转换模块。
其中,加载模块,用于加载神经网络的预训练模型;统计模块,用于在预训练模型中,统计各饱和激活层satRelu的初始值;重训练模块,用于在神经网络中添加伪量化节点,并利用satRelu的初始值进行神经网络的重训练,获取伪量化模型;判断模块,用于判断伪量化模型的精度是否收敛到设定的精度;转换模块,用于当伪量化模型的精度收敛到设定的精度时,对伪量化模型进行推理前处理,转换为可用于推理运算的4比特的推理模型,其中,推理前处理过程包括:常量折叠、二次量化以及激活等价变换。
进一步地,统计模块包括:替换单元、激活值获取单元、统计单元和初始值选取单元。其中,替换单元,用于将所述神经网络中所有的激活层relu替换为饱和激活层satRelu;激活值获取单元,用于根据所获取的命令,获取各饱和激活层satRelu的激活值;统计单元,用于根据所述激活值,利用直方图统计分布数据;初始值选取单元,用于选取所述直方图中位于99.999%点位的激活值作为饱和激活层satRelu中参数max的初始值,其中, satRelu定义为:
Figure PCTCN2021076982-appb-000026
且反向传播中,satRelu对于参数max的梯度为:
Figure PCTCN2021076982-appb-000027
satRelu对于输入x的梯度为
Figure PCTCN2021076982-appb-000028
重训练模块包括:伪量化层插入单元、第一重训练单元和第二重训练单元。其中,伪量化层插入单元,用于在神经网络的权重层之前插入权重伪量化层,且在激活层之前插入激活伪量化层;第一重训练单元,用于利用公式y=quant(w)=clip(round(w*scale))/scale,对权重伪量化层进行神经网络的重训练,其中,w为权重值,n取值为4,比例系数scale为:
Figure PCTCN2021076982-appb-000029
第二重训练单元,用于利用公式y=quant(x)=clip(round(x*scale))/scale,对激活伪量化层进行神经网络的重训练,其中,x为每层的激活值,max为satRelu的最大值,n取值为4,比例系数scale为:
Figure PCTCN2021076982-appb-000030
推理前处理模块包括:常量折叠单元、二次量化单元和激活等价变换单元。其中,常量折叠单元,用于将batchNorm层融合进卷积中,其中,卷积的计算公式为:z=w*x+b,batchNorm的计算公式为:
Figure PCTCN2021076982-appb-000031
合并后的新卷积的计算公式为:
Figure PCTCN2021076982-appb-000032
Figure PCTCN2021076982-appb-000033
二次量化单元,用于对权重进行二次量化,获取二次量化后权重的量化比例系数scale;激活等价变换单元,用于利用公 式
Figure PCTCN2021076982-appb-000034
对激活做等价变换。
该实施例中神经网络的4比特量化系统的工作原理和工作方法,在图1所示的实施例一种已经详细阐述,在此不再赘述。
以上所述仅是本申请的具体实施方式,使本领域技术人员能够理解或实现本申请。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此,本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。

Claims (10)

  1. 一种神经网络的4比特量化方法,其特征在于,所述方法包括:
    加载神经网络的预训练模型;
    在所述预训练模型中,统计各饱和激活层satRelu的初始值;
    在所述神经网络中添加伪量化节点,并利用satRelu的初始值进行神经网络的重训练,获取伪量化模型;
    判断所述伪量化模型的精度是否收敛到设定的精度;
    如果是,对所述伪量化模型进行推理前处理,转换为可用于推理运算的4比特的推理模型,所述推理前处理过程包括:常量折叠、二次量化以及激活等价变换;
    如果否,继续进行神经网络的重训练。
  2. 根据权利要求1所述的一种神经网络的4比特量化方法,其特征在于,在所述预训练模型中,统计各饱和激活层satRelu的初始值的方法,包括:
    将所述神经网络中所有的激活层relu替换为饱和激活层satRelu;
    根据所获取的命令,获取各饱和激活层satRelu的激活值;
    根据所述激活值,利用直方图统计分布数据;
    选取所述直方图中位于99.999%点位的激活值作为饱和激活层satRelu中参数max的初始值,其中,satRelu定义为:
    Figure PCTCN2021076982-appb-100001
    且反向传播中,satRelu对于参数max的梯度为:
    Figure PCTCN2021076982-appb-100002
    satRelu对于输入x的梯度为
    Figure PCTCN2021076982-appb-100003
    max为饱和激活层satRelu的最大值。
  3. 根据权利要求2所述的一种神经网络的4比特量化方法,其特征在于,在神经网络的重训练过程中,采用L2正则化的方法对参数max进行压缩。
  4. 根据权利要求2所述的一种神经网络的4比特量化方法,其特征在于,重训练周期≤10,参数max的取值≤1。
  5. 根据权利要求1所述的一种神经网络的4比特量化方法,其特征在于,在所述神经网络中添加伪量化节点,并利用satRelu的初始值进行神经网络的重训练,获取伪量化模型的方法,包括:
    在神经网络的权重层之前插入权重伪量化层,且在激活层之前插入激活伪量化层;
    利用公式y=quant(w)=clip(round(w*scale))/scale,对权重伪量化层进行神经网络的重训练,其中,w为权重值,n取值为4,比例系数scale为:
    Figure PCTCN2021076982-appb-100004
    利用公式y=quant(x)=clip(round(x*scale))/scale,对激活伪量化层进行神经网络的重训练,其中,x为每层的激活值,max为satRelu的最大值,n取值为4,比例系数scale为:
    Figure PCTCN2021076982-appb-100005
  6. 根据权利要求2-4中任一所述的一种神经网络的4比特量化方法,其特征在于,进行神经网络的重训练时,反向传播过程采用直通估计器计算梯度。
  7. 一种神经网络的4比特量化系统,其特征在于,所述系统包括:
    加载模块,用于加载神经网络的预训练模型;
    统计模块,用于在所述预训练模型中,统计各饱和激活层satRelu的初始值;
    重训练模块,用于在所述神经网络中添加伪量化节点,并利用satRelu的初始值进行神经网络的重训练,获取伪量化模型;
    判断模块,用于判断所述伪量化模型的精度是否收敛到设定的精度;
    转换模块,用于当所述伪量化模型的精度收敛到设定的精度时,对所述伪量化模型进行推理前处理,转换为可用于推理运算的4比特的推理模型,所述推理前处理过程包括:常量折叠、二次量化以及激活等价变换。
  8. 根据权利要求7所述的一种神经网络的4比特量化系统,其特征在于,所述统计模块包括:
    替换单元,用于将所述神经网络中所有的激活层relu替换为饱和激活层satRelu;
    激活值获取单元,用于根据所获取的命令,获取各饱和激活层satRelu的激活值;
    统计单元,用于根据所述激活值,利用直方图统计分布数据;
    初始值选取单元,用于选取所述直方图中位于99.999%点位的激活值作为饱和激活层satRelu中参数max的初始值,其中,satRelu定义为:
    Figure PCTCN2021076982-appb-100006
    且反向传播中,satRelu对于参数max的梯度为:
    Figure PCTCN2021076982-appb-100007
    satRelu对于输入x的梯度为
    Figure PCTCN2021076982-appb-100008
    max为饱和激活层satRelu的最大值。
  9. 根据权利要求7所述的一种神经网络的4比特量化系统,其特征在于,所述重训练模块包括:
    伪量化层插入单元,用于在神经网络的权重层之前插入权重伪量化层,且在激活层之前插入激活伪量化层;
    第一重训练单元,用于利用公式y=quant(w)=clip(round(w*scale))/scale,对权重伪量化层进行神经网络的重训练,其中,w为权重值,n取值为4,比例系数scale为:
    Figure PCTCN2021076982-appb-100009
    第二重训练单元,用于利用公式y=quant(x)=clip(round(x*scale))/scale,对激活伪量化层进行神经网络的重训练,其中,x为每层的激活值,max为satRelu的最大值,n取值为4,比例系数scale为:
    Figure PCTCN2021076982-appb-100010
  10. 根据权利要求7所述的一种神经网络的4比特量化系统,其特征在于,所述推理前处理模块包括:
    常量折叠单元,用于将batchNorm层融合进卷积中,其中,卷积的计算公式为:z=w*x+b,batchNorm的计算公式为:
    Figure PCTCN2021076982-appb-100011
    合并后的新卷积的计算公式为:
    Figure PCTCN2021076982-appb-100012
    二次量化单元,用于对权重进行二次量化,获取二次量化后权重的量化比例系数scale;
    激活等价变换单元,用于利用公式
    Figure PCTCN2021076982-appb-100013
    对激活做等价变换。
PCT/CN2021/076982 2020-06-24 2021-02-20 一种神经网络的4比特量化方法及系统 Ceased WO2021258752A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010589233.5A CN111882058A (zh) 2020-06-24 2020-06-24 一种神经网络的4比特量化方法及系统
CN202010589233.5 2020-06-24

Publications (1)

Publication Number Publication Date
WO2021258752A1 true WO2021258752A1 (zh) 2021-12-30

Family

ID=73156945

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/076982 Ceased WO2021258752A1 (zh) 2020-06-24 2021-02-20 一种神经网络的4比特量化方法及系统

Country Status (2)

Country Link
CN (1) CN111882058A (zh)
WO (1) WO2021258752A1 (zh)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114662380A (zh) * 2022-02-24 2022-06-24 北京旷视科技有限公司 一种神经网络模型量化方法、设备、产品及介质
CN115034367A (zh) * 2022-06-09 2022-09-09 北京三快在线科技有限公司 一种模型部署的方法及装置
CN115331106A (zh) * 2022-08-19 2022-11-11 西安电子科技大学 一种基于全卷积轻量化神经网络的sar图像目标识别方法
CN115984628A (zh) * 2023-02-13 2023-04-18 上海大学 一种基于图神经网络的图像分类方法、系统及电子设备
CN116597814A (zh) * 2023-01-11 2023-08-15 中科南京智能技术研究院 一种基于时域二值神经网络的语音唤醒方法及系统
WO2023183262A1 (en) * 2022-03-21 2023-09-28 Google Llc 4-bit conformer with accurate quantization training for speech recognition
CN119599073A (zh) * 2024-11-21 2025-03-11 东南大学 模拟域低位多比特融合量化方法
WO2025199907A1 (zh) * 2024-03-28 2025-10-02 亿咖通(湖北)技术有限公司 神经网络模型量化方法、装置、设备、介质及产品

Families Citing this family (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111882058A (zh) * 2020-06-24 2020-11-03 苏州浪潮智能科技有限公司 一种神经网络的4比特量化方法及系统
CN112488291B (zh) * 2020-11-03 2024-06-04 珠海亿智电子科技有限公司 一种神经网络8比特量化压缩方法
CN114692818A (zh) * 2020-12-31 2022-07-01 合肥君正科技有限公司 一种低bit混合精度量化提升模型精度的方法
CN114692815A (zh) * 2020-12-31 2022-07-01 合肥君正科技有限公司 一种优化低比特模型训练的方法
CN114692814B (zh) * 2020-12-31 2024-12-06 合肥君正科技有限公司 一种优化神经网络模型激活的量化方法
CN112884144A (zh) * 2021-02-01 2021-06-01 上海商汤智能科技有限公司 网络量化方法及装置、电子设备和存储介质
CN115563203B (zh) * 2021-07-02 2025-09-12 腾讯科技(深圳)有限公司 一种模型训练方法、系统及存储介质和终端设备
CN115618931A (zh) * 2021-07-15 2023-01-17 Oppo广东移动通信有限公司 模型量化方法、装置、电子设备及可读存储介质
CN113887706B (zh) * 2021-09-30 2024-02-06 苏州浪潮智能科技有限公司 一种针对一阶段目标检测网络的低比特量化的方法和装置
CN113971457B (zh) * 2021-10-29 2024-02-02 苏州浪潮智能科技有限公司 一种神经网络的计算性能优化方法及系统
CN116109543A (zh) * 2021-11-10 2023-05-12 中移(成都)信息通信科技有限公司 一种数据快速识别读取方法及装置、计算机可读存储介质
CN114091655A (zh) * 2021-11-17 2022-02-25 上海瑾盛通信科技有限公司 神经网络量化方法、装置、存储介质以及终端
CN114418121B (zh) * 2022-01-25 2025-10-28 Oppo广东移动通信有限公司 模型训练方法、对象处理方法及装置、电子设备、介质
CN114676760B (zh) * 2022-03-10 2023-06-02 北京智源人工智能研究院 预训练模型推理处理方法、装置、电子设备及存储介质
CN114611697B (zh) * 2022-05-11 2022-09-09 上海登临科技有限公司 神经网络量化及部署方法、系统、电子设备及存储介质
CN115952841A (zh) * 2022-11-09 2023-04-11 深圳市同为数码科技股份有限公司 基于4比特量化的模型压缩方法、装置、设备及存储介质
CN115951859B (zh) * 2022-12-29 2025-05-16 深圳市欧冶半导体有限公司 一种分段线性量化方法及相关装置
CN117370798B (zh) * 2023-09-22 2025-05-30 北京百度网讯科技有限公司 模型压缩方法、训练方法、多媒体数据处理方法及装置
CN118409866B (zh) * 2024-06-21 2024-09-27 北京壁仞科技开发有限公司 张量精度处理方法、装置、电子设备、介质、程序产品

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110334802A (zh) * 2019-05-23 2019-10-15 腾讯科技(深圳)有限公司 一种神经网络模型的构建方法、装置、设备及存储介质
CN110837890A (zh) * 2019-10-22 2020-02-25 西安交通大学 一种面向轻量级卷积神经网络的权值数值定点量化方法
US20200097823A1 (en) * 2018-09-24 2020-03-26 Samsung Electronics Co., Ltd. Non-uniform quantization of pre-trained deep neural network
CN111882058A (zh) * 2020-06-24 2020-11-03 苏州浪潮智能科技有限公司 一种神经网络的4比特量化方法及系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200097823A1 (en) * 2018-09-24 2020-03-26 Samsung Electronics Co., Ltd. Non-uniform quantization of pre-trained deep neural network
CN110334802A (zh) * 2019-05-23 2019-10-15 腾讯科技(深圳)有限公司 一种神经网络模型的构建方法、装置、设备及存储介质
CN110837890A (zh) * 2019-10-22 2020-02-25 西安交通大学 一种面向轻量级卷积神经网络的权值数值定点量化方法
CN111882058A (zh) * 2020-06-24 2020-11-03 苏州浪潮智能科技有限公司 一种神经网络的4比特量化方法及系统

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114662380A (zh) * 2022-02-24 2022-06-24 北京旷视科技有限公司 一种神经网络模型量化方法、设备、产品及介质
WO2023183262A1 (en) * 2022-03-21 2023-09-28 Google Llc 4-bit conformer with accurate quantization training for speech recognition
US12374323B2 (en) 2022-03-21 2025-07-29 Google Llc 4-bit conformer with accurate quantization training for speech recognition
CN115034367A (zh) * 2022-06-09 2022-09-09 北京三快在线科技有限公司 一种模型部署的方法及装置
CN115331106A (zh) * 2022-08-19 2022-11-11 西安电子科技大学 一种基于全卷积轻量化神经网络的sar图像目标识别方法
CN116597814A (zh) * 2023-01-11 2023-08-15 中科南京智能技术研究院 一种基于时域二值神经网络的语音唤醒方法及系统
CN115984628A (zh) * 2023-02-13 2023-04-18 上海大学 一种基于图神经网络的图像分类方法、系统及电子设备
WO2025199907A1 (zh) * 2024-03-28 2025-10-02 亿咖通(湖北)技术有限公司 神经网络模型量化方法、装置、设备、介质及产品
CN119599073A (zh) * 2024-11-21 2025-03-11 东南大学 模拟域低位多比特融合量化方法

Also Published As

Publication number Publication date
CN111882058A (zh) 2020-11-03

Similar Documents

Publication Publication Date Title
WO2021258752A1 (zh) 一种神经网络的4比特量化方法及系统
CN111079781B (zh) 基于低秩与稀疏分解的轻量化卷积神经网络图像识别方法
WO2020238237A1 (zh) 一种基于幂指数量化的神经网络压缩方法
CN112613610B (zh) 一种基于联合动态剪枝的深度神经网络压缩方法
CN113011571A (zh) 基于Transformer模型的INT8离线量化及整数推断方法
CN110598839A (zh) 卷积神经网络系统和卷积神经网络量化的方法
US12555347B2 (en) Method, apparatus and device for extracting image features, and storage medium
CN113052261B (zh) 一种基于余弦空间优化的图像分类损失函数的设计方法
CN113379604B (zh) 针对超分辨率网络的剪枝量化压缩方法、系统及介质
CN113570037B (zh) 神经网络压缩方法及装置
CN113918882A (zh) 可硬件实现的动态稀疏注意力机制的数据处理加速方法
CN111160524A (zh) 一种两阶段的卷积神经网络模型压缩方法
CN115409161A (zh) 量化神经网络模型的片内执行方法、装置、设备及介质
CN112613604A (zh) 神经网络的量化方法及装置
CN114372565B (zh) 一种用于边缘设备的目标检测网络压缩方法
CN117151178A (zh) 一种面向fpga的cnn定制网络量化加速方法
CN116757255A (zh) 一种改进MobileNetV2的分心驾驶行为检测模型轻量化方法
CN116523949A (zh) 一种基于结构化剪枝的视频人像抠图方法
CN116634162A (zh) 率失真优化的图像压缩神经网络训练后量化方法
CN119312851B (zh) 一种用于图像分类卷积神经网络的低位宽自适应量化方法
CN115170902B (zh) 图像处理模型的训练方法
CN113157453A (zh) 一种基于任务复杂度的高能效目标检测任务动态调度方法
CN115147283B (zh) 一种图像重建方法、装置、设备及介质
CN119167999A (zh) Transformer模型的非线性层加速方法、装置、加速器及存储介质
CN118798294A (zh) 模型压缩方法、系统、电子设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21829738

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21829738

Country of ref document: EP

Kind code of ref document: A1