Model compression method and device, electronic equipment and storage medium
By sorting and uniformly dividing the parameters of a deep learning neural network model, quantization parameters are determined, and model compression is achieved. This solves the problem of high computational complexity and improves computational speed and storage efficiency.
Patent Information
- Application Number
- CN202310180432.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-17
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2043-02-17
AI Technical Summary
Deep learning neural network models have high computational complexity, large space storage requirements, and large time computation requirements due to their large parameter scale, so they need to be compressed and accelerated.
By sorting and uniformly dividing the model parameters, the quantization parameters of each set are determined, thereby quantizing the model parameters and generating a compressed model.
It improves quantization accuracy, reduces the computational resource and storage space requirements of the compressed model, and enhances computational speed and efficiency.
Smart Images

Figure CN116306881B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to the field of artificial intelligence technology such as deep learning and model quantization, specifically to a model compression method, apparatus, electronic device and storage medium. Background Technology
[0002] In recent years, with the rapid development of artificial intelligence technology, deep learning neural networks have achieved great success in pattern recognition, such as image classification, object detection, image segmentation, speech recognition, and machine translation. However, high-performance neural networks typically have a large number of model parameters, resulting in high computational complexity. This computational complexity is reflected in both spatial storage (the huge model storage volume and runtime memory usage) and temporal computation (hundreds of billions of floating-point operations required for a single inference). Therefore, compressing and accelerating neural networks has become particularly important. Summary of the Invention
[0003] This disclosure provides a model compression method, apparatus, electronic device, and storage medium.
[0004] According to a first aspect of this disclosure, a model compression method is provided, comprising:
[0005] Obtain each model parameter in the model to be compressed and the target data bit width corresponding to the model parameter;
[0006] The model parameters are sorted in ascending order to obtain the first sorting result;
[0007] Based on the amount of data contained within the data range corresponding to the target data bit width, the first sorting result is evenly divided to obtain multiple first sets with the same amount of data.
[0008] Determine the first quantization parameter corresponding to each of the first sets, wherein the model parameters contained in the first set i are greater than the model parameters contained in the first set j, and the first quantization parameter corresponding to the first set i is greater than the first quantization parameter corresponding to the first set j, and i and j are different values;
[0009] Based on the first quantization parameter corresponding to each first set, the model parameters in each first set are quantized to obtain the compressed model.
[0010] According to a second aspect of this disclosure, a data processing method is provided, comprising:
[0011] Obtain the data to be processed, the data boundary points associated with the preset model, and the second quantization parameters corresponding to the data between each pair of adjacent data boundary points;
[0012] Based on the data demarcation points, the data to be processed is divided to obtain the target data to be processed contained in each pair of adjacent data demarcation points.
[0013] Based on the second quantization parameter corresponding to the data between two adjacent data boundary points in each group, the target data to be processed contained in the two adjacent data boundary points in each group is quantized to obtain the target quantized data corresponding to the data to be processed.
[0014] The target quantized data is input into the preset model to obtain the prediction result corresponding to the data to be processed, wherein the preset model is generated based on the model compression method.
[0015] According to a third aspect of this disclosure, a model compression apparatus is provided, comprising:
[0016] The first acquisition module is used to acquire each model parameter in the model to be compressed and the target data bit width corresponding to the model parameter;
[0017] The second acquisition module is used to sort the various model parameters in ascending order to obtain the first sorting result;
[0018] The third acquisition module is used to uniformly divide the first sorting result based on the amount of data contained in the data range corresponding to the target data bit width, so as to obtain multiple first sets with the same amount of data.
[0019] The first determining module is used to determine the first quantization parameter corresponding to each of the first sets, wherein the model parameters contained in the first set i are greater than the model parameters contained in the first set j, and the first quantization parameter corresponding to the first set i is greater than the first quantization parameter corresponding to the first set j, and i and j are different values;
[0020] The fourth acquisition module is used to quantize the model parameters in each of the first sets based on the first quantization parameters corresponding to each of the first sets, so as to obtain the compressed model.
[0021] According to a fourth aspect of this disclosure, a data processing apparatus is provided, comprising:
[0022] The first acquisition module is used to acquire the data to be processed, the data boundary points associated with the preset model, and the second quantization parameters corresponding to the data between each pair of adjacent data boundary points.
[0023] The second acquisition module is used to divide the data to be processed based on the data boundary points to obtain the target data to be processed contained in each pair of adjacent data boundary points.
[0024] The third acquisition module is used to quantize the target data to be processed contained in each group of two adjacent data boundary points based on the second quantization parameter corresponding to the data between each group of two adjacent data boundary points, so as to obtain the target quantized data corresponding to the data to be processed.
[0025] The third acquisition module is used to input the target quantized data into the preset model to obtain the prediction result corresponding to the data to be processed, wherein the preset model is generated based on the model compression device.
[0026] According to a fifth aspect of this disclosure, an electronic device is provided, comprising:
[0027] At least one processor; and
[0028] A memory communicatively connected to the at least one processor; wherein,
[0029] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the model compression method as described in the first aspect, or to perform the data processing method as described in the second aspect.
[0030] According to a sixth aspect of this disclosure, a non-transitory computer-readable storage medium is provided that stores computer instructions for causing the computer to perform the model compression method as described in the first aspect, or to perform the data processing method as described in the second aspect.
[0031] According to a seventh aspect of this disclosure, a computer program product is provided, including computer instructions that, when executed by a processor, implement the steps of the model compression method as described in the first aspect, or the steps of the data processing method as described in the second aspect.
[0032] The model compression method, apparatus, electronic device, and storage medium disclosed herein have the following beneficial effects:
[0033] In this embodiment, the model parameters and their corresponding target data bit widths in the model to be compressed are first obtained. The model parameters are then sorted from smallest to largest to obtain a first sorting result. Next, based on the amount of data contained within the data range corresponding to the target data bit width, the first sorting result is evenly divided to obtain multiple first sets with the same amount of data. A first quantization parameter is determined for each first set. Finally, based on the first quantization parameter for each first set, the model parameters in each first set are quantized to obtain the compressed model. Therefore, by evenly dividing the model parameters from smallest to largest into first sets with the same amount of data as the target data bit width, and assigning a first quantization parameter to each first set, the model parameters can be evenly quantized based on the number of model parameters in each set, improving quantization accuracy. This reduces the computational loss of the compressed model, lowers the computational resources and storage space occupied by the compressed model, and improves the computational speed and efficiency of the compressed model.
[0034] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0035] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0036] Figure 1 This is a schematic flowchart of a model compression method provided according to an embodiment of the present disclosure;
[0037] Figure 2 This is a schematic flowchart of a model compression method according to yet another embodiment of the present disclosure;
[0038] Figure 3 This is a flowchart illustrating a data processing method according to yet another embodiment of the present disclosure;
[0039] Figure 4 This is a schematic diagram of a model compression device according to an embodiment of the present disclosure;
[0040] Figure 5 This is a schematic diagram of the structure of a data processing apparatus according to yet another embodiment of the present disclosure;
[0041] Figure 6 This is a block diagram of an electronic device provided according to an embodiment of the present disclosure. Detailed Implementation
[0042] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0043] The embodiments disclosed herein relate to the fields of artificial intelligence technology, such as deep learning and model quantization.
[0044] Artificial Intelligence (AI) is a new technological science that studies and develops theories, methods, technologies, and application systems to simulate, extend, and expand human intelligence.
[0045] Deep learning learns the inherent patterns and hierarchical representations of sample data. The information gained during this learning process greatly aids in interpreting data such as text, images, and sound. The ultimate goal of deep learning is to enable machines to possess analytical and learning capabilities similar to humans, allowing them to recognize data such as text, images, and sound.
[0046] Model quantization is the process of converting a floating-point model to a fixed-point model using some method. For example, it involves quantizing model parameters from Float-32 to lower bit values, such as Float-16, INT8, or 1 bit. To achieve greater compression ratios and faster running speeds, or due to limitations imposed by the computing unit type of the deployment platform, models typically require fixed-point quantization of both the weights and activation values of the entire network model.
[0047] The model compression method, apparatus, electronic device, and storage medium of this disclosure are described below with reference to the accompanying drawings.
[0048] It should be noted that the execution subject of the model compression method in this embodiment is a model compression device, which can be implemented by software and / or hardware. The device can be configured in an electronic device, which may include, but is not limited to, a terminal, a server, etc.
[0049] Figure 1 This is a schematic flowchart of a model compression method provided according to an embodiment of the present disclosure.
[0050] like Figure 1 As shown, the model compression method includes:
[0051] S101: Obtain the model parameters and target data bit widths corresponding to the model parameters in the model to be compressed.
[0052] The model to be compressed can be a pre-trained high-precision model. The model to be compressed can be a model for image recognition, a model for image classification, a model for speech recognition, etc. This disclosure does not limit this.
[0053] In this model, each parameter can be one or more of the model's weights, biases, and activation values.
[0054] The target data bit width can be the length of the quantized model parameters. For example, if the quantized model parameters are of type INT8, then the target data bit width is 8 bits.
[0055] It should be noted that the data bit width of each model parameter in the model to be compressed is greater than the target data bit width. For example, if each model parameter in the model to be compressed is Float-32 (i.e., the data bit width is 32 bits), then the quantized model parameters can be of type INT8, i.e., the target data bit width is 8 bits, or they can be of type INT4, i.e., the target data bit width is 4 bits.
[0056] S102: Sort each model parameter in ascending order to obtain the first sorting result.
[0057] It should be noted that if quantization is required for each type of model parameter, the different types of model parameters need to be sorted separately before quantization. For example, if both weights and activation values need to be quantized, then all weights and activation values in the model to be compressed should be sorted separately.
[0058] S103: Based on the amount of data contained within the data range corresponding to the target data bit width, the first sorting result is evenly divided to obtain multiple first sets with the same amount of data.
[0059] The target data bit width corresponds to the amount of data contained within the data range, which can be defined as the maximum number of data points that the target data bit width can represent. For example, if the target data bit width is 8 bits, the corresponding data volume is 256, thus the first sorting result is evenly divided into 256 first sets.
[0060] In this embodiment of the disclosure, the first sorting result is evenly divided, meaning that the number of model parameters contained in each first set is basically the same. For example, some first sets contain 'a' model parameters, while the remaining first sets contain 'a+1' model parameters. It should be noted that since the number of model parameters in the model to be compressed is large, the slight difference in the number of model parameters in each first set will not affect the quantization of the model parameters.
[0061] S104: Determine the first quantization parameter corresponding to each first set, wherein the model parameters contained in the first set i are greater than the model parameters contained in the first set j, and the first quantization parameter corresponding to the first set i is greater than the first quantization parameter corresponding to the first set j, and i and j are different values.
[0062] Where i and j are both integers greater than 0.
[0063] Optionally, the first set can be sorted from smallest to largest based on the values of the quantization parameters contained in each first set to obtain a first order. Then, multiple data points corresponding to the target quantization data bit width are determined (for example, if the target quantization data bit width is int8, the corresponding data points could be -127 to 128, or 0 to 255, etc.), and these multiple data points are sorted from smallest to largest to obtain a second order. The first quantization parameter corresponding to the model parameter in the b-th first set in the first order is determined as the b-th data point in the second order, where b is a positive integer.
[0064] S105: Based on the first quantization parameter corresponding to each first set, quantize the model parameters in each first set to obtain the compressed model.
[0065] In this embodiment of the disclosure, after determining the first quantization parameter corresponding to each first set, each model parameter contained in the first set can be quantized into the first quantization parameter corresponding to the first set to obtain the compressed model, thereby reducing the storage space required for the model parameters and reducing the memory space occupied by the model.
[0066] It is understood that the model compression method provided in this disclosure can be applied to compression scenarios for any task model, such as compression of models for text classification, image classification, speech recognition, etc., and this disclosure does not limit it.
[0067] In this embodiment, the model parameters and their corresponding target data bit widths in the model to be compressed are first obtained. The model parameters are then sorted from smallest to largest to obtain a first sorting result. Next, based on the amount of data contained within the data range corresponding to the target data bit width, the first sorting result is evenly divided to obtain multiple first sets with the same amount of data. A first quantization parameter is determined for each first set. Finally, based on the first quantization parameter for each first set, the model parameters in each first set are quantized to obtain the compressed model. Therefore, by evenly dividing the model parameters from smallest to largest into first sets with the same amount of data as the target data bit width, and assigning a first quantization parameter to each first set, the model parameters can be evenly quantized based on the number of model parameters in each set, improving quantization accuracy. This reduces the computational loss of the compressed model, lowers the computational resources and storage space occupied by the compressed model, and improves the computational speed and efficiency of the compressed model.
[0068] Figure 2 This is a schematic flowchart of a model compression method according to yet another embodiment of the present disclosure;
[0069] like Figure 2 As shown, the model compression method includes:
[0070] S201: Obtain the model parameters and target data bit widths corresponding to the model parameters in the model to be compressed.
[0071] S202: Sort each model parameter in ascending order to obtain the first sorting result.
[0072] S203: Based on the amount of data contained within the data range corresponding to the target data bit width, the first sorting result is evenly divided to obtain multiple first sets with the same amount of data.
[0073] S204: Determine the first quantization parameter corresponding to each first set, wherein the model parameters contained in the first set i are greater than the model parameters contained in the first set j, and the first quantization parameter corresponding to the first set i is greater than the first quantization parameter corresponding to the first set j, and i and j are different values.
[0074] S205: Based on the first quantization parameter corresponding to each first set, quantize the model parameters in each first set to obtain the compressed model.
[0075] The specific implementation of steps S201 to S205 can be found in the detailed descriptions of other embodiments in this disclosure, and will not be repeated here.
[0076] S206: Obtain multiple sets of initial sample data corresponding to the task type of the model to be compressed.
[0077] The task type of the model to be compressed can be image classification, object detection, image segmentation, speech recognition, and machine translation, etc. This disclosure does not limit this.
[0078] For example, if the task type of the model to be compressed is image classification, then the initial sample data is the image data to be classified. If the task type of the model to be compressed is speech recognition, then the initial sample data is the speech data to be classified.
[0079] Each initial sample data set can contain multiple sample data sets. For example, if the task type of the model to be compressed is speech recognition, then each initial sample data set can contain 100 speech data sets.
[0080] S207: Quantize each set of initial sample data to obtain the quantized sample data corresponding to each set of initial sample data.
[0081] The process of quantizing each set of initial sample data is the same as the process of quantizing model parameters, and will not be described in detail here.
[0082] S208: Determine the quantization loss for each set of initial sample data based on each set of initial sample data and the corresponding quantized sample data.
[0083] Quantization loss reflects the impact of quantizing the initial sample data on the accuracy of the model's predictions. A larger quantization loss has a greater impact on the accuracy of the predictions, while a smaller quantization loss has a smaller impact.
[0084] Optionally, each set of initial sample data can be input into the model to be compressed to obtain the first output vector corresponding to each set of initial sample data. Then, each set of quantized sample data can be input into the compressed model to obtain the second output vector corresponding to each set of quantized sample data. Finally, based on the loss function and the first and second output vectors corresponding to each set of initial sample data, the quantization loss corresponding to each set of initial sample data can be determined.
[0085] The first output vector can be the first prediction result of the model to be compressed on the initial sample data. The second output vector can be the second prediction result of the compressed model on the quantized sample data. The greater the difference between the first and second prediction results, the greater the quantization loss.
[0086] The loss function can be the mean squared error loss function, the L2 loss function, etc. This disclosure does not limit it.
[0087] Therefore, the loss of the compressed model in predicting quantized sample data can be accurately determined by comparing the second output vector obtained by the compressed model in predicting quantized sample data with the first output vector obtained by the model to be compressed in predicting initial sample data.
[0088] Optionally, reference loss values can be determined based on the first and second output vectors corresponding to each set of initial sample data, and then the quantization loss corresponding to each set of initial sample data can be determined based on each reference loss value and each preset decay factor.
[0089] Each reference loss value can be any of the following:
[0090] The variances of the first output vector and the second output vector;
[0091] The variances of the absolute values of the first and second output vectors;
[0092] The various exponents of the differences between the first difference corresponding to the first output vector and the second difference corresponding to the second output vector; and
[0093] The variances of each power between the absolute value of the first difference and the absolute value of the second difference;
[0094] The first difference is the difference between each element in the first output vector and the mean of the first output vector, and the second difference is the difference between each element in the second output vector and the mean of the second output vector.
[0095] Optionally, based on the first and second output vectors corresponding to each set of initial sample data, a reference loss value is determined. Then, based on each reference loss value and each preset attenuation factor, the loss function for determining the quantization loss corresponding to each set of initial sample data can be as follows:
[0096] Loss = A[E(X)-E(Y)]+A 1 [E(X 2 )-E(Y 2 )]+A 2 [E(X 3 )-E(Y 3 )]+……A n-1 [E
[0097] (X n )-E(Y n )]
[0098] Where Loss is the quantization error, A is the decay factor, the value of A is in the range of [0, 1), n is an integer greater than 0, and E is the mean.
[0099] If X is the first output vector, then Y is the second output vector; or,
[0100] If X is the absolute value of the first output vector, then Y is the absolute value of the second output vector; or,
[0101] If X is the first difference between each element in the first output vector and the mean of the first output vector, then Y is the second difference between each element in the second output vector and the mean of the second output vector; or,
[0102] If X is the absolute value of the first difference, then Y is the absolute value of the second difference.
[0103] Therefore, the quantization loss can be obtained by using the reference loss value of each moment and the attenuation factor corresponding to each moment. In other words, the sum of the reference loss values of multiple moments is used as the quantization loss, which makes the determined quantization loss more accurate and provides multiple methods for calculating the reference loss value.
[0104] S209: Determine the data boundary points based on the set of target sample data with the minimum corresponding quantization loss.
[0105] It should be noted that the smaller the quantization loss of the initial sample data, the more accurate the prediction results of the compressed model on the quantized sample data, meaning the quantization results of the initial sample data are better. Therefore, the data boundary point can be determined based on the set of target sample data with the minimum quantization loss.
[0106] Among them, the data demarcation point is used to segment and quantize the input data of the compressed model during the inference stage.
[0107] Optionally, the target sample data can be sorted from smallest to largest to obtain the second sorting result corresponding to the target sample data. Then, based on the data volume, the second sorting result can be evenly divided to obtain multiple second sets with the same data volume. Finally, the average value between the last element in the previous second set and the first element in the next second set is determined as a data boundary point.
[0108] For example, if the target sample data is "-3, -3, 8, -9, 12, 80, -30, 2, 2, 4, 1, 100", then the second sorting result is "-30, -9, -3, -3, 1, 2, 2, 4, 8, 12, 80, 100". If the data volume is 4, then the corresponding second set is {-30, -9, -3}, {-3, 1, 2}, {2, 4, 8}, {12, 80, 100}, and the corresponding data boundary points are -3, 2, 10.
[0109] It should be noted that the above examples are merely illustrative and should not be taken as specific limitations on the target sample data, data volume, etc. in the embodiments of this disclosure.
[0110] In this embodiment of the disclosure, by taking the average value between the last element in the previous second set and the first element in the next second set of each adjacent second set corresponding to the target sample data as a data boundary point, the data boundary point can be accurately determined, thereby improving the quantification accuracy of the model data.
[0111] S210: Based on the target data bit width, determine the second quantization parameter corresponding to the data between two adjacent data boundary points in each group, wherein the data between two adjacent data boundary points in the m-th group is greater than the value between two adjacent data boundary points in the n-th group, and the second quantization parameter corresponding to the data between two adjacent data boundary points in the m-th group is greater than the second quantization parameter corresponding to the data between two adjacent data boundary points in the n-th group, where m and n are different values.
[0112] In this context, the data between two adjacent data boundary points in each group corresponds to a second quantization parameter.
[0113] For example, if the data boundary points are -3, 2, 10, and the data volume is 4, with values of 0, 1, 2, 3 respectively, then the second quantization parameter corresponding to (-∞, -3) is 0, the second quantization parameter corresponding to (-3, 2) is 1, the second quantization parameter corresponding to (2, 10) is 2, and the second quantization parameter corresponding to (10, ∞) is 3.
[0114] It should be noted that the above examples are merely illustrative and should not be taken as specific limitations on data demarcation points, data volume, etc. in the embodiments of this disclosure.
[0115] It is understood that the model compression method provided in this disclosure can be applied to compression scenarios for any task model, such as compression of models for text classification, image recognition, speech recognition, etc., and this disclosure does not limit it.
[0116] The following is a brief explanation of the model compression process provided in this disclosure, using image recognition as an example.
[0117] First, a high-precision compressed model for image recognition is obtained after training. Then, the model parameters of the compressed model for image recognition are sorted in ascending order to obtain a first sorting result. Based on the amount of data contained in the data range corresponding to the target data bit width, the first sorting result is evenly divided to obtain multiple first sets with the same amount of data. The first quantization parameter corresponding to each first set is determined. Based on the first quantization parameter corresponding to each first set, the model parameters in each first set are quantized to obtain the compressed model for image recognition.
[0118] Next, multiple sets of initial sample data (such as image data) are acquired for training the image recognition model. Each set of image data is then quantized to obtain the quantized image data corresponding to each set. Based on each set of image data and the corresponding quantized sample data, the quantization loss corresponding to each set of image data is determined. Based on the target image data with the smallest corresponding quantization loss, each data boundary point is determined. Based on the target data bit width, the second quantization parameter corresponding to the data between two adjacent data boundary points in each set is determined.
[0119] In this embodiment of the disclosure, after generating the compressed model, multiple sets of initial sample data corresponding to the task type of the model to be compressed can be obtained; each set of initial sample data is quantized to obtain quantized sample data corresponding to each set of initial sample data; based on each set of initial sample data and the corresponding quantized sample data, the quantization loss corresponding to each set of initial sample data is determined; based on the target sample data with the smallest corresponding quantization loss, each data boundary point is determined; based on the target data bit width, the second quantization parameter corresponding to the data between two adjacent data boundary points in each group is determined. Thus, by determining the data boundary points based on the target sample data with the smallest quantization loss, and determining the second quantization parameter corresponding to the data between two adjacent data boundary points in each group, the compressed model can quantize the input data of the compressed model during inference based on the data boundary points and the second quantization parameter corresponding to the data between two adjacent data boundary points in each group, thereby improving the quantization accuracy of the input data of the compressed model and further reducing the computational loss of the compressed model.
[0120] Figure 3 This is a flowchart illustrating a data processing method according to yet another embodiment of the present disclosure;
[0121] like Figure 3 As shown, the model compression method includes:
[0122] S301: Obtain the data to be processed, the data boundary points associated with the preset model, and the second quantization parameter corresponding to the data between each pair of adjacent data boundary points.
[0123] In this process, the data to be processed is matched with the task of the prediction model. For example, if the task of the preset model is image recognition, then the data to be processed can be the image data to be recognized; if the task of the preset model is speech recognition, then the data to be processed can be the speech data to be recognized. This disclosure does not impose any limitations on this.
[0124] The data demarcation points are used to segment the data to be processed. The second quantization parameter corresponding to the data between two adjacent data demarcation points in each group is used to quantize the data to be processed between the two adjacent data demarcation points.
[0125] In this embodiment of the disclosure, the method for determining the data boundary point and the method for determining the second quantization parameter corresponding to the data between two adjacent data boundary points in each group can be referred to the detailed description of other embodiments in this disclosure, and will not be repeated here.
[0126] S302: Based on each data boundary point, divide the data to be processed to obtain the target data to be processed contained in each pair of adjacent data boundary points.
[0127] For example, if the data to be processed is "-3, -3, 7, -9, 12, 70, -30, 2, 3, 4, 1, 100", and the data boundary points are -3, 2, 10, then the target data to be processed contained in (-∞, -3] is "-30, -9, -3", the target data to be processed contained in (-3, 2] is "-3, 1, 2", the target data to be processed contained in (2, 10] is "3, 4, 7", and the target data to be processed contained in (10, ∞) is "12, 70, 100".
[0128] It should be noted that the above examples are merely illustrative and should not be taken as specific limitations on the data to be processed, data demarcation points, etc. in the embodiments of this disclosure.
[0129] S303: Based on the second quantization parameter corresponding to the data between two adjacent data boundary points in each group, quantize the target data to be processed contained in the two adjacent data boundary points in each group to obtain the target quantized data corresponding to the data to be processed.
[0130] For example, if the second quantization parameter corresponding to (-∞, -3] is 0, then the second quantization parameter corresponding to (-3, 2] is 1, then the second quantization parameter corresponding to (2, 10) is 2, and then the second quantization parameter corresponding to (10, ∞) is 3; the target data to be processed contained in (-∞, -3] is "-30, -9, -3", the target data to be processed contained in (-3, 2] is "-3, 1, 2", the target data to be processed contained in (2, 10) is "3, 4, 7", and the target data to be processed contained in (10, ∞) is "12, 70, 100"; then the second quantization parameter corresponding to "-30, -9, -3" is 0, the second quantization parameter corresponding to "-3, 1, 2" is 1, the second quantization parameter corresponding to "-3, 1, 2" is 2, and the second quantization parameter corresponding to "12, 70, 100" is 3.
[0131] It should be noted that the above examples are merely illustrative and should not be taken as specific limitations on the second quantization parameters, etc., corresponding to the data between two adjacent data boundary points in each group in this disclosure embodiment.
[0132] S304: Input the target quantized data into the preset model to obtain the prediction result corresponding to the data to be processed, wherein the preset model is generated based on the model compression method.
[0133] In this embodiment of the disclosure, after determining the target quantized data corresponding to the data to be processed, the target quantized data can be input into a preset model to obtain the prediction result corresponding to the data to be processed, thereby...
[0134] It is understood that the data processing methods provided in this disclosure can be applied to data processing methods such as text classification models, image recognition models, and speech recognition models, and this disclosure does not limit them.
[0135] The following is a brief explanation of the data processing procedure provided in this disclosure, using image recognition as an example.
[0136] First, the compressed model for image recognition, the data boundary points associated with the model, and the second quantization parameters corresponding to the data between each pair of adjacent data boundary points are obtained. Then, the data to be recognized is obtained. Based on each data boundary point, the image to be recognized is divided to obtain the target data to be recognized contained within each pair of adjacent data boundary points. Based on the second quantization parameters corresponding to the data between each pair of adjacent data boundary points, the target data to be recognized contained within each pair of adjacent data boundary points is quantized to obtain the target quantized data corresponding to the data to be recognized. Finally, the target quantized data is input into the model for image recognition to obtain the image recognition result corresponding to the data to be recognized.
[0137] In this embodiment, the data to be processed, the data boundary points associated with a preset model, and the second quantization parameters corresponding to the data between each pair of adjacent data boundary points are first obtained. Then, based on each data boundary point, the data to be processed is divided to obtain the target data to be processed contained within each pair of adjacent data boundary points. Based on the second quantization parameters corresponding to the data between each pair of adjacent data boundary points, the target data to be processed contained within each pair of adjacent data boundary points is quantized to obtain the target quantized data corresponding to the data to be processed. Finally, the target quantized data is input into the preset model to obtain the prediction result corresponding to the data to be processed. Therefore, by quantizing the data to be processed based on the determined data boundary points and the second quantization parameters corresponding to the data between each pair of adjacent data boundary points, and using the preset model to predict the quantized data to be processed, the data to be processed can be accurately quantized, improving the calculation speed of the preset model while ensuring the accuracy of the prediction results.
[0138] Figure 4 This is a schematic diagram of a model compression device according to an embodiment of the present disclosure;
[0139] like Figure 4 As shown, the model compression device 400 includes:
[0140] The first acquisition module 410 is used to acquire each model parameter in the model to be compressed and the target data bit width corresponding to the model parameter;
[0141] The second acquisition module 420 is used to sort the various model parameters in ascending order to obtain the first sorting result;
[0142] The third acquisition module 430 is used to uniformly divide the first sorting result based on the amount of data contained in the data range corresponding to the target data bit width, so as to obtain multiple first sets with the same amount of data.
[0143] The first determining module 440 is used to determine the first quantization parameter corresponding to each first set, wherein the model parameters contained in the first set i are greater than the model parameters contained in the first set j, and the first quantization parameter corresponding to the first set i is greater than the first quantization parameter corresponding to the first set j, and i and j are different values;
[0144] The fourth acquisition module 450 is used to quantize the model parameters in each first set based on the first quantization parameter corresponding to each first set, so as to obtain the compressed model.
[0145] In some embodiments of this disclosure, it also includes:
[0146] The fifth acquisition module is used to acquire multiple sets of initial sample data corresponding to the task type of the model to be compressed;
[0147] The sixth acquisition module is used to quantize each set of initial sample data to obtain the quantized sample data corresponding to each set of initial sample data.
[0148] The second determining module is used to determine the quantization loss corresponding to each set of initial sample data based on each set of initial sample data and the corresponding quantized sample data.
[0149] The third determination module is used to determine the data boundary points based on the set of target sample data with the minimum corresponding quantization loss.
[0150] The fourth determining module is used to determine the second quantization parameter corresponding to the data between two adjacent data boundary points in each group based on the target data bit width. The data between two adjacent data boundary points in the m-th group is greater than the data between two adjacent data boundary points in the n-th group, and the second quantization parameter corresponding to the data between two adjacent data boundary points in the m-th group is greater than the second quantization parameter corresponding to the data between two adjacent data boundary points in the n-th group. m and n are different values.
[0151] In some embodiments of this disclosure, the third determining module is specifically used for:
[0152] Sort the target sample data in ascending order to obtain the second sorting result corresponding to the target sample data;
[0153] Based on the amount of data, the second sorting result is divided evenly to obtain multiple second sets with the same amount of data;
[0154] The average value between the last element in the previous second set and the first element in the next second set is used as a data boundary point.
[0155] In some embodiments of this disclosure, it is specifically used for:
[0156] Each set of initial sample data is input into the model to be compressed to obtain the first output vector corresponding to each set of initial sample data;
[0157] Each set of quantized sample data is input into the compressed model to obtain the second output vector corresponding to each set of quantized sample data.
[0158] Based on the loss function and the first and second output vectors corresponding to each set of initial sample data, the quantization loss corresponding to each set of initial sample data is determined.
[0159] In some embodiments of this disclosure, the second determining module is further specifically used for:
[0160] Based on the first and second output vectors corresponding to each set of initial sample data, determine each reference loss value;
[0161] Based on each reference loss value and each preset attenuation factor, determine the quantization loss corresponding to each set of initial sample data.
[0162] In some embodiments of this disclosure, the reference loss values are any of the following:
[0163] The variances of the first output vector and the second output vector;
[0164] The variances of the absolute values of the first and second output vectors;
[0165] The various exponents of the differences between the first difference corresponding to the first output vector and the second difference corresponding to the second output vector; and
[0166] The variances of each power between the absolute value of the first difference and the absolute value of the second difference;
[0167] The first difference is the difference between each element in the first output vector and the mean of the first output vector, and the second difference is the difference between each element in the second output vector and the mean of the second output vector.
[0168] It should be noted that the foregoing explanation of the model compression method also applies to the model compression device of this embodiment, and will not be repeated here.
[0169] In this embodiment, the model parameters and their corresponding target data bit widths in the model to be compressed are first obtained. The model parameters are then sorted from smallest to largest to obtain a first sorting result. Next, based on the amount of data contained within the data range corresponding to the target data bit width, the first sorting result is evenly divided to obtain multiple first sets with the same amount of data. A first quantization parameter is determined for each first set. Finally, based on the first quantization parameter for each first set, the model parameters in each first set are quantized to obtain the compressed model. Therefore, by evenly dividing the model parameters from smallest to largest into first sets with the same amount of data as the target data bit width, and assigning a first quantization parameter to each first set, the model parameters can be evenly quantized based on the number of model parameters in each set, improving quantization accuracy. This reduces the computational loss of the compressed model, lowers the computational resources and storage space occupied by the compressed model, and improves the computational speed and efficiency of the compressed model.
[0170] Figure 5 This is a schematic diagram of the structure of a data processing apparatus according to an embodiment of the present disclosure;
[0171] like Figure 5 As shown, the data processing device 500 includes:
[0172] The first acquisition module 510 is used to acquire the data to be processed, the data boundary points associated with the preset model, and the second quantization parameters corresponding to the data between each pair of adjacent data boundary points.
[0173] The second acquisition module 520 is used to divide the data to be processed based on each data boundary point, so as to obtain the target data to be processed contained in each group of two adjacent data boundary points.
[0174] The third acquisition module 530 is used to quantize the target data to be processed contained in each group of two adjacent data boundary points based on the second quantization parameter corresponding to the data between each group of two adjacent data boundary points, so as to obtain the target quantized data corresponding to the data to be processed.
[0175] The fourth acquisition module 540 is used to input the target quantized data into a preset model to obtain the prediction result corresponding to the data to be processed, wherein the preset model is generated based on the model compression device.
[0176] It should be noted that the foregoing explanation of the model compression method also applies to the model compression device of this embodiment, and will not be repeated here.
[0177] In this embodiment, the data to be processed, the data boundary points associated with a preset model, and the second quantization parameters corresponding to the data between each pair of adjacent data boundary points are first obtained. Then, based on each data boundary point, the data to be processed is divided to obtain the target data to be processed contained within each pair of adjacent data boundary points. Based on the second quantization parameters corresponding to the data between each pair of adjacent data boundary points, the target data to be processed contained within each pair of adjacent data boundary points is quantized to obtain the target quantized data corresponding to the data to be processed. Finally, the target quantized data is input into the preset model to obtain the prediction result corresponding to the data to be processed. Therefore, by quantizing the data to be processed based on the determined data boundary points and the second quantization parameters corresponding to the data between each pair of adjacent data boundary points, and using the preset model to predict the quantized data to be processed, the data to be processed can be accurately quantized, improving the calculation speed of the preset model while ensuring the accuracy of the prediction results.
[0178] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0179] Figure 6A schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0180] like Figure 6 As shown, device 600 includes a computing unit 601, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 602 or a computer program loaded from storage unit 608 into random access memory (RAM) 603. RAM 603 may also store various programs and data required for the operation of device 600. The computing unit 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0181] Multiple components in device 600 are connected to I / O interface 605, including: input unit 606, such as keyboard, mouse, etc.; output unit 607, such as various types of monitors, speakers, etc.; storage unit 608, such as disk, optical disk, etc.; and communication unit 609, such as network card, modem, wireless transceiver, etc. Communication unit 609 allows device 600 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0182] The computing unit 601 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as model compression methods or data processing methods. For example, in some embodiments, the model compression method or data processing method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on device 600 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 603 and executed by the computing unit 601, one or more steps of the model compression method or data processing method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform a model compression method or a data processing method by any other suitable means (e.g., by means of firmware).
[0183] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0184] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0185] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0186] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0187] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), the Internet, and blockchain networks.
[0188] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. A server can be a cloud server, also known as a cloud computing server or cloud host, a hosting product within the cloud computing service ecosystem, addressing the shortcomings of traditional physical hosts and VPS (Virtual Private Server, or simply "VPS") services, such as high management difficulty and weak business scalability. Servers can also be servers for distributed systems or servers incorporating blockchain technology.
[0189] In this embodiment, the model parameters and their corresponding target data bit widths in the model to be compressed are first obtained. The model parameters are then sorted from smallest to largest to obtain a first sorting result. Next, based on the amount of data contained within the data range corresponding to the target data bit width, the first sorting result is evenly divided to obtain multiple first sets with the same amount of data. A first quantization parameter is determined for each first set. Finally, based on the first quantization parameter for each first set, the model parameters in each first set are quantized to obtain the compressed model. Thus, by evenly dividing the model parameters from smallest to largest into first sets with the same amount of data as the target data bit width, and assigning a first quantization parameter to each first set, the model parameters can be evenly quantized based on the number of model parameters in each set, improving quantization accuracy. This reduces the computational loss of the compressed model, lowers the computational resources and storage space occupied by the compressed model, and improves the computational speed and efficiency of the compressed model.
[0190] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0191] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this disclosure, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified. In the description of this disclosure, the words "if" and "suppose" as used may be interpreted as "when," "when," "in response to determination," or "in the circumstances."
[0192] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A model compression method, comprising: Obtain each model parameter in the model to be compressed and the target data bit width corresponding to the model parameter; The model parameters are sorted in ascending order to obtain the first sorting result; Based on the amount of data contained within the data range corresponding to the target data bit width, the first sorting result is evenly divided to obtain multiple first sets with the same amount of data. Determine the first quantization parameter corresponding to each of the first sets, wherein the model parameters contained in the first set i are greater than the model parameters contained in the first set j, and the first quantization parameter corresponding to the first set i is greater than the first quantization parameter corresponding to the first set j, and i and j are different values; Based on the first quantization parameter corresponding to each first set, the model parameters in each first set are quantized to obtain the compressed model; The method further includes: Obtain multiple sets of initial sample data corresponding to the task type of the model to be compressed, wherein the task type of the model to be compressed is any one of the following: image classification, object detection, image segmentation, speech recognition, machine translation; Each set of initial sample data is quantized to obtain quantized sample data corresponding to each set of initial sample data. Based on each set of initial sample data and the corresponding quantized sample data, determine the quantization loss corresponding to each set of initial sample data; Determine the data boundary points based on the set of target sample data with the minimum corresponding quantization loss; Based on the target data bit width, a second quantization parameter is determined for the data between two adjacent data boundary points in each group. The data between two adjacent data boundary points in the m-th group is greater than the data between two adjacent data boundary points in the n-th group, and the second quantization parameter corresponding to the data between two adjacent data boundary points in the m-th group is greater than the second quantization parameter corresponding to the data between two adjacent data boundary points in the n-th group. m and n are different values.
2. The method according to claim 1, wherein, The step of determining each data boundary point based on the set of target sample data with the minimum corresponding quantization loss includes: The target sample data is sorted in ascending order to obtain the second sorting result corresponding to the target sample data; Based on the data volume, the second sorting result is evenly divided to obtain multiple second sets with the same data volume; The average value between the last element in the previous second set and the first element in the next second set is used as a data boundary point.
3. The method according to claim 1, wherein, The step of determining the quantization loss corresponding to each set of initial sample data based on each set of initial sample data and the corresponding quantized sample data includes: Each set of initial sample data is input into the model to be compressed to obtain the first output vector corresponding to each set of initial sample data; Each set of quantized sample data is input into the compressed model to obtain the second output vector corresponding to each set of quantized sample data; Based on the loss function and the first and second output vectors corresponding to each set of initial sample data, the quantization loss corresponding to each set of initial sample data is determined.
4. The method according to claim 3, wherein, The determination of the quantization loss for each set of initial sample data based on the loss function and the first and second output vectors corresponding to each set of initial sample data includes: Based on the first output vector and the second output vector corresponding to each set of initial sample data, determine each reference loss value; Based on the reference loss values and the preset attenuation factors, the quantization loss corresponding to each set of initial sample data is determined.
5. The method according to claim 4, wherein, The reference loss values are any one of the following: The differences between the first output vector and the second output vector at each power; The differences between the absolute values of the first output vector and the absolute values of the second output vector, raised to various powers; The differences between the first difference corresponding to the first output vector and the second difference corresponding to the second output vector, and the differences between each power of the first difference; and The differences between the absolute values of the first difference and the absolute values of the second difference, raised to the power of each other; Wherein, the first difference is the difference between each element in the first output vector and the mean of the first output vector, and the second difference is the difference between each element in the second output vector and the mean of the second output vector.
6. A data processing method, comprising: Obtain the data to be processed, the data boundary points associated with the preset model, and the second quantization parameters corresponding to the data between each pair of adjacent data boundary points; Based on the data demarcation points, the data to be processed is divided to obtain the target data to be processed contained in each pair of adjacent data demarcation points. Based on the second quantization parameter corresponding to the data between two adjacent data boundary points in each group, the target data to be processed contained in the two adjacent data boundary points in each group is quantized to obtain the target quantized data corresponding to the data to be processed. The target quantized data is input into the preset model to obtain the prediction result corresponding to the data to be processed, wherein the preset model is generated based on the method described in any one of claims 1-5.
7. A model compression device, comprising: The first acquisition module is used to acquire each model parameter in the model to be compressed and the target data bit width corresponding to the model parameter; The second acquisition module is used to sort the various model parameters in ascending order to obtain the first sorting result; The third acquisition module is used to uniformly divide the first sorting result based on the amount of data contained in the data range corresponding to the target data bit width, so as to obtain multiple first sets with the same amount of data. The first determining module is used to determine the first quantization parameter corresponding to each of the first sets, wherein the model parameters contained in the first set i are greater than the model parameters contained in the first set j, and the first quantization parameter corresponding to the first set i is greater than the first quantization parameter corresponding to the first set j, and i and j are different values; The fourth acquisition module is used to quantize the model parameters in each of the first sets based on the first quantization parameters corresponding to each of the first sets, so as to obtain the compressed model; The device further includes: The fifth acquisition module is used to acquire multiple sets of initial sample data corresponding to the task type of the model to be compressed, wherein the task type of the model to be compressed is any one of the following: image classification, object detection, image segmentation, speech recognition, or machine translation; The sixth acquisition module is used to quantize each set of initial sample data to obtain quantized sample data corresponding to each set of initial sample data. The second determining module is used to determine the quantization loss corresponding to each set of initial sample data based on each set of initial sample data and the corresponding quantized sample data. The third determination module is used to determine the data boundary points based on the set of target sample data with the minimum corresponding quantization loss. The fourth determining module is used to determine the second quantization parameter corresponding to the data between two adjacent data boundary points in each group based on the target data bit width, wherein the data between two adjacent data boundary points in the m-th group is greater than the data between two adjacent data boundary points in the n-th group, and the second quantization parameter corresponding to the data between two adjacent data boundary points in the m-th group is greater than the second quantization parameter corresponding to the data between two adjacent data boundary points in the n-th group, where m and n are different values.
8. The apparatus according to claim 7, wherein, The third determining module is specifically used for: The target sample data is sorted in ascending order to obtain the second sorting result corresponding to the target sample data; Based on the data volume, the second sorting result is evenly divided to obtain multiple second sets with the same data volume; The average value between the last element in the previous second set and the first element in the next second set is used as a data boundary point.
9. The apparatus according to claim 7, wherein, The second determining module is specifically used for: Each set of initial sample data is input into the model to be compressed to obtain the first output vector corresponding to each set of initial sample data; Each set of quantized sample data is input into the compressed model to obtain the second output vector corresponding to each set of quantized sample data; Based on the loss function and the first and second output vectors corresponding to each set of initial sample data, the quantization loss corresponding to each set of initial sample data is determined.
10. The apparatus according to claim 9, wherein, The second determining module is further specifically used for: Based on the first output vector and the second output vector corresponding to each set of initial sample data, determine each reference loss value; Based on the reference loss values and the preset attenuation factors, the quantization loss corresponding to each set of initial sample data is determined.
11. The apparatus according to claim 10, wherein, The reference loss values are any one of the following: The differences between the first output vector and the second output vector at each power; The differences between the absolute values of the first output vector and the absolute values of the second output vector, raised to various powers; The differences between the first difference corresponding to the first output vector and the second difference corresponding to the second output vector, and the differences between each power of the first difference; and The differences between the absolute values of the first difference and the absolute values of the second difference, raised to the power of each other; Wherein, the first difference is the difference between each element in the first output vector and the mean of the first output vector, and the second difference is the difference between each element in the second output vector and the mean of the second output vector.
12. A data processing apparatus, comprising: The first acquisition module is used to acquire the data to be processed, the data boundary points associated with the preset model, and the second quantization parameters corresponding to the data between each pair of adjacent data boundary points. The second acquisition module is used to divide the data to be processed based on the data boundary points to obtain the target data to be processed contained in each pair of adjacent data boundary points. The third acquisition module is used to quantize the target data to be processed contained in each group of two adjacent data boundary points based on the second quantization parameter corresponding to the data between each group of two adjacent data boundary points, so as to obtain the target quantized data corresponding to the data to be processed. The third acquisition module is used to input the target quantized data into the preset model to obtain the prediction result corresponding to the data to be processed, wherein the preset model is generated based on the device as described in any one of claims 7-11.
13. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the method of any one of claims 1-5, or to perform the method of claim 6.
14. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method of any one of claims 1-5, or to perform the method of claim 6.
15. A computer program product comprising computer instructions that, when executed by a processor, implement the steps of the method of any one of claims 1-5, or the steps of the method of claim 6.
Citation Information
Patent Citations
Data processing method in neural network system and neural network system
CN112215331A
Method and device for optimizing neural network
US20180373981A1