A parameter quantization-based deep learning network model optimization method
By using a lightweight network model based on YOLOv3-tiny and a step-by-step quantization method, the problem of limited hardware resources on the missile platform is solved, and efficient optimization of the network model is achieved, making it suitable for deployment on embedded devices.
Patent Information
- Application Number
- CN202310162619.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-24
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2043-02-24
AI Technical Summary
When building a deep learning-based intelligent information processing platform on a missile-borne platform, it faces limitations in hardware resources such as memory and power consumption. Existing network model optimization methods are difficult to meet the needs of resource-constrained embedded hardware platforms.
A lightweight network model based on YOLOv3-tiny is adopted, and the network model is optimized by combining channel-level quantization and step-by-step quantization. This includes building a lightweight network, channel-level quantization, and step-by-step quantization during retraining. The network weight parameters are gradually optimized by limiting the quantization range and updating the error.
It significantly reduces the storage space requirements and computational power consumption of network models, improves the computational efficiency of hardware platforms, and is suitable for deployment in embedded devices.
Smart Images

Figure CN116524173B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method for optimizing deep learning network models based on parameter quantization, belonging to the field of computer vision technology. Background Technology
[0002] Currently, most deep learning-based infrared target detection methods achieve high accuracy by establishing high-performance network models. However, in the missile-borne platform environment, embedded hardware platforms with limited space and power consumption struggle to meet the complex computing power and redundant storage requirements of deep neural networks. Therefore, it is necessary to research deep learning computing software and hardware platform systems suitable for missile-borne platforms, focusing on low-power, miniaturized intelligent hardware and optimizing low-complexity deep learning network models. Given a fixed intelligent hardware platform, optimizing low-complexity deep learning network models can effectively save storage space in the intelligent processor, reduce processor complexity, improve processor efficiency, and lower processor power consumption.
[0003] In computers, lower bit counts require less storage space than higher bit counts for floating-point numbers. Quantization, a model compression method, uses lower-precision numbers to represent convolutional neural network parameters instead of high-precision floating-point numbers. For example, replacing the original 32-bit single-precision floating-point numbers of a convolutional neural network with 8-bit integers reduces the storage space occupied by the network model to one-quarter of its original size. This lower-precision representation reduces redundancy in the network to some extent; the quantized parameters can well express the network's characteristics without requiring excessively high precision. However, in some cases, the precision of the quantized parameters may not meet the requirements of the target task, leading to a decrease in network accuracy. The goal of network quantization is to represent the network with as few bits as possible while minimizing the loss of network precision, achieving a balance between quantization bit depth and precision loss.
[0004] Reference [CN 114170512 A] addresses the shortcomings of existing remote sensing SAR target detection methods, such as high model complexity and slow inference speed. It expands and augments the data by obtaining pre-divided training and test sets from publicly available remote sensing SAR target detection datasets. It also adjusts, prunes, and performs hybrid precision quantization on existing lightweight networks to obtain a final remote sensing SAR target detection model based on a combination of network pruning and parameter quantization, which improves detection accuracy while saving training costs.
[0005] Reference [CN 111767993 A] provides a method, system, device and storage medium for INT8 quantization of convolutional neural networks. By performing offline nonlinear INT8 quantization on the parameters, input and output of the model's convolutional layers, the entire model can be operated on with pure integers, while improving quantization accuracy.
[0006] The reference [Li Jiashi. Research on Compression and Acceleration of Deep Neural Networks [D]. Beijing University of Posts and Telecommunications, 2020] addresses the severe network oscillations caused by one-shot quantization of floating-point parameters and activation values to low-bit values, which makes the quantized network training difficult to converge and results in low accuracy. It proposes an incremental quantization algorithm along the output channel dimension to reduce network fluctuations during the quantization process by iteratively quantizing network parameters and activation values. In each quantization iteration, only a portion of the network parameters and activation values corresponding to the output channels are selected and quantized according to rules. Furthermore, to further mitigate network fluctuations, the quantized weights and activation values in each iteration should be disjoint along the output channel dimension.
[0007] In view of the fact that existing network model optimization methods mostly adopt a single pruning or quantization compression approach, and lack application in lightweight infrared target recognition networks, this invention, based on existing network quantization methods, combines INT8 quantization, channel quantization, and other methods to implement a low-complexity optimization method for infrared target recognition network models based on YOLOv3-tiny network, taking into account the needs and characteristics of infrared target recognition. Summary of the Invention
[0008] The technical problem solved by this invention is to address the limitations of hardware resources such as memory and power consumption faced when building a deep learning-based intelligent information processing platform on a missile platform in the existing technology. This invention proposes a deep learning network model optimization method based on parameter quantization.
[0009] The present invention solves the above-mentioned technical problem through the following technical solution:
[0010] A deep learning network model optimization method based on parameter quantization includes:
[0011] A lightweight network model based on YOLOv3-tiny was constructed and trained to obtain preliminary floating-point network weight parameters. The lightweight network model includes convolutional layers, batch normalization layers, activation functions, max pooling layers, upsampling layers, and routing layers.
[0012] Channel-level quantization is performed on the designed lightweight network model;
[0013] The obtained preliminary network is retrained, and the network weights are quantized in a step-by-step quantization manner during the retraining process.
[0014] In the lightweight network model, the convolutional layer is used to extract high-dimensional features from the input image, specifically:
[0015]
[0016] In the formula, w n x represents the weight of the nth layer. n-1 O represents the input feature value of the nth layer. n This represents the output of the nth layer, where K is the width of the convolution kernel, and C... n This represents the number of channels for the output feature values of the nth layer.
[0017] The batch normalization layer is specifically:
[0018]
[0019] In the formula, x and y represent the input and output of the batch normalization layer, respectively, and μ (i) σ (i) Let γ represent the mean and variance of the feature map in the i-th channel of a batch, respectively. (i) and β (i) ε is a learnable channel-level parameter in the normalization layer, used to avoid data overflow.
[0020] The activation function used is the ReLU function as the activation function between the two convolutional layers.
[0021] ReLU = max(0, x).
[0022] Max pooling layers are used for data dimensionality reduction, reducing computational cost, enhancing the invariance of image features, and increasing the receptive field. Upsampling layers are used to restore image features to the input dimension and achieve target location output. Routing layers obtain multi-scale fused feature values through the output feature values of two cascaded convolutional layers.
[0023] The channel-level quantization of the designed lightweight network model specifically involves:
[0024] Different quantization intervals are used for quantization parameter matching for different channels in each layer to improve the model accuracy of the lightweight network model. The specific channel-level quantization operation for channel j in layer i is as follows:
[0025] Through max ij and min ij Record the distribution interval of the channel parameters of this layer, prune the long-tail weights, and obtain the quantization range of the parameters as d. ij The average value is m ijThe weight record of channel j in the current layer i is w. ij Quantization weights wq ij and the recovery weight wr ij According to d ij m ij And the calculation of the number of quantization bits b;
[0026] After matching the quantization parameters of each layer and channel, channel-level quantization is completed.
[0027] The step-by-step quantization method used in the retraining process is as follows:
[0028] The lightweight network model, after channel-level quantization, is retrained for a predetermined number of iterations. During retraining, the weights of each layer are randomly quantized to eliminate the lightweight network model's dependence on fixed feature quantities until the lightweight network model converges.
[0029] The model retraining steps are as follows:
[0030] During forward inference, the quantization range is selected through parameter distribution; parameters that exceed the quantization range are restricted to the quantization range, and the full-precision weights are recorded as the basis for updates.
[0031] The scaling factor and quantization range d are updated based on the mean absolute error of the full-precision parameters and the quantized parameters. ij and average m ij .
[0032] During the backpropagation of errors, the weight parameters are updated progressively in reverse based on the loss between the target and the actual target obtained by forward inference of the quantized parameters under the loss function.
[0033] Through multiple iterations of forward inference and backpropagation, the weight parameters of the network model are quantized step by step, and the network inference is reconverged.
[0034] During the model retraining process, each convolutional layer is quantized, and the quantization order of the weights in each convolutional layer is randomly selected to achieve step-by-step quantization of the weights. The learning ability of the convolutional layer is improved by the coexistence of quantization parameters and full-precision parameters.
[0035] During the model retraining process, the batch normalization layer is fused to the convolutional layer using a progressive fusion strategy. The batch normalization parameters are transferred to the pre-convolutional layer while maintaining mean and variance updates. The convolutional layer learns using the input mean and variance. During the fusion phase, updates to the mean and variance are stopped to eliminate independent batch normalization parameters, thus completing the fusion of the batch normalization layer and the convolutional layer and reducing the difficulty of deploying the deep learning network model on hardware.
[0036] The quantization process of the convolutional layer during the model retraining process is as follows:
[0037] For input feature A in Weight W conv and bias B conv Quantification and pass convolution Obtain the quantized convolution output M q According to M q and Quantization range, bias With M q After dequantization, the results are added together, and the sum is passed through an activation function to obtain the final output feature value A. out .
[0038] The parameter quantization specifically refers to:
[0039] Uniform quantization is used, with a preset quantization bit width k, where the distance between nearest-neighbor quantization points is equal.
[0040] x q =Q k (x r ,α)
[0041]
[0042] In the formula, x r Let be a tensor, be the weights, biases, or activation values, α be the scaling factor, q be the integer tensor involved in the computation within the integer arithmetic unit, and x be the value of the tensor. q Here are the quantized parameters, where Q represents the quantization function, clamp is the truncation function, and round is the rounding function, returning the rounded value of the floating-point number.
[0043] The scaling factor is used to overcome the long tail phenomenon in the weight distribution of convolutional layers and to achieve quantization correction within a range, specifically:
[0044]
[0045] During the forward inference phase, the parameters of the batch normalization layer are fixed, specifically:
[0046] y=ξ (i) o+η (i)
[0047]
[0048] In the formula, o represents the output of the previous convolutional layer, and the quantized convolution operation is:
[0049] o = αa q a α w q w
[0050] In the formula, α a q a and α w q w These represent the quantized activation value and weight, respectively.
[0051] The quantization convolution process after merging the batch normalization layer and the convolutional layer is as follows:
[0052]
[0053]
[0054] After merging the batch normalization layer with the previous quantized convolutional layer, the merged output is quantized again. The specific method is as follows:
[0055]
[0056]
[0057]
[0058] In the formula, α β It is the channel-level scaling factor tensor of β, whose initial value is the absolute maximum value of each channel of β. The scaling factors α of the weight, bias and activation values are all floating-point numbers, and it is impossible to implement all integer operations.
[0059] Shift quantization of the scaling factor:
[0060]
[0061] The scaling factor of shift quantization can be obtained using bit left or right shift operations via floating-point arithmetic. The specific calculation of the quantized convolution is as follows:
[0062]
[0063] The gradient calculation during the backpropagation of weight parameter errors in the retraining process is as follows:
[0064]
[0065] By using the parameter quantization calculation method described above during the retraining process, the step-by-step quantization process of network weight parameters is completed, thereby optimizing the network model.
[0066] The advantages of this invention compared to the prior art are:
[0067] This invention provides a deep learning network model optimization method based on parameter quantization. This low-complexity optimization method significantly reduces the number of network model weight parameters that need to be directly stored on the AI processor, reducing the computational power requirements of the algorithm. It enables the implementation of deep network models for missile-borne intelligent information processing platforms, effectively saving processor storage space and power consumption for intelligent algorithms, and improving the computational efficiency of the hardware platform. This also reduces the power consumption of the hardware platform. Attached Figure Description
[0068] Figure 1 A schematic diagram of the deep learning network model optimization process provided for the invention;
[0069] Figure 2 A schematic diagram of the YOLOv3-tiny data stream provided for the invention;
[0070] Figure 3 A step-by-step retraining flowchart provided for the invention; Detailed Implementation
[0071] A parameter quantization-based deep learning network model optimization method is proposed. Addressing the limitations of hardware resources such as memory and power consumption encountered when building a deep learning-based intelligent information processing platform on an airborne platform, this method utilizes the lightweight YOLOv3-tiny network model and combines channel-level quantization with a multi-step quantization approach to achieve parameter quantization of the network model.
[0072] YOLOv3-tiny's lightweight network model is a simplified version of YOLOv3, with less storage space and computational overhead, making it suitable for deployment on embedded devices. Its network model includes convolutional layers, batch normalization layers, activation functions, max pooling layers, upsampling layers, and routing layers. The specific workflow is as follows:
[0073] Construct a lightweight network model based on YOLOv3-tiny;
[0074] Channel-level quantization is performed on the lightweight network model;
[0075] Retrain and quantize the lightweight network model after channel-level quantization.
[0076] Perform parameter quantization on the trained lightweight network model.
[0077] Convolutional layers are used to extract high-dimensional features from the input image, specifically:
[0078]
[0079] In the formula, w n x represents the weight of the nth layer. n-1 O represents the input feature value of the nth layer. n This represents the output of the nth layer, where K is the width of the convolution kernel, and C... n The number of channels for the output feature values of the nth layer;
[0080] The batch normalization layer is specifically as follows:
[0081]
[0082] In the formula, x and y represent the input and output of the batch normalization layer, respectively, and μ (i) σ (i) Let γ represent the mean and variance of the feature map in the i-th channel of a batch, respectively. (i) and β (i) ε is a learnable channel-level parameter in the normalization layer, used to avoid data overflow.
[0083] The ReLU function is used as the activation function between the two convolutional layers.
[0084] ReLU = max(0,x);
[0085] Max pooling layers are used for data dimensionality reduction, reducing computation, enhancing the invariance of image features, and increasing the receptive field; upsampling layers are used to restore image features to the input dimension and achieve target location output; routing layers obtain multi-scale fused feature values through the output feature values of two cascaded convolutional layers.
[0086] Channel-level quantization specifically refers to:
[0087] Different quantization intervals are used for quantization parameter matching for different channels in each layer to improve the model accuracy of the lightweight network model. The specific channel-level quantization operation for channel j in layer i is as follows:
[0088] Through max ij and min ij Record the distribution interval of the channel parameters of this layer, prune the long-tail weights, and obtain the quantization range of the parameters as d. ij The average value is m ij The weight record of channel j in the current layer i is w. ij Quantization weights wq ij and the recovery weight wr ij According to d ij m ij And the calculation of the number of quantization bits b;
[0089] After matching the quantization parameters of each layer and channel, channel-level quantization is completed.
[0090] Retraining quantization specifically refers to:
[0091] The lightweight network model, after channel-level quantization, undergoes a preset number of retraining steps. During retraining, the weights of each layer are randomly quantized to eliminate the lightweight network model's dependence on fixed feature quantities until the lightweight network model converges.
[0092] The model retraining steps are as follows:
[0093] The quantization range is selected by parameter distribution; parameters that exceed the quantization range are restricted to the quantization range, and the full-precision weights are recorded as the basis for updates.
[0094] The scaling factor and d are updated based on the mean absolute error of the full-precision parameters and the quantized parameters. ij and m ij ;
[0095] During the backpropagation of errors, the weight parameters are updated progressively in reverse based on the loss between the target and the actual target obtained by forward inference of the quantized parameters under the loss function.
[0096] Through multiple iterations of forward inference and backpropagation, the weight parameters of the network model are quantized step by step, and the network inference is reconverged.
[0097] During model retraining, each convolutional layer is quantized, and the quantization order of the weights is randomly selected in each convolutional layer to achieve step-by-step quantization of the weights. The learning ability of the convolutional layer is improved by the coexistence of quantization parameters and full-precision parameters.
[0098] The batch normalization layer is fused to the convolutional layer through a progressive fusion strategy, transferring the batch normalization parameters to the pre-convolutional layer while maintaining mean and variance updates. The convolutional layer learns using the input mean and variance. During the fusion phase, the updates of the mean and variance are stopped to eliminate independent batch normalization parameters, thus completing the fusion of the batch normalization layer and the convolutional layer to reduce the difficulty of deploying deep learning network models on hardware.
[0099] The quantization process of convolutional layers during model retraining is as follows:
[0100] For input feature A in Weight W conv and bias B conv Quantification and pass convolution Obtain the quantized convolution output M q According to M q and Quantization range, bias With Mq After dequantization, the results are added together, and the sum is passed through an activation function to obtain the final output feature value A. out ;
[0101] Parameter quantization specifically refers to:
[0102] Uniform quantization is used, with a preset quantization bit width k, where the distance between nearest-neighbor quantization points is equal.
[0103] x q =Q k (x r ,α)
[0104]
[0105] In the formula, x r Let be a tensor, be the weights, biases, or activation values, α be the scaling factor, q be the integer tensor involved in the computation within the integer arithmetic unit, and x be the value of the tensor. q These are the quantized parameters used for network training. The scaling factor is α, Q represents the quantization function, clamp is the truncation function, and round is the rounding function, returning a floating-point number with rounded values.
[0106] The scaling factor is used to overcome the long tail phenomenon in the weight distribution of convolutional layers and to achieve quantization correction within a range, specifically:
[0107]
[0108] During the forward inference phase, the parameters of the batch normalization layer are fixed, specifically:
[0109] y=ξ (i) o+η (i)
[0110]
[0111] In the formula, o represents the output of the previous convolutional layer, and the quantized convolution operation is:
[0112] o = α a q a α w q w
[0113] In the formula, α a q a and α w q w These represent the quantized activation value and weight, respectively.
[0114] The quantization convolution process after merging the batch normalization layer and the convolutional layer is as follows:
[0115]
[0116]
[0117] After merging the batch normalization layer with the previous quantized convolutional layer, the merged output is quantized again. The specific method is as follows:
[0118]
[0119]
[0120]
[0121] In the formula, α β It is the channel-level scaling factor tensor of β, whose initial value is the absolute maximum value of each channel of β. The scaling factors α of the weight, bias and activation values are all floating-point numbers, and it is impossible to implement all integer operations.
[0122] Shift quantization of the scaling factor:
[0123]
[0124] The scaling factor of shift quantization can be obtained using bit left or right shift operations via floating-point arithmetic. The specific calculation of the quantized convolution is as follows:
[0125]
[0126] During retraining, the gradient calculation during the backpropagation of the weight parameter error is specifically as follows:
[0127]
[0128] By using the parameter quantization calculation method described above during the retraining process, the step-by-step quantization process of network weight parameters is completed, thereby optimizing the network model.
[0129] The following description, in conjunction with the accompanying drawings and preferred embodiments, provides further details:
[0130] In the current embodiment, the overall implementation process is as follows: Figure 1 As shown, a low-complexity optimization method for deep learning network models based on parameter quantization is proposed, including a lightweight network model based on YOLOv3-tiny, which combines channel-level quantization and multi-step quantization to achieve parameter quantization of the network model.
[0131] like Figure 2As shown, YOLOv3-tiny's lightweight network model is a simplified version of YOLOv3, with less storage space and computational overhead, making it suitable for deployment on embedded devices. Its network model includes convolutional layers, batch normalization layers, activation functions, max pooling layers, upsampling layers, and routing layers.
[0132] The convolutional layer is used to extract high-dimensional features from the input image, and its operation is as follows:
[0133]
[0134] Among them, w n x represents the weight of the nth layer. n-1 O represents the input feature value of the nth layer. n This represents the output of the nth layer, where K is the width of the convolution kernel, and C... n This represents the number of channels for the output feature values of the nth layer.
[0135] The following operation represents the batch normalization layer:
[0136]
[0137] Where x and y represent the input and output of the batch normalization layer, respectively, and μ (i) σ (i) Let γ represent the mean and variance of the feature map in the i-th channel of a batch, respectively. (i) and β (i) These are two learnable channel-level parameters in the normalization layer, with ε used to avoid data overflow.
[0138] The ReLU function is used as the activation function between two convolutional layers:
[0139] ReLU = max(0,x)
[0140] In YOLO, the routing layer obtains the features extracted by the first half of the neural network by cascading two output feature values of the same size from different convolutional layers.
[0141] The channel-level quantization employed allows for different quantization intervals to be used for different channels in each layer, enabling the quantization intervals to better match the parameter distribution of each channel. Channel-level quantization better preserves the differences between channels, which helps improve model accuracy. The quantization operation of channel j in convolutional layer i can be described as follows: First, through max... ij and min ij Record the distribution interval of the channel parameters of this layer, and then prune the long-tail weights according to the parameter distribution to obtain the quantization range of the parameters as d. ij The average value is m ij The weights of channel j in convolutional layer i are recorded as w.ij Quantization weights wq ij and the recovery weight wr ij According to d ij m ij The quantization bit width (b) is calculated.
[0142] like Figure 3 As shown, the multi-step quantization method used decomposes the one-step quantization in the model retraining into multiple steps, thereby ensuring the stability of the model training. At the same time, random quantization is performed on the weights during training to enhance the robustness of the model, eliminate the model's dependence on fixed features, and make the model more convergent.
[0143] The model retraining process employed divides the training phase into two main steps. In the first step, the quantization range is selected based on the parameter distribution. Parameters exceeding the quantization range are bound within it, and full-precision weights are recorded as the basis for updates. In the second step, d... ij and m ij Update based on the mean absolute error of the full-precision parameters and the quantized parameters.
[0144] The quantization process of retrained convolutional layers involves randomly selecting the quantization order of weights within each convolutional layer to achieve step-by-step quantization. This significantly reduces model perturbation during training and prevents the model from escaping from the global minimum. Furthermore, the coexistence of quantized parameters and full-precision parameters allows the full-precision parameters to fully utilize their learning capabilities.
[0145] Furthermore, to reduce the difficulty of deploying the model on hardware, the batch normalization structure in the network model is fused to the preceding convolutional layers. A progressive fusion strategy is adopted, decomposing the operation into two stages. In the learning stage, the batch normalization parameters are transferred to the pre-convolutional layers while maintaining mean and variance updates. The convolutional layers learn the distribution of activations using the input mean and variance. In the fusion stage, updates to the mean and variance are stopped, thus eliminating the independent batch normalization parameters.
[0146] Furthermore, during the quantization process of the convolutional layer, the input feature A is first... in Weight W conv and bias B conv Quantification and pass convolution Obtain the quantized convolution output M q Because of M q and Different quantization ranges require different biases. With M q After dequantization, the results are added together, and the sum is passed through an activation function to obtain the final output feature value A.out .
[0147] Furthermore, the network model's parameter quantization employs uniform quantization, where the distance between nearest-neighbor quantization points is equal. Given a quantization bit width k, the quantization process can be expressed as follows:
[0148] x q =Q k (x r ,α)
[0149]
[0150] Where x r For tensors, α can be weights, biases, or activation values. α is the scaling factor, q is the integer tensor involved in computation within the integer arithmetic unit, and x... q These are the quantized parameters used for network training. The scaling factor α is crucial for low-bit quantization. Q represents the quantization function. clamp is the truncation function. round is the rounding function, returning the rounded value of the floating-point number.
[0151] Furthermore, to address the difficulty in selecting the scaling factor α caused by the long tail phenomenon in the weight distribution of convolutional neural networks, a learnable scaling factor α during training is introduced to implement an interval-variable clamping function. The quantization process is modified as shown in the following equation:
[0152]
[0153] To update the scaling factor α during neural network training, the gradient of α during backpropagation is calculated using the following formula:
[0154]
[0155] Furthermore, in the forward inference stage, the parameters of the batch normalization layer are fixed, resulting in the following formula:
[0156] y=ξ (i) o+η (i)
[0157]
[0158] Where o is the output of the previous convolutional layer, the quantized convolution operation can be represented by the following formula:
[0159] o = α a q a α w q w
[0160] Where α a q a and αw q w These represent the quantized activation value and weight, respectively.
[0161] Furthermore, the batch normalization layer and the convolutional layer are merged, and the merged quantized convolution process is shown below:
[0162]
[0163]
[0164] The merging process is characterized by quantizing the merged output again after merging the batch normalization layer with the previous quantized convolutional layer. Low-bit integer arithmetic is used to simplify the further convolution calculation, as shown in the following equation:
[0165]
[0166]
[0167]
[0168] Where α β It is a channel-level scaling factor tensor of β, initialized with the absolute maximum value of each channel of β. At this point, the scaling factors α of the weights, biases, and activation values are all floating-point numbers, making it impossible to perform all-integer operations.
[0169] Further shift quantization of the scaling factor:
[0170]
[0171] The scaling factor for shift quantization can be obtained using bit left or right shift operations via floating-point arithmetic. The quantized convolution is calculated as follows:
[0172]
[0173] The final convolution operation consists only of integer multiplication and addition operations between the weight tensor and the activation tensor, and bit shifting operations for the scaling factor, requiring no floating-point operations. The weights, after quantization, use two bits, while the bias and activation values each use eight bits. Quantization reduces memory usage and bandwidth overhead, and improves resource utilization.
[0174] Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make possible changes and modifications to the technical solutions of the present invention by utilizing the methods and techniques disclosed above without departing from the spirit and scope of the present invention. Therefore, any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solutions of the present invention shall fall within the protection scope of the technical solutions of the present invention.
[0175] The contents not described in detail in this specification are common knowledge to those skilled in the art.
Claims
1. A method for optimizing deep learning network models based on parameter quantization, characterized in that... include: A lightweight network model based on YOLOv3-tiny is constructed and trained to obtain preliminary floating-point network weight parameters; the lightweight network model includes convolutional layers, batch normalization layers, activation functions, max pooling layers, upsampling layers, and routing layers; Channel-level quantization is performed on the designed lightweight network model; The obtained preliminary network is retrained, and the network weights are quantized in a step-by-step quantization manner during the retraining process. In the lightweight network model, the convolutional layer is used to extract high-dimensional features from the input image, specifically: In the formula, w n x represents the weight of the nth layer. n-1 O represents the input feature value of the nth layer. n This represents the output of the nth layer, where K is the width of the convolution kernel, and C... n This represents the number of channels for the output feature values of the nth layer.
2. The method for optimizing a deep learning network model based on parameter quantization according to claim 1, characterized in that: The batch normalization layer is specifically: In the formula, x and y represent the input and output of the batch normalization layer, respectively, and μ (i) σ (i) Let γ represent the mean and variance of the feature map in the i-th channel of a batch, respectively. (i) and β (i) ε is a learnable channel-level parameter in the normalization layer, used to avoid data overflow.
3. The method for optimizing a deep learning network model based on parameter quantization according to claim 2, characterized in that: The activation function used is ReLU, which is employed as the activation function between the two convolutional layers. ReLU = max(0, x).
4. The method for optimizing a deep learning network model based on parameter quantization according to claim 3, characterized in that: Max pooling layers are used for data dimensionality reduction, reducing computational cost, enhancing the invariance of image features, and increasing the receptive field. Upsampling layers are used to restore image features to the input dimension and achieve target location output. Routing layers obtain multi-scale fused feature values through the output feature values of two cascaded convolutional layers.
5. The method for optimizing a deep learning network model based on parameter quantization according to claim 4, characterized in that: The channel-level quantization of the designed lightweight network model specifically involves: Different quantization intervals are used for quantization parameter matching for different channels in each layer to improve the model accuracy of the lightweight network model. The specific channel-level quantization operation for channel j in layer i is as follows: Through max ij and min ij Record the distribution interval of the channel parameters of this layer, prune the long-tail weights, and obtain the quantization range of the parameters as d. ij The average value is m ij The weight record of channel j in the current layer i is w. ij Quantization weights wq ij and the recovery weight wr ij According to d ij m ij Calculate the quantization bit width (b). After matching the quantization parameters of each layer and channel, channel-level quantization is completed.
6. The method for optimizing a deep learning network model based on parameter quantization according to claim 5, characterized in that: The step-by-step quantization method used in the retraining process is as follows: The lightweight network model, after channel-level quantization, is retrained for a predetermined number of iterations. During retraining, the weights of each layer are randomly quantized to eliminate the lightweight network model's dependence on fixed feature quantities until the lightweight network model converges. The model retraining steps are as follows: During forward inference, the quantization range is selected through parameter distribution; parameters that exceed the quantization range are restricted to the quantization range, and the full-precision weights are recorded as the basis for updates. The scaling factor and quantization range d are updated based on the mean absolute error of the full-precision parameters and the quantized parameters. ij and average value m ij ; During the backpropagation of error, the weight parameters are gradually updated in reverse based on the loss between the target and the actual target obtained by forward inference of the quantized parameters under the loss function. Through multiple iterations of forward inference and backpropagation, the weight parameters of the network model are quantized step by step, and the network inference is reconverged.
7. The method for optimizing a deep learning network model based on parameter quantization according to claim 6, characterized in that: During the model retraining process, each convolutional layer is quantized, and the quantization order of the weights in each convolutional layer is randomly selected to achieve step-by-step quantization of the weights. The learning ability of the convolutional layer is improved by the coexistence of quantization parameters and full-precision parameters.
8. The method for optimizing a deep learning network model based on parameter quantization according to claim 7, characterized in that: During the model retraining process, the batch normalization layer is fused to the convolutional layer using a progressive fusion strategy. The batch normalization parameters are transferred to the pre-convolutional layer while maintaining mean and variance updates. The convolutional layer learns using the input mean and variance. During the fusion phase, updates to the mean and variance are stopped to eliminate independent batch normalization parameters, thus completing the fusion of the batch normalization layer and the convolutional layer and reducing the difficulty of deploying the deep learning network model on hardware.
9. The method for optimizing a deep learning network model based on parameter quantization according to claim 8, characterized in that: The quantization process of the convolutional layer during the model retraining process is as follows: For input feature A in Weight W conv and bias B conv Quantification and pass convolution Obtain the quantized convolution output M q According to M q and Quantization range, bias With M q After dequantization, the results are added together, and the sum is passed through an activation function to obtain the final output feature value A. out .
10. The method for optimizing a deep learning network model based on parameter quantization according to claim 9, characterized in that: The parameter quantization specifically refers to: Uniform quantization is used, with a preset quantization bit width k, where the distance between nearest-neighbor quantization points is equal. x q =Q k (x r ,α) In the formula, x r Let be a tensor, be the weights, biases, or activation values, α be the scaling factor, q be the integer tensor involved in the computation within the integer arithmetic unit, and x be the value of the tensor. q Here are the quantized parameters, where Q represents the quantization function, clamp is the truncation function, and round is the rounding function, returning the rounded value of the floating-point number. The scaling factor is used to overcome the long tail phenomenon in the weight distribution of convolutional layers and to achieve quantization correction within a range, specifically:
11. The method for optimizing a deep learning network model based on parameter quantization according to claim 10, characterized in that: During the forward inference phase, the parameters of the batch normalization layer are fixed, specifically: y=ξ (i) o+h (i) In the formula, o represents the output of the previous convolutional layer, and the quantized convolution operation is: o=a a q a a w q w In the formula, α a q a and α w q w These represent the quantized activation value and weight, respectively. The quantization convolution process after merging the batch normalization layer and the convolutional layer is as follows: After merging the batch normalization layer with the previous quantized convolutional layer, the merged output is quantized again. The specific method is as follows: In the formula, α β It is the channel-level scaling factor tensor of β, whose initial value is the absolute maximum value of each channel of β. The scaling factors α of the weight, bias and activation values are all floating-point numbers, and it is impossible to implement all integer operations. Shift quantization of the scaling factor: The scaling factor of shift quantization uses bit left or right shift operations to perform floating-point operations. The specific calculation of the quantized convolution is as follows:
12. The method for optimizing a deep learning network model based on parameter quantization according to claim 6, characterized in that: The gradient calculation during the backpropagation of weight parameter errors in the retraining process is as follows: By using the parameter quantization calculation method described above in the retraining process, the step-by-step quantization process of network weight parameters is completed, thereby optimizing the network model.
Citation Information
Patent Citations
Convolutional neural network INT8 quantification method, system and device and storage medium
CN111767993A
Remote sensing SAR target detection method based on combination of network pruning and parameter quantification
CN114170512A
Method for rapidly detecting small target under view angle of unmanned aerial vehicle based on yolov3
CN113128362A