A method, system and related components for quantizing a neural network

By directly obtaining the mean of the input feature map on the full-precision model and using the weighted quantization error tensor to correct the quantization neural network, the problems of long processing time and dependence on batch normalization parameters in the existing technology are solved, and fast and widely applicable quantization neural network correction is achieved.

CN115238871BActive Publication Date: 2026-02-24HUNAN GOKE MICROELECTRONICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210969151.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-12
Publication Date
2026-02-24
Estimated Expiration
2042-08-12

AI Technical Summary

Technical Problem

Existing quantized neural networks suffer from severe mean shift errors in real-time processing fields such as edge computing due to the large number of parameters and computational load. Existing correction methods are time-consuming or rely on batch normalization parameters, limiting their applicability.

Method used

By directly running the calibration set image data on the full-precision model, the mean of the input feature map of each network layer is obtained at once, and the error tensor and bias tensor are corrected using weight quantization, avoiding iteration and dependence on batch normalization parameters.

Benefits of technology

It achieves fast, low-CPU-requirement quantization neural network correction, has a wide range of applications, short processing time, and does not depend on batch normalization parameters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115238871B_ABST
    Figure CN115238871B_ABST
Patent Text Reader

Abstract

The application discloses a correction method and system for quantizing a neural network and related components, and relates to the field of computer vision. The method comprises the following steps: obtaining a target neural network for processing image data; determining a weight quantization error tensor corresponding to each network layer of the target neural network according to the target neural network; running calibration set image data on a full-precision model to obtain the mean value of each input channel of the input feature map of each network layer at one time; determining the weight quantization mean value offset error corresponding to each network layer according to the weight quantization error tensor and the input channel mean value of each network layer; and correcting the initial quantization model according to the bias tensor of each network layer of the initial quantization model and the weight quantization mean value offset error to obtain a target quantization model. The correction process of the application does not require iteration, consumes less time, has lower requirements for CPU, and is not dependent on batch normalization parameters, so the application range is wider.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision, and in particular to a method, system, and related components for correcting quantized neural networks. Background Technology

[0002] Currently, neural networks are developing rapidly in the field of computer vision. However, in fields such as edge computing that require real-time processing, the large number of parameters and computational demands of neural networks severely limit their development. Therefore, low-bit quantization technology for neural networks has emerged.

[0003] Low-bit quantization of neural networks, including the quantization of weights and activations, can significantly improve the parameter storage size and computational efficiency of neural networks. In the quantization of neural network weights, it is generally chosen to quantize the weights to their nearest integer. While this method offers advantages such as extremely fast quantization speed and ease of operation, due to the quantization error between the weights before and after quantization, the output feature map of the network layer before activation exhibits mean shift error after convolution calculations.

[0004] Currently, there are two main methods to handle the mean shift problem caused by weight quantization:

[0005] One approach is Iterative Bias Correction, also known as Empirical Bias Correction. This method uses calibration set images to iteratively correct the mean offset error of each layer of the neural network. This approach requires that when correcting the error of the current network layer, the mean offset errors of all channels of the output feature maps of all network layers input to this layer have been corrected. Therefore, it is necessary to repeatedly run the calibration set images to correct the error of each network layer one by one, which is time-consuming and generally takes several hours to tens of hours.

[0006] Another approach is Analysis Bias Correction, which uses the standard deviation and mean parameters from the batch normalization parameters of the previous layer to correct the offset error of the mean of each channel in the output feature map of this network layer through activation function transformation. This method is time-efficient and efficient, but it depends on the existence of batch normalization parameters and is not suitable for neural networks without batch normalization parameters or with incomplete batch normalization parameters.

[0007] Therefore, there is an urgent need for a method to quantify the mean offset error and solve the above-mentioned technical problems. Summary of the Invention

[0008] In view of this, the purpose of this invention is to provide a time-efficient and widely applicable method, system, and related components for correcting quantized neural networks. The specific solution is as follows:

[0009] A method for correcting a quantized neural network, comprising:

[0010] A target neural network for processing image data is obtained, the target neural network including a full-precision model and an initial quantized model after weight quantization of the full-precision model;

[0011] Based on the target neural network, determine the weight quantization error tensor corresponding to each network layer of the target neural network;

[0012] The calibration set image data is run on the full-precision model, and the mean value of each input channel of the input feature map of each network layer is obtained at once;

[0013] The weight quantization mean offset error for each network layer is determined based on the weight quantization error tensor of each network layer and the mean of the input channels.

[0014] The target quantization model is obtained by correcting the initial quantization model based on the bias tensor of each network layer of the initial quantization model and the mean offset error of the weight quantization.

[0015] Preferably, the process of correcting the initial quantization model to obtain the target quantization model based on the bias tensors of each network layer of the initial quantization model and the weight quantization mean offset error includes:

[0016] Subtract the mean offset error of the weight quantization of the corresponding network layer from the bias tensor of each network layer in the initial quantization model to obtain the target quantization model after correcting the initial quantization model.

[0017] Preferably, the process of determining the weight quantization error tensor corresponding to each network layer of the target neural network based on the target neural network includes:

[0018] Subtracting the initial weight tensor of the full-precision model from the quantized weight tensor of the initial quantization model yields the weight quantization error tensor corresponding to each network layer of the target neural network.

[0019] Preferably, the target neural network includes multiple network layers, specifically including convolutional layers and / or fully connected layers.

[0020] Preferably, the process of determining the weight quantization mean offset error corresponding to each network layer based on the weight quantization error tensor of each network layer and the mean of the input channels includes:

[0021] When the network layer is a convolutional layer, the weight quantization mean offset error of each output channel of the output feature map of the network layer is determined based on the value of each output channel of the weight quantization error tensor and the mean of all input channels of the network layer.

[0022] Preferably, when the network layer is a convolutional layer, the process of determining the weight quantization mean offset error of each output channel of the output feature map of the network layer based on the value of each output channel of the weight quantization error tensor and the mean of all input channels of the network layer specifically includes:

[0023] For all values ​​of any output channel of the weight quantization error tensor and the mean of all input channels of the network layer, perform the following operations:

[0024] Summing all values ​​of the weighted quantization error tensor in the same input channel yields the first sum value of the input channel.

[0025] The first sum of each input channel is multiplied by the mean of the corresponding input channel to obtain the first product of each input channel.

[0026] The first product of all input channels is summed to obtain a second sum, which is used as the weight quantization mean offset error of the convolutional layer in the output channel.

[0027] Preferably, the process of determining the weight quantization mean offset error corresponding to each network layer based on the weight quantization error tensor of each network layer and the mean of the input channels includes:

[0028] When the network layer is the fully connected layer, a matrix-vector multiplication operation is performed on the weight quantization error tensor of the fully connected layer and the mean of each input channel of the fully connected layer to obtain the weight quantization mean offset error of the fully connected layer.

[0029] Accordingly, this application also discloses a correction system for quantized neural networks, comprising:

[0030] An acquisition module is used to acquire a target neural network for processing image data, the target neural network including a full-precision model and an initial quantized model after weight quantization of the full-precision model;

[0031] The first module is used to determine the weight quantization error tensor corresponding to each network layer of the target neural network based on the target neural network.

[0032] The second module is used to run the calibration set image data on the full-precision model and obtain the mean value of each input channel of the input feature map of each network layer at once;

[0033] The third module is used to determine the weight quantization mean offset error corresponding to each of the network layers based on the weight quantization error tensor of each network layer and the mean of the input channels.

[0034] The correction module is used to correct the initial quantization model based on the bias tensor of each network layer of the initial quantization model and the weight quantization mean offset error to obtain the target quantization model.

[0035] Accordingly, this application discloses a correction device for quantized neural networks, comprising:

[0036] Memory, used to store computer programs;

[0037] A processor for executing the computer program to implement the steps of the correction method for the quantized neural network as described in any of the preceding descriptions.

[0038] Accordingly, this application discloses a readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the quantization neural network correction method described in any of the above claims.

[0039] This application discloses a method for correcting a quantized neural network, comprising: obtaining a target neural network for processing image data, the target neural network including a full-precision model and an initial quantized model after weight quantization of the full-precision model; determining the weight quantization error tensor corresponding to each network layer of the target neural network based on the target neural network; running calibration set image data on the full-precision model and obtaining the mean of each input channel of the input feature map of each network layer at once; determining the weight quantization mean offset error corresponding to each network layer based on the weight quantization error tensor of each network layer and the mean of the input channels; and correcting the initial quantization model based on the bias tensor of each network layer of the initial quantization model and the weight quantization mean offset error to obtain a target quantization model. This application directly runs calibration set image data on the full-precision model to obtain the mean of the input feature map corresponding to all network layers at once, and then uses the mean of all input feature maps and the weight quantization error tensor to calculate and correct the initial quantization model. This process does not require iteration, consumes less time, has lower CPU requirements, and does not depend on batch normalization parameters, thus having a wider range of applications. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0041] Figure 1 This is a flowchart illustrating the steps of a method for correcting a quantized neural network according to an embodiment of the present invention.

[0042] Figure 2 This is a structural distribution diagram of a correction system for a quantized neural network according to an embodiment of the present invention. Detailed Implementation

[0043] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0044] Of the two existing mean offset correction methods, iterative bias correction is very time-consuming, depending on the model size and CPU performance, and generally takes several hours to tens of hours. Analyzing bias correction relies on batch normalization parameters, which is not suitable for neural networks without batch normalization parameters or with incomplete batch normalization parameters.

[0045] This application obtains the mean of the input feature maps of all network layers at once by directly running the calibration set image data on the full-precision model. Then, it uses the mean of all input feature maps and the weight quantization error tensor to calculate and correct the initial quantization model. The process does not require iteration, consumes less time, has lower CPU requirements, and does not depend on batch normalization parameters, making it more widely applicable.

[0046] This invention discloses a method for correcting quantized neural networks, see [link to relevant documentation]. Figure 1 As shown, it includes:

[0047] S1: Obtain the target neural network for processing image data. The target neural network includes a full-precision model and an initial quantized model after weight quantization of the full-precision model.

[0048] It is understood that the target neural network in this embodiment is mainly used to process image data. Since the full-precision model of the target neural network has a large number of parameters and computational load when running in real time, the initial quantized model obtained after weight quantization of the full-precision model can quickly and easily perform calculations. However, the output feature maps of each network layer of the initial quantized model have mean offset errors in each output channel. The purpose of this embodiment is to correct this error.

[0049] S2: Based on the target neural network, determine the weight quantization error tensor for each network layer of the target neural network;

[0050] Understandably, once the number of bits and the weight quantization method for the target neural network weights are determined, the weight quantization error tensor of each network layer is a constant. Step S2 can determine the weight quantization error tensor of each network layer based on the initial weight tensor of the full-precision model and the weight quantization method or quantization parameters used when quantizing the full-precision model. Here, the quantization parameters include the number of bits. Alternatively, step S2 can specifically include: determining the weight quantization error tensor based on the initial weight tensor of the full-precision model and the quantized weight tensor of the initial quantized model. Specifically, the weight quantization error tensor of each network layer is obtained by subtracting the initial weight tensor of the full-precision model from the quantized weight tensor of the initial quantized model. Specifically, the tensor in the initial weight tensor, quantized weight tensor, and weight quantization error tensor is a geometric entity in mathematical terms. Tensors include scalars, vectors, and linear operators, and can be expressed in the form of coordinate systems, multidimensional arrays of components, etc., denoted as arrays of scalars, and are commonly used in physics and engineering.

[0051] S3: Run the calibration set image data on the full-precision model and obtain the mean value of each input channel of the input feature map of each network layer at once;

[0052] It is understood that the calibration set image data specifically refers to a subset of the training set image data, and / or the validation set image data, and / or the test set image data. These training set image data, validation set image data, and test set image data are all image data corresponding to the full-precision model. By selecting a subset of the data as the calibration set image data, the target neural network can be obtained.

[0053] It should be noted that, in this embodiment, when directly running the calibration set image data on the full-precision model, unlike the iterative bias correction method, this application does not require a process of iterative layer-by-layer correction and iteration of the initial quantization model. Instead, the calibration set image data is directly passed through the network layers of the full-precision model to obtain the mean value of each input channel of the input feature map of each network layer in one go. No iteration or correction is required. The mean value of each input channel of the input feature map of each network layer is directly obtained. Furthermore, for each network layer, the weight quantization mean offset error can be determined by calculating the mean value of the input channel and the weight quantization error tensor.

[0054] S4: Determine the weight quantization mean offset error for each network layer based on the weight quantization error tensor and the mean of the input channels for each network layer;

[0055] Understandably, the target neural network comprises multiple network layers, specifically convolutional layers and / or fully connected layers. The methods for calculating the weight quantization mean offset error differ slightly depending on the type of network layer.

[0056] When the network layer is a convolutional layer, the weight quantization mean offset error of each output channel of the network layer's output feature map is determined based on the value of each output channel of the weight quantization error tensor and the mean of all input channels of the network layer.

[0057] It is understandable that when the network layer is a convolutional layer, the network layer corresponds to multiple weight quantization mean offset errors. Each weight quantization mean offset error corresponds to one output channel of the output feature map of this network layer. The specific calculation formula is as follows:

[0058]

[0059] Understandably, the weight quantization error tensor requires at least four dimensions in its representation: output channels, input channels, and dimensions (height and width). Here, co is the output channel index, ci is the input channel index, CI is the total number of input channels in the convolutional layer, m and n are the indexes of the weight quantization error tensor in its height and width dimensions, and M and N are the total values ​​in these two dimensions, respectively. E[εx]co The mean offset error of the weight quantization of the output channel co in the output feature map of this network layer. E[xc [o,ci] represents the mean value of the input channel ci in the input feature map of this network layer. εLet x be the weight quantization error tensor for input channels co and ci, with height and width m and n respectively, and let x be the output feature map of this network layer. This calculation does not involve the spatial dimension of the input feature map; the spatial dimension of the input feature map does not affect the weight quantization mean offset error of each output channel of the output feature map of this network layer. In other words, when the network layer is a convolutional layer, the process of determining the weight quantization mean offset error of each output channel of the network layer's output feature map based on the value of each output channel of the weight quantization error tensor and the mean of all input channels of the network layer specifically includes:

[0060] For all values ​​of any output channel of the weight quantization error tensor and the mean of all input channels of the network layer, perform the following operations:

[0061] Summing all values ​​of the weighted quantization error tensor in the same input channel yields the first sum value for the input channel.

[0062] Multiply the first sum of each input channel by the mean of the corresponding input channel to obtain the first product of each input channel;

[0063] The first product of all input channels is summed to obtain the second sum, which is used as the weight quantization mean offset error of the convolutional layer in the output channel.

[0064] For fully connected layers, the formula for calculating the weight quantization mean offset error degenerates into:

[0065]

[0066] For a fully connected layer, its input feature map is actually a one-dimensional phasor. For convenience and uniformity of description, in this embodiment, each element of the input feature map of the fully connected layer is regarded as a unique element of each input channel, that is, each element is directly used as the average value of the input channel of its respective input channel. The output feature map is similar.

[0067] It is understandable that the weight quantization mean offset error tensor of each network layer has the same shape as the bias tensor of the corresponding network layer.

[0068] S5: Based on the bias tensor and weight quantization mean offset error of each network layer of the initial quantization model, the initial quantization model is corrected to obtain the target quantization model.

[0069] It is understandable that the weight quantization mean offset error tensor of each network layer has the same tensor shape as the bias tensor of the corresponding network layer. Step S5 specifically includes: subtracting the weight quantization mean offset error of the corresponding network layer from the bias tensor of each network layer of the initial quantization model to obtain the target neural network after correcting the weight quantization mean offset error of the initial quantization model.

[0070] Understandably, a target neural network with corrected offset errors can perform more accurate image processing.

[0071] Understandably, this embodiment treats each network layer as a unit. Based on the weight quantization error tensor of that network layer and the mean of each input channel of the input feature map, the weight quantization error tensor of that network layer is determined. This is then used to correct the mean shift of each output channel of the output feature map of that network layer. The process does not require iteration between network layers; each network layer is independent of the others. The correction of the current network layer does not rely on the correction result of the previous network layer, thus reducing the time consumption. Furthermore, it does not depend on the batch normalization parameters of the layer above it. Without batch normalization parameters, this embodiment can successfully complete the correction of the quantization mean shift error of the entire target neural network, making it more widely applicable.

[0072] This application discloses a method for correcting a quantized neural network, comprising: obtaining a target neural network for processing image data, the target neural network including a full-precision model and an initial quantized model after weight quantization of the full-precision model; determining the weight quantization error tensor corresponding to each network layer of the target neural network based on the target neural network; running calibration set image data on the full-precision model and obtaining the mean of each input channel of the input feature map of each network layer at once; determining the weight quantization mean offset error corresponding to each network layer based on the weight quantization error tensor of each network layer and the mean of the input channels; and correcting the initial quantization model based on the bias tensor of each network layer of the initial quantization model and the weight quantization mean offset error to obtain a target quantization model. This application directly runs calibration set image data on the full-precision model to obtain the mean of the input feature map corresponding to all network layers at once, and then uses the mean of all input feature maps and the weight quantization error tensor to calculate and correct the initial quantization model. This process does not require iteration, consumes less time, has lower CPU requirements, and does not depend on batch normalization parameters, thus having a wider range of applications.

[0073] Accordingly, this application discloses a correction system for quantized neural networks, see [link to relevant documentation]. Figure 2 As shown, it includes:

[0074] The acquisition module 10 is used to acquire a target neural network for processing image data, the target neural network including a full-precision model and an initial quantization model after weight quantization of the full-precision model;

[0075] The first module 11 is used to determine the weight quantization error tensor corresponding to each network layer of the target neural network based on the target neural network.

[0076] The second module 12 is used to run the calibration set image data on the full-precision model and obtain the mean value of each input channel of the input feature map of each network layer at once;

[0077] The third module 13 is used to determine the weight quantization mean offset error corresponding to each of the network layers based on the weight quantization error tensor of each of the network layers and the mean of each input channel.

[0078] The correction module 14 is used to obtain the target neural network after correcting the weight quantization mean offset error of the initial quantization model based on the bias tensor of each network layer of the initial quantization model and the weight quantization mean offset error.

[0079] This application embodiment obtains the mean of the input feature maps of all network layers at once by directly running the calibration set image data on the full-precision model. Then, it uses the mean of all input feature maps and the weight quantization error tensor to calculate and correct the initial quantization model. The process does not require iteration, consumes less time, has lower CPU requirements, and does not depend on batch normalization parameters, making it more widely applicable.

[0080] In some specific embodiments, the correction module 14 is specifically used for:

[0081] Subtract the mean offset error of the weight quantization of the corresponding network layer from the bias tensor of each network layer in the initial quantization model to obtain the target quantization model after correcting the initial quantization model.

[0082] In some specific embodiments, the first module 11 is specifically used for:

[0083] Subtracting the initial weight tensor of the full-precision model from the quantized weight tensor of the initial quantization model yields the weight quantization error tensor corresponding to each network layer of the target neural network.

[0084] In some specific embodiments, the target neural network includes multiple network layers, specifically including convolutional layers and / or fully connected layers.

[0085] In some specific embodiments, the third module 13 is specifically used for:

[0086] When the network layer is a convolutional layer, the weight quantization mean offset error of each output channel of the output feature map of the network layer is determined based on the value of each output channel of the weight quantization error tensor and the mean of all input channels of the network layer.

[0087] In some specific embodiments, the third module 13 is specifically used for:

[0088] For all values ​​of any output channel of the weight quantization error tensor and the mean of all input channels of the network layer, perform the following operations:

[0089] Summing all values ​​of the weighted quantization error tensor in the same input channel yields the first sum value of the input channel.

[0090] The first sum of each input channel is multiplied by the mean of the corresponding input channel to obtain the first product of each input channel.

[0091] The first product of all input channels is summed to obtain a second sum, which is used as the weight quantization mean offset error of the convolutional layer in the output channel.

[0092] In some specific embodiments, the third module 13 is specifically used for:

[0093] When the network layer is the fully connected layer, a matrix-vector multiplication operation is performed on the weight quantization error tensor of the fully connected layer and the mean of each input channel of the fully connected layer to obtain the weight quantization mean offset error of the fully connected layer.

[0094] In some specific embodiments, the calibration set image data is specifically a subset of the training set image data, and / or the validation set image data, and / or the test set image data.

[0095] Accordingly, this application discloses a correction device for quantized neural networks, comprising:

[0096] Memory, used to store computer programs;

[0097] A processor for executing the computer program to implement the steps of the correction method for the quantized neural network as described in any of the preceding descriptions.

[0098] Accordingly, this application discloses a readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the quantization neural network correction method described in any of the above claims.

[0099] For details regarding the specific correction method for the quantized neural network, please refer to the relevant descriptions in the above embodiments, which will not be repeated here.

[0100] In this embodiment, the correction device and readable storage medium of the quantized neural network have the same technical effects as the correction method of the quantized neural network in the above embodiment, and will not be described again here.

[0101] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0102] The present invention provides a detailed description of a method, system, and related components for correcting a quantized neural network. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for correcting a quantized neural network, characterized in that, include: A target neural network for processing image data is obtained, the target neural network including a full-precision model and an initial quantized model after weight quantization of the full-precision model; Based on the target neural network, determine the weight quantization error tensor corresponding to each network layer of the target neural network; The calibration set image data is run on the full-precision model, and the mean value of each input channel of the input feature map of each network layer is obtained at once; The weight quantization mean offset error for each network layer is determined based on the weight quantization error tensor of each network layer and the mean of the input channels. The target quantization model is obtained by correcting the initial quantization model based on the bias tensor of each network layer of the initial quantization model and the mean offset error of the weight quantization.

2. The correction method according to claim 1, characterized in that, The process of correcting the initial quantization model based on the bias tensors of each network layer of the initial quantization model and the mean offset error of the weight quantization to obtain the target quantization model includes: Subtract the mean offset error of the weight quantization of the corresponding network layer from the bias tensor of each network layer in the initial quantization model to obtain the target quantization model after correcting the initial quantization model.

3. The correction method according to claim 2, characterized in that, The process of determining the weight quantization error tensor corresponding to each network layer of the target neural network based on the target neural network includes: Subtracting the initial weight tensor of the full-precision model from the quantized weight tensor of the initial quantization model yields the weight quantization error tensor corresponding to each network layer of the target neural network.

4. The correction method according to claim 1, characterized in that, The target neural network includes multiple network layers, specifically including convolutional layers and / or fully connected layers.

5. The correction method according to claim 4, characterized in that, The process of determining the weight quantization mean offset error for each network layer based on the weight quantization error tensor of each network layer and the mean of the input channels includes: When the network layer is a convolutional layer, the weight quantization mean offset error of each output channel of the output feature map of the network layer is determined based on the value of each output channel of the weight quantization error tensor and the mean of all input channels of the network layer.

6. The correction method according to claim 5, characterized in that, When the network layer is a convolutional layer, the process of determining the weight quantization mean offset error of each output channel of the output feature map of the network layer based on the value of each output channel of the weight quantization error tensor and the mean of all input channels of the network layer specifically includes: For all values ​​of any output channel of the weight quantization error tensor and the mean of all input channels of the network layer, perform the following operations: Summing all values ​​of the weighted quantization error tensor in the same input channel yields the first sum value of the input channel. The first sum of each input channel is multiplied by the mean of the corresponding input channel to obtain the first product of each input channel. The first product of all input channels is summed to obtain a second sum, which is used as the weight quantization mean offset error of the convolutional layer in the output channel.

7. The correction method according to claim 4, characterized in that, The process of determining the weight quantization mean offset error for each network layer based on the weight quantization error tensor of each network layer and the mean of the input channels includes: When the network layer is the fully connected layer, a matrix-vector multiplication operation is performed on the weight quantization error tensor of the fully connected layer and the mean of each input channel of the fully connected layer to obtain the weight quantization mean offset error of the fully connected layer.

8. A correction system for a quantized neural network, characterized in that, include: An acquisition module is used to acquire a target neural network for processing image data, the target neural network including a full-precision model and an initial quantized model after weight quantization of the full-precision model; The first module is used to determine the weight quantization error tensor corresponding to each network layer of the target neural network based on the target neural network. The second module is used to run the calibration set image data on the full-precision model and obtain the mean value of each input channel of the input feature map of each network layer at once; The third module is used to determine the weight quantization mean offset error corresponding to each of the network layers based on the weight quantization error tensor of each network layer and the mean of the input channels. The correction module is used to correct the initial quantization model based on the bias tensors of each network layer of the initial quantization model and the weight quantization mean offset error to obtain the target quantization model.

9. A correction device for a quantized neural network, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the correction method for the quantized neural network as described in any one of claims 1 to 7.

10. A readable storage medium, characterized in that, The readable storage medium stores a computer program that, when executed by a processor, implements the steps of the correction method for the quantized neural network as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Convolutional neural network system and convolutional neural network quantification method

    CN110598839A

  • Training method of neural network model and medium thereof, and electronic equipment

    CN111401546A