A data processing method, device and storage medium
By utilizing the combined processing of the target layer target parameter value, compression ratio and sparsification rate during the model cropping and compression process, and adopting progressive dynamic adjustment, the problem of long time-consuming model cropping and compression process is solved and efficient cropping and compression is achieved. Effect.
Patent Information
- Application Number
- CN202110240689.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-04
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2041-03-04
AI Technical Summary
The existing model cropping and compression process takes a long time, resulting in low cropping efficiency, and it is difficult to quickly obtain a cropped and compressed model with excellent accuracy and compression ratio.
By determining the target parameter values of the target layer in the neural network model to be trimmed, combined with the compression ratio and sparsification rate, the model is sparsely trimmed, and a progressive dynamic adjustment method is used to gradually optimize the parameter values until the target compression ratio is reached, improving Model cutting efficiency.
It is possible to quickly obtain a cropping compression model with better cropping accuracy, which significantly improves the model cropping efficiency and reduces the time consumption in the sparse processing process.
Smart Images

Figure CN113112014B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of intelligent technology, and in particular to a data processing method, device and storage medium. Background Art
[0002] With the rapid development of artificial intelligence applications, deep learning has been widely studied. As the neural network model obtained through deep learning becomes more and more complex, it requires a large amount of storage space and consumes a lot of computing resources, making it difficult to implement on various hardware platforms. In order to ensure that the obtained neural network model can be implemented on various hardware platforms, a method for pruning and compressing the obtained neural network model is proposed. The method for model pruning and compression is specifically to perform a sparse operation on all weight coefficients in the neural network model, obtain the actual test effect of the pruned model, and feedback the actual test effect, so as to repeat the sparse training, and finally obtain a compressed neural network model that meets the requirements.
[0003] However, the entire pruning and compression process of the above-mentioned model pruning and compression method is relatively time-consuming, resulting in the inability to quickly obtain a pruning and compressed neural network model with relatively good accuracy and compression ratio, making the pruning and compression efficiency low.
[0004] Application Contents
[0005] In order to solve the above-mentioned technical problems, the embodiments of the present application hope to provide a data processing method, device and storage medium, which solves the problem that the current model cropping and compression process is time-consuming, and realizes a technical solution for quickly obtaining a cropping and compression model with higher cropping accuracy, thereby effectively improving the model cropping efficiency.
[0006] The technical solution of this application is implemented as follows:
[0007] In a first aspect, a data processing method is provided, the method comprising:
[0008] Determine at least one first parameter value corresponding to a target parameter of a target layer in the neural network model to be pruned;
[0009] Determine compression ratio and sparsification ratio;
[0010] Based on the compression ratio, the sparsification rate and the at least one first parameter value, the to-be-cut neural network model is subjected to a sparsification and cutting process to obtain a target neural network model;
[0011] The data to be cropped is subjected to sparse cropping processing based on the target neural network model.
[0012] Optionally, the performing a sparse pruning process on the neural network model to be pruned based on the compression ratio, the sparse rate and the at least one first parameter value to obtain a target neural network model includes:
[0013] Based on the compression ratio, the at least one first parameter value is grouped to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed; wherein each of the first parameter values to be analyzed is smaller than each of the second parameter values to be analyzed;
[0014] Based on the sparsification rate, adjusting the at least one first parameter value to be analyzed and the at least one second parameter value to be analyzed respectively, to obtain at least one first target parameter value and at least one second target parameter value in sequence;
[0015] Each of the first target parameter values is used to replace the corresponding first parameter value to be analyzed in the neural network model to be trimmed, and each of the second target parameter values is used to replace the corresponding second parameter value to be analyzed in the neural network model to be trimmed, so as to obtain the target neural network model.
[0016] Optionally, the grouping processing of the at least one first parameter value based on the compression ratio to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed includes:
[0017] Determine a first compression reference ratio and a preset step value; wherein the first compression reference ratio is associated with the compression ratio, and the first compression reference ratio is less than or equal to the compression ratio;
[0018] Based on the first compression reference ratio, grouping the at least one first parameter value to obtain at least one third parameter value to be analyzed and at least one fourth parameter value to be analyzed;
[0019] Based on the thinning rate, adjusting the at least one third parameter value to be analyzed and the at least one fourth parameter value to be analyzed respectively, to obtain at least one first reference parameter value and at least one second reference parameter value in sequence;
[0020] Using each of the first reference parameter values to replace the corresponding first parameter value to be analyzed in the neural network model to be trimmed, and using each of the second reference parameter values to replace the corresponding second parameter value to be analyzed in the neural network model to be trimmed, to obtain a first reference neural network model;
[0021] Obtain at least one second parameter value corresponding to the target parameter of the target layer in the first reference neural network model;
[0022] Determine a sum of the first compression reference ratio and the preset step value to obtain a second compression reference ratio;
[0023] If the second compression reference ratio is equal to the compression ratio, the at least one second parameter value is grouped based on the compression ratio to obtain the at least one first parameter value to be analyzed and the at least one second parameter value to be analyzed.
[0024] Optionally, the method further includes:
[0025] If the second compression reference ratio is less than the compression ratio, grouping the at least one second parameter value based on the second compression reference ratio to obtain at least one fifth parameter value to be analyzed and at least one sixth parameter value to be analyzed; wherein each of the fifth parameter values to be analyzed is less than each of the sixth parameter values to be analyzed;
[0026] Based on the thinning rate, adjusting the at least one fifth parameter value to be analyzed and the at least one sixth parameter value to be analyzed respectively, to obtain at least one third reference parameter value and at least one fourth reference parameter value in sequence;
[0027] Using each of the third reference parameter values to replace the corresponding fifth parameter value to be analyzed in the first reference neural network model, and each of the fourth reference parameter values to replace the corresponding sixth parameter value to be analyzed in the first reference neural network model, to obtain a second reference neural network model;
[0028] Obtain at least one third parameter value corresponding to the target parameter of the target layer in the second reference neural network model;
[0029] Determine a sum of the second compression reference ratio and the preset step value to obtain a third compression reference ratio;
[0030] If the third compression reference ratio is less than the compression ratio, the at least one third parameter value is grouped based on the third compression reference ratio, and this is repeated until the sum of the fourth compression reference ratio and the preset step value is the compression ratio, then based on the compression ratio, at least one fourth parameter value corresponding to the target parameter of the target layer in the third reference neural network model is grouped to obtain the at least one first parameter value to be analyzed and the at least one second parameter value to be analyzed; wherein the third reference neural network model is a neural network model obtained based on the fourth compression reference ratio and has an associated relationship with the neural network model to be trimmed.
[0031] Optionally, adjusting at least one of the first parameter value to be analyzed and at least one of the second parameter value to be analyzed respectively based on the sparsification rate to obtain at least one first target parameter value and at least one second target parameter value in sequence includes:
[0032] Based on at least one of the first parameter values to be analyzed, the thinning rate and a first preset value, adjusting each of the first parameter values to be analyzed to obtain at least one of the first target parameter values; wherein the first preset value is less than or equal to 0;
[0033] Based on the thinning rate and the second preset value, each of the second parameter values to be analyzed is adjusted to obtain at least one second target parameter value; wherein the second preset value is greater than or equal to 0.
[0034] Optionally, adjusting each of the first parameter values to be analyzed based on at least one of the first parameter values to be analyzed, the thinning rate, and a first preset value to obtain at least one of the first target parameter values includes:
[0035] Sort at least one of the first parameter values to be analyzed in ascending order to obtain a target arrangement order of at least one of the first parameter values to be analyzed;
[0036] Determining a sorting sequence number of each of the first parameter values to be analyzed from the target arrangement sequence;
[0037] Determine the product of the sorting sequence number of each of the first parameter values to be analyzed, the thinning rate and the first preset value to obtain a first value;
[0038] The sum of the first numerical value and each of the first parameter values to be analyzed is determined to obtain at least one of the first target parameter values.
[0039] Optionally, adjusting each of the second parameter values to be analyzed based on the thinning rate and the second preset value to obtain at least one second target parameter value includes:
[0040] Determine the product of the thinning rate and the second preset value to obtain a second value;
[0041] The sum of the second numerical value and each of the second parameter values to be analyzed is determined to obtain at least one second target parameter value.
[0042] Optionally, the target layer is at least one specific neural network layer in the neural network model to be pruned.
[0043] In a second aspect, an electronic device includes: a processor, a memory, and a communication bus; wherein:
[0044] The memory is used to store executable instructions;
[0045] The communication bus is used to realize the communication connection between the processor and the memory;
[0046] The processor is used to execute the data processing program stored in the memory to implement the following steps:
[0047] Determine at least one first parameter value corresponding to a target parameter of a target layer in the neural network model to be pruned;
[0048] Determine compression ratio and sparsification ratio;
[0049] Based on the compression ratio, the sparsification rate and the at least one first parameter value, the to-be-cut neural network model is subjected to a sparsification and cutting process to obtain a target neural network model;
[0050] The data to be cropped is subjected to sparse cropping processing based on the target neural network model.
[0051] In a third aspect, a storage medium is provided, wherein a data processing program is stored on the storage medium, and when the data processing program is executed by a processor, the steps of the data processing method as described in any one of the above items are implemented.
[0052] The embodiment of the present application provides a data processing method, device and storage medium. After determining at least one first parameter value corresponding to the target parameter of the target layer in the neural network model to be pruned, the compression ratio and the sparsification rate are determined, and then based on the compression ratio, the sparsification rate and the at least one first parameter value, the neural network model to be pruned is subjected to sparsification and pruning processing to obtain the target neural network model, and finally the data to be pruned is subjected to sparsification and pruning processing based on the target neural network model. In this way, at least one first parameter value corresponding to the target parameter of the target layer in the neural network model to be pruned is subjected to sparsification and pruning processing by using the compression ratio and the sparsification rate to obtain the target neural network model, which solves the problem that the pruning and compression process is relatively time-consuming in the current model pruning and compression process, realizes a technical solution for quickly obtaining a pruned and compressed model with better pruning accuracy, and effectively improves the efficiency of model pruning. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 A flowchart of a data processing method provided in an embodiment of the present application;
[0054] Figure 2 A flowchart of another data processing method provided in an embodiment of the present application;
[0055] Figure 3A flowchart of another data processing method provided in an embodiment of the present application;
[0056] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0058] The embodiment of the present application provides a data processing method, referring to Figure 1 As shown, the method is applied to an electronic device, and the method comprises the following steps:
[0059] Step 101: Determine at least one first parameter value corresponding to a target parameter of a target layer in a neural network model to be pruned.
[0060] In an embodiment of the present application, the neural network model to be pruned is a trained neural network model that needs to be sparsely pruned during the process of model compression using a neural network model. The target layer may be one or more layers included in the input layer, the output layer, and / or the hidden layer, such as a batch normalization (BN) layer in the hidden layer or a convolution layer before the BN layer. The target parameter may be a parameter determined through historical experience, such as a gamma (Gamma or γ) parameter in the BN layer, or other parameters in the convolution layer before the BN layer that have an associated relationship with the γ parameter. Since the neural network model to be pruned is a trained neural network model, the values corresponding to the target parameters in its target layer are known, and therefore, at least one first parameter value corresponding to the target parameter of the target layer may be determined.
[0061] Step 102: Determine the compression ratio and the sparsification ratio.
[0062] In an embodiment of the present application, the sparsification rate may be a sparsification processing experience value preset by the user for the data to be cropped, and similarly, the compression ratio may also be a compression experience value preset by the user for the data after the sparsification processing to be compressed. However, in some application scenarios, the sparsification rate and the compression ratio may also be calculated based on the hardware resources of the neural network model to be cropped and the hardware devices running the neural network model to be cropped, such as the computing power and storage capacity of the electronic device. The computing power of the electronic device may be, for example, the central processing unit (CPU) resources of the electronic device, and the corresponding storage capacity of the electronic device may be, for example, the memory usage, or the graphics processing unit (GPU) resources of the electronic device, and the corresponding storage capacity of the electronic device may be, for example, the video memory usage.
[0063] Step 103: Based on the compression ratio, the sparsification rate and at least one first parameter value, the neural network model to be pruned is subjected to sparse pruning processing to obtain a target neural network model.
[0064] In an embodiment of the present application, at least one first parameter value is adjusted using a compression ratio and a sparsification rate to determine a target neural network model that satisfies the sparsification rate.
[0065] Step 104: Perform sparse cropping on the data to be cropped based on the target neural network model.
[0066] In the embodiment of the present application, after obtaining the target neural network model, the data to be pruned can be subjected to sparse pruning, which can ensure that the data obtained after sparse pruning meets the sparseness ratio. In some other application scenarios, after obtaining the target neural network model, the target neural network model can be further subjected to model compression processing to obtain a compressed deployment model, so that the compressed deployment model can both perform sparse processing and compression processing on the data to be processed.
[0067] A data processing method provided by an embodiment of the present application determines a compression ratio and a sparsification rate after determining at least one first parameter value corresponding to a target parameter of a target layer in a neural network model to be pruned, and then performs sparsification pruning processing on the neural network model to be pruned based on the compression ratio, the sparsification rate and the at least one first parameter value to obtain a target neural network model, and finally performs sparsification pruning processing on the data to be pruned based on the target neural network model. In this way, at least one first parameter value corresponding to a target parameter of a target layer in a neural network model to be pruned is subjected to sparsification pruning processing by using a compression ratio and a sparsification rate to obtain a target neural network model, thereby solving the problem that the pruning and compression process is relatively time-consuming in the current model pruning and compression process, and realizing a technical solution for quickly obtaining a pruned and compressed model with better pruning accuracy, thereby effectively improving the efficiency of model pruning.
[0068] Based on the above embodiments, the embodiments of the present application provide a data processing method, referring to Figure 2 As shown, the method is applied to an electronic device, and the method comprises the following steps:
[0069] Step 201: Determine at least one first parameter value corresponding to a target parameter of a target layer in a neural network model to be pruned.
[0070] The target layer is at least one specific neural network layer in the neural network model to be pruned.
[0071] In the embodiment of the present application, taking the target layer as the BN layer in the neural network model to be pruned and the target parameter as the Gamma parameter as an example, the target parameter of the target layer in the neural network model to be pruned includes 8 first parameter values, which are G1=2.11, G2=1.90, G3=0.9, G4=0.21, G5=0.84, G6=0.25, G7=1.12, and G8=0.08 respectively.
[0072] Step 202: Determine the compression ratio and the sparsification ratio.
[0073] In an embodiment of the present application, the electronic device receives a compression ratio and a thinning ratio input by a user, and determines the compression ratio and the thinning ratio. For example, the determined compression ratio is 40%, and the thinning ratio is 0.01.
[0074] Step 203: Based on the compression ratio, group at least one first parameter value to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed.
[0075] Each first parameter value to be analyzed is smaller than each second parameter value to be analyzed.
[0076] In an embodiment of the present application, in one embodiment, at least one first parameter value can be directly grouped based on the compression ratio, and the process includes: counting the first number of at least one first parameter value, calculating the first product value of the compression ratio and the first number, and rounding the first product value to obtain a third value, determining the minimum value of the third value in at least one first parameter value, obtaining at least one first parameter value to be analyzed, and determining the value of at least one first parameter value other than at least one first parameter value to be analyzed as at least one second parameter value to be analyzed. In another embodiment, at least one first parameter value can also be grouped step by step in a progressive dynamic adjustment manner to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed.
[0077] Step 204: Based on the sparsification rate, adjust at least one first parameter value to be analyzed and at least one second parameter value to be analyzed respectively, and obtain at least one first target parameter value and at least one second target parameter value in sequence.
[0078] In an embodiment of the present application, based on the sparsification rate, at least one first parameter value to be analyzed is negatively adjusted so that the at least one first parameter value to be analyzed becomes smaller and smaller and closer to zero. In this way, it can comply with the idea of setting certain weight coefficients to zero when performing sparsification processing on a trained neural network model; based on the sparsification rate, at least one second parameter value to be analyzed is positively adjusted so that the at least one second parameter value to be analyzed becomes larger and larger. In this way, the obtained at least one first target parameter value and at least one second target parameter value become more and more differentiated.
[0079] Step 205: Use each first target parameter value to replace the corresponding first parameter value to be analyzed in the neural network model to be trimmed, and use each second target parameter value to replace the corresponding second parameter value to be analyzed in the neural network model to be trimmed, so as to obtain the target neural network model.
[0080] In an embodiment of the present application, the target neural network model can be obtained by respectively substituting the determined at least one first target parameter value and at least one second target parameter value into the neural network model to be trimmed.
[0081] Step 206: Perform sparse cropping on the data to be cropped based on the target neural network model.
[0082] In an embodiment of the present application, after obtaining the target neural network model, the target neural network model can be used to perform sparse cropping processing on the data to be cropped.
[0083] Based on the above embodiments, in other embodiments of the present application, step 203 can be implemented by steps 203a to 203m:
[0084] Step 203a: Determine a first compression reference ratio and a preset step value.
[0085] The first compression reference ratio is associated with the compression ratio, and the first compression reference ratio is less than or equal to the compression ratio.
[0086] In the embodiment of the present application, when the first compression reference ratio is equal to the compression ratio, at least one first parameter value is grouped by the compression ratio, wherein the preset step value is zero. When the first compression reference ratio is less than the compression ratio, a progressive dynamic adjustment is performed.
[0087] Exemplarily, when the compression ratio is 40%, assuming that the first compression ratio is 10%, the preset step value is 5%.
[0088] Step 203b: Based on the first compression reference ratio, group at least one first parameter value to obtain at least one third parameter value to be analyzed and at least one fourth parameter value to be analyzed.
[0089] In the embodiment of the present application, since the number of at least one first parameter value is 8, it can be determined that the product of the first compression reference ratio and the number of at least one first parameter value is 0.8, so it is rounded to 1, and correspondingly, it is determined that the minimum value among G1=2.11, G2=1.90, G3=0.9, G4=0.21, G5=0.84, G6=0.25, G7=1.12, G8=0.08 is G8, so it can be determined that G8 is the third parameter value to be analyzed, and the corresponding G1, G2, G3, G4, G5, G6 and G7 are at least one fourth parameter value to be analyzed.
[0090] Step 203c: Based on the sparsification rate, adjust at least one third parameter value to be analyzed and at least one fourth parameter value to be analyzed respectively, and obtain at least one first reference parameter value and at least one second reference parameter value in sequence.
[0091] In the embodiment of the present application, at least one third parameter value to be analyzed is sorted in a descending order to obtain a target arrangement order of at least one third parameter value to be analyzed; from the target arrangement order of at least one third parameter value to be analyzed, the sorting sequence number of each third parameter value to be analyzed is determined; the product between the sorting sequence number of each third parameter value to be analyzed, the thinning rate and the first preset value is determined to obtain the first value of each third parameter value to be analyzed; the sum of the first value of each third parameter value to be analyzed and each third parameter value to be analyzed is determined to obtain at least one first reference parameter value. The product of the thinning rate and the second preset value is determined to obtain a second value; the sum of the second value and each fourth parameter value to be analyzed is determined to obtain at least one second reference parameter value.
[0092] Exemplarily, taking the first preset value Y1 as -1 and the second preset value Y2 as 1 as an example, when at least one third parameter value to be analyzed is G8, the corresponding sort number is 1, and the first value L1 is determined to be L1=1*Y1*0.01=1*(-1)*0.01=-0.01, and the first reference parameter value corresponding to G8 is G81=G8+L1=0.08-0.01=0.07. For at least one fourth parameter value to be analyzed G1, G2, G3, G4, G5, G6 and G7, the second numerical value L2=Y2*0.01=1*0.01=0.01, and for the fourth parameter value to be analyzed corresponding to G1, G11=G1+L2=2.11+0.01=2.12. Similarly, the fourth parameter value to be analyzed corresponding to G2 is G21=1.91, the fourth parameter value to be analyzed corresponding to G3 is G31=0.91, the fourth parameter value to be analyzed corresponding to G4 is G41=0.22, the fourth parameter value to be analyzed corresponding to G5 is G51=0.85, the fourth parameter value to be analyzed corresponding to G6 is G61=0.26, and the fourth parameter value to be analyzed corresponding to G7 is G71=1.13.
[0093] Step 203d, using each first reference parameter value to replace the corresponding first parameter value to be analyzed in the neural network model to be trimmed, and each second reference parameter value to replace the corresponding second parameter value to be analyzed in the neural network model to be trimmed, to obtain a first reference neural network model.
[0094] In an embodiment of the present application, in the neural network model to be trimmed, G11=2.12 is used instead of G1, G21=1.91 is used instead of G2, G31=0.91 is used instead of G3, G41=0.22 is used instead of G4, G51=0.85 is used instead of G5, G61=0.26 is used instead of G6, G71=1.13 is used instead of G7, and G81=0.07 is used instead of G8, so as to obtain a first reference neural network model. However, due to the adaptive adjustment of the first reference neural network model, after the corresponding values of G11, G21, G31, G41, G51, G61, G71, and G81 are substituted into the neural network model to be trimmed, the values of G11, G21, G31, G41, G51, G61, G71, and G81 of the first reference neural network model will be adaptively adjusted, that is, the values of G11, G21, G31, G41, G51, G61, G71, and G81 in the first reference neural network model are not necessarily the values calculated in step 203d.
[0095] Step 203e, obtaining at least one second parameter value corresponding to the target parameter of the target layer in the first reference neural network model.
[0096] In an embodiment of the present application, at least one second parameter value corresponding to the Gamma parameter of the BN layer in the first reference neural network model obtained in step 203d is G11, G21, G31, G41, G51, G61, G71, G81.
[0097] Step 203f, determine the sum of the first compression reference ratio and the preset step value to obtain a second compression reference ratio.
[0098] In the embodiment of the present application, the second compression reference ratio=the first compression reference ratio+the preset step value=10%+5%=15%.
[0099] After executing step 203f, the electronic device may choose to execute step 203g or steps 203h to 203m. If the second compression reference ratio is equal to the compression ratio, step 203g is executed; if the second compression reference ratio is less than the compression ratio, steps 203h to 203m are executed.
[0100] Step 203g: If the second compression reference ratio is equal to the compression ratio, group at least one second parameter value based on the compression ratio to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed.
[0101] In the embodiment of the present application, the specific implementation process of step 203g can refer to the specific implementation process of steps 203b to 203c, which will not be repeated here.
[0102] Step 203h: If the second compression reference ratio is less than the compression ratio, group at least one second parameter value based on the second compression reference ratio to obtain at least one fifth parameter value to be analyzed and at least one sixth parameter value to be analyzed.
[0103] Each fifth parameter value to be analyzed is smaller than each sixth parameter value to be analyzed.
[0104] In the embodiment of the present application, since the second compression ratio of 15% is less than the compression ratio of 40%, based on the second compression ratio of 15%, at least one second parameter value G11, G21, G31, G41, G51, G61, G71, G81 is grouped and processed, and 15%*8=1.2 is calculated, rounded to 1, and a corresponding minimum value among G11, G21, G31, G41, G51, G61, G71, G81 is determined to obtain a fifth parameter value to be analyzed, and the corresponding 7 values except the fifth parameter value to be analyzed are at least one sixth parameter value to be analyzed.
[0105] Step 203i: Based on the sparsification rate, adjust at least one fifth parameter value to be analyzed and at least one sixth parameter value to be analyzed respectively, and obtain at least one third reference parameter value and at least one fourth reference parameter value in sequence.
[0106] Step 203j, use each third reference parameter value to replace the corresponding fifth parameter value to be analyzed in the first reference neural network model, and use each fourth reference parameter value to replace the corresponding sixth parameter value to be analyzed in the first reference neural network model to obtain a second reference neural network model.
[0107] Step 203k: obtain at least one third parameter value corresponding to the target parameter of the target layer in the second reference neural network model.
[0108] Step 2031: Determine the sum of the second compression reference ratio and the preset step value to obtain a third compression reference ratio.
[0109] Step 203m: if the third compression reference ratio is less than the compression ratio, at least one third parameter value is grouped based on the third compression reference ratio, and this is repeated until the sum of the fourth compression reference ratio and the preset step value is the compression ratio, then at least one fourth parameter value corresponding to the target parameter of the target layer in the third reference neural network model is grouped based on the compression ratio to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed.
[0110] Among them, the third reference neural network model is a neural network model obtained based on the fourth compression reference ratio and has an associated relationship with the neural network model to be trimmed.
[0111] In the embodiment of the present application, this is repeated until the sum of the fourth compression reference ratio and the preset step value is 40%, and the 8 Gamma parameters corresponding to the BN layer in the third reference neural network model corresponding to the fourth compression reference ratio of 35% are grouped and processed to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed. In this way, after 7 times of progressive dynamic adjustment of 10%->15%->20%->25%->30%->35%->40%, the accuracy loss caused by the preset step value can be effectively reduced, thereby ensuring that the final target neural network model is more in line with the accuracy requirements.
[0112] Correspondingly, step 204 can be implemented by steps 204a to 204b:
[0113] Step 204a: Based on at least one first parameter value to be analyzed, a thinning rate, and a first preset value, each first parameter value to be analyzed is adjusted to obtain at least one first target parameter value.
[0114] Among them, the first preset value is less than or equal to 0.
[0115] Step 204b: Based on the thinning rate and the second preset value, adjust each second parameter value to be analyzed to obtain at least one second target parameter value.
[0116] Among them, the second preset value is greater than or equal to 0.
[0117] In this way, since the number of progressive dynamic adjustments is also much smaller than the number of times the sparse model is currently trained, the process of sparse processing of the neural network model to be pruned is accelerated; and in the present application, when analyzing the parameter values of the target parameters of the neural network model to be pruned, the compression ratio that will only be considered later is considered in advance, which effectively accelerates the gap between the Gamma parameter value to be pruned and the Gamma parameter value to be retained.
[0118] Based on the above embodiment, in other embodiments of the present application, step 204a can be implemented by steps a11 to a14:
[0119] Step a11: sort at least one first parameter value to be analyzed in ascending order to obtain a target arrangement order of at least one first parameter value to be analyzed.
[0120] Step a12: Determine the sorting sequence number of each first parameter value to be analyzed from the target sorting sequence.
[0121] Step a13: determine the product of the sorting sequence number of each first parameter value to be analyzed, the sparsification rate and the first preset value to obtain a first value.
[0122] Step a14, determine the sum of the first numerical value and each first parameter value to be analyzed, and obtain at least one first target parameter value.
[0123] Correspondingly, step 204b can be implemented by steps b11 to b12:
[0124] Step b11: determine the product of the thinning rate and a second preset value to obtain a second value.
[0125] Step b12: determine the sum of the second numerical value and each second parameter value to be analyzed to obtain at least one second target parameter value.
[0126] In this way, by performing polar accelerated differentiation processing on at least one first parameter value to be analyzed, the gap between the two poles is effectively and quickly accelerated, so that the Gamma parameters to be retained and the Gamma parameters to be clipped can be determined quickly.
[0127] Based on the foregoing embodiment, the embodiment of the present application provides a data processing method, that is, a single analysis is performed on at least one first parameter value of a target parameter of a target layer of a neural network model to be pruned based on a compression ratio, referring to Figure 3 As shown, the following steps are included:
[0128] Step 301, determine that the Gamma parameter of the BN layer included in the neural network model to be pruned includes 8 values, which are G1=2.11, G2=1.90, G3=0.9, G4=0.21, G5=0.84, G6=0.25, G7=1.12, and G8=0.08.
[0129] Step 302: Determine the thinning rate to be 0.01 and the compression ratio to be 40%.
[0130] Step 303, sort the eight values G1=2.11, G2=1.90, G3=0.9, G4=0.21, G5=0.84, G6=0.25, G7=1.12 and G8=0.08 in descending order, and obtain the sorting results of G1, G2, G7, G3, G5, G6, G4, G8.
[0131] Step 304: Determine that the product of the compression ratio and the number of Gamma parameters of the BN layer included in the neural network model to be pruned is 3.2, and round it to 3.
[0132] Step 305 , group the eight parameters from the sorting results to obtain the first five parameters G1, G2, G7, G3 and G5, and the last three parameters G6, G4 and G8.
[0133] Step 306: Determine that the adjustment offset corresponding to each parameter value in the first five G1, G2, G7, G3 and G5 is 0.01*1=0.01.
[0134] Step 307 , based on the adjustment offset of 0.01, the values of G1 , G2 , G7 , G3 and G5 are adjusted in sequence, and the corresponding values are G1 ′=2.12, G2 ′=1.91, G7 ′=1.13, G3 ′=0.91, G5 ′=0.85.
[0135] Step 308, determine that the sorting order of the three G6, G4 and G8 from small to large is G8, G4, G6, the corresponding sorting order of G8 is 1, and the offset corresponding to G8 is determined to be -1*0.01*1=-0.01, the sorting order of G4 is 2, and the offset corresponding to G4 is determined to be -1*0.01*2=-0.02, the sorting order of G6 is 3, and the offset corresponding to G6 is determined to be -1*0.01*3=-0.03.
[0136] Step 309, based on the offset -0.01 corresponding to G8, G8 is adjusted to obtain G8'=0.07; based on the offset -0.02 corresponding to G4, G4 is adjusted to obtain G4'=0.19; based on the offset -0.03 corresponding to G6, G6 is adjusted to obtain G6'=0.22.
[0137] Step 310, based on the determined G1', G2', G3', G4', G5', G6', G7' and G8', replace G1, G2, G3, G4, G5, G6, G7, G8 in the neural network model to be trimmed in turn to obtain the target neural network model.
[0138] It should be noted that in some application scenarios, the parameter values of the smallest three parameters among G1', G2', G3', G4', G5', G6', G7' and G8' can be directly set to 0, that is, the parameter values corresponding to G4', G6' and G8' can be directly set to 0.
[0139] Based on the foregoing embodiment, according to the number of layers of the neural network model to be pruned included in the target layer, whether to perform progressive dynamic adjustment based on the compression ratio, and the value of the second preset value, the following schemes may be included:
[0140] Solution 1: The target layer in the neural network model to be pruned includes at least two different layers of the neural network model to be pruned, the first preset value is -1, the second preset value is 0, and the embodiments corresponding to steps 201 to 202, steps 203a to 203m, steps 204a to 204b, steps a11 to a14 and steps b11 to b12 are executed.
[0141] Solution 2: The target layer in the neural network model to be pruned includes at least two different layers of the neural network model to be pruned, the first preset value is -1, the second preset value is 0, and the embodiments corresponding to steps 31 to 310 are executed.
[0142] Solution three: the target layer in the neural network model to be trimmed includes at least two different layers of the neural network model to be trimmed, the first preset value is -1, the second preset value is 1, and the embodiments corresponding to steps 201 to 202, steps 203a to 203m, steps 204a to 204b, steps a11 to a14 and steps b11 to b12 are executed.
[0143] Solution 4: The target layer in the neural network model to be pruned includes at least two different layers of the neural network model to be pruned, the first preset value is -1, the second preset value is 1, and the embodiments corresponding to steps 31 to 310 are executed.
[0144] Solution 5: The target layer in the neural network model to be trimmed includes at least two different layers of the neural network model to be trimmed, the first preset value is 0, the second preset value is 1, and the corresponding embodiments of steps 201-202, steps 203a-203m, steps 204a-204b, steps a11-a14 and steps b11-b12 are executed.
[0145] Solution 6: The target layer in the neural network model to be pruned includes at least two different layers of the neural network model to be pruned, the first preset value is 0, the second preset value is 1, and the embodiments corresponding to steps 31 to 310 are executed.
[0146] Solution seven, the target layer in the neural network model to be pruned includes 1 layer of the neural network model to be pruned, the first preset value is -1, the second preset value is 1, and the embodiments corresponding to steps 201 to 202, steps 203a to 203m, steps 204a to 204b, steps a11 to a14 and steps b11 to b12 are executed.
[0147] Solution 8: The target layer in the neural network model to be pruned includes a layer of the neural network model to be pruned, the first preset value is -1, the second preset value is 1, and the embodiments corresponding to steps 31 to 310 are executed.
[0148] Solution nine: The target layer in the neural network model to be pruned includes a layer of the neural network model to be pruned, the first preset value is -1, the second preset value is 0, and the embodiments corresponding to steps 201 to 202, steps 203a to 203m, steps 204a to 204b, steps a11 to a14 and steps b11 to b12 are executed.
[0149] Solution 10: The target layer in the neural network model to be pruned includes a layer of the neural network model to be pruned, the first preset value is -1, the second preset value is 0, and the embodiments corresponding to steps 31 to 310 are executed.
[0150] Solution 11: The target layer in the neural network model to be pruned includes a layer of the neural network model to be pruned, the first preset value is 0, the second preset value is 1, and the embodiments corresponding to steps 201 to 202, steps 203a to 203m, steps 204a to 204b, steps a11 to a14 and steps b11 to b12 are executed.
[0151] Solution 12: The target layer in the neural network model to be pruned includes a layer of the neural network model to be pruned, the first preset value is -0, the second preset value is 1, and the embodiments corresponding to steps 31 to 310 are executed.
[0152] In this way, by analyzing the importance of the gamma parameter value of each layer to be retained in the neural network model to be pruned to the accuracy of the neural network model, and analyzing the importance of the gamma parameter value of each layer to be pruned to the compression of each layer of the network model, the time required for expanding the compression ratio and improving the accuracy in the later model compression process is reduced, and the compression quality is improved; further, the precision loss caused by cropping sparsification can be well compensated through the progressive dynamic adjustment of the cropping sparsification method, so as to achieve continuous improvement of accuracy by fine-tuning the gamma parameters to be retained.
[0153] It should be noted that, for the description of the same steps and the same contents in this embodiment as those in other embodiments, reference can be made to the description in other embodiments and will not be repeated here.
[0154] A data processing method provided by an embodiment of the present application determines a compression ratio and a sparsification rate after determining at least one first parameter value corresponding to a target parameter of a target layer in a neural network model to be pruned, and then performs sparsification pruning processing on the neural network model to be pruned based on the compression ratio, the sparsification rate and the at least one first parameter value to obtain a target neural network model, and finally performs sparsification pruning processing on the data to be pruned based on the target neural network model. In this way, at least one first parameter value corresponding to a target parameter of a target layer in a neural network model to be pruned is subjected to sparsification pruning processing by using a compression ratio and a sparsification rate to obtain a target neural network model, thereby solving the problem that the pruning and compression process is relatively time-consuming in the current model pruning and compression process, and realizing a technical solution for quickly obtaining a pruned and compressed model with better pruning accuracy, thereby effectively improving the efficiency of model pruning.
[0155] Based on the above embodiments, the embodiments of the present application provide an electronic device, which can be applied to Figures 1 to 3 And in any of the data processing methods provided in the above embodiments, refer to Figure 4 As shown, the electronic device 4 may include: a processor 41, a memory 42 and a communication bus 43, wherein:
[0156] A memory 42, for storing executable instructions;
[0157] A communication bus 43, used to realize the communication connection between the processor and the memory;
[0158] The processor 41 is used to execute the data processing program stored in the memory to implement the following steps:
[0159] Determine at least one first parameter value corresponding to a target parameter of a target layer in the neural network model to be pruned;
[0160] Determine compression ratio and sparsification ratio;
[0161] Based on the compression ratio, the sparsification rate and at least one first parameter value, the neural network model to be pruned is subjected to a sparse pruning process to obtain a target neural network model;
[0162] The data to be cropped is sparsely cropped based on the target neural network model.
[0163] In other embodiments of the present application, the processor executes the step of performing sparse pruning on the neural network model to be pruned based on the compression ratio, the sparseness ratio and at least one first parameter value to obtain the target neural network model, which can be achieved by the following steps:
[0164] Based on the compression ratio, at least one first parameter value is grouped to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed; wherein each first parameter value to be analyzed is smaller than each second parameter value to be analyzed;
[0165] Based on the sparsification rate, at least one first parameter value to be analyzed and at least one second parameter value to be analyzed are adjusted respectively to obtain at least one first target parameter value and at least one second target parameter value in sequence;
[0166] Each first target parameter value is used to replace the corresponding first parameter value to be analyzed in the neural network model to be trimmed, and each second target parameter value is used to replace the corresponding second parameter value to be analyzed in the neural network model to be trimmed, so as to obtain the target neural network model.
[0167] In other embodiments of the present application, when the processor executes the step of grouping at least one first parameter value based on the compression ratio to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed, it can be implemented by the following steps:
[0168] Determine a first compression reference ratio and a preset step value; wherein the first compression reference ratio is associated with the compression ratio, and the first compression reference ratio is less than or equal to the compression ratio;
[0169] Based on the first compression reference ratio, grouping the at least one first parameter value to obtain at least one third parameter value to be analyzed and at least one fourth parameter value to be analyzed;
[0170] Based on the thinning rate, adjusting at least one third parameter value to be analyzed and at least one fourth parameter value to be analyzed respectively, to obtain at least one first reference parameter value and at least one second reference parameter value in sequence;
[0171] Using each first reference parameter value to replace the corresponding first parameter value to be analyzed in the neural network model to be trimmed, and each second reference parameter value to replace the corresponding second parameter value to be analyzed in the neural network model to be trimmed, to obtain a first reference neural network model;
[0172] Obtain at least one second parameter value corresponding to a target parameter of a target layer in a first reference neural network model;
[0173] Determine a sum of a first compression reference ratio and a preset step value to obtain a second compression reference ratio;
[0174] If the second compression reference ratio is equal to the compression ratio, at least one second parameter value is grouped based on the compression ratio to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed.
[0175] In other embodiments of the present application, the processor is further configured to perform the following steps:
[0176] If the second compression reference ratio is less than the compression ratio, grouping the at least one second parameter value based on the second compression reference ratio to obtain at least one fifth parameter value to be analyzed and at least one sixth parameter value to be analyzed; wherein each fifth parameter value to be analyzed is less than each sixth parameter value to be analyzed;
[0177] Based on the thinning rate, adjusting at least one fifth parameter value to be analyzed and at least one sixth parameter value to be analyzed respectively, to obtain at least one third reference parameter value and at least one fourth reference parameter value in sequence;
[0178] Using each third reference parameter value to replace the corresponding fifth parameter value to be analyzed in the first reference neural network model, and each fourth reference parameter value to replace the corresponding sixth parameter value to be analyzed in the first reference neural network model, to obtain a second reference neural network model;
[0179] Obtain at least one third parameter value corresponding to a target parameter of a target layer in a second reference neural network model;
[0180] Determine a sum of the second compression reference ratio and the preset step value to obtain a third compression reference ratio;
[0181] If the third compression reference ratio is less than the compression ratio, at least one third parameter value is grouped based on the third compression reference ratio, and this is repeated until the sum of the fourth compression reference ratio and the preset step value is the compression ratio, then at least one fourth parameter value corresponding to the target parameter of the target layer in the third reference neural network model is grouped based on the compression ratio to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed; wherein the third reference neural network model is a neural network model that is obtained based on the fourth compression reference ratio and has an associated relationship with the neural network model to be trimmed.
[0182] In other embodiments of the present application, when the processor executes the step of adjusting at least one first parameter value to be analyzed and at least one second parameter value to be analyzed respectively based on the sparsification rate, and sequentially obtaining at least one first target parameter value and at least one second target parameter value, it can be implemented by the following steps:
[0183] Based on at least one first parameter value to be analyzed, a thinning rate and a first preset value, adjusting each first parameter value to be analyzed to obtain at least one first target parameter value; wherein the first preset value is less than or equal to 0;
[0184] Based on the thinning rate and the second preset value, each second parameter value to be analyzed is adjusted to obtain at least one second target parameter value; wherein the second preset value is greater than or equal to 0.
[0185] In other embodiments of the present application, when the processor executes the step of adjusting each first parameter value to be analyzed based on at least one first parameter value to be analyzed, the sparsification rate and the first preset value to obtain at least one first target parameter value, it can be implemented by the following steps:
[0186] Sort the at least one first parameter value to be analyzed in ascending order to obtain a target arrangement order of the at least one first parameter value to be analyzed;
[0187] Determine the sorting sequence number of each first parameter value to be analyzed from the target sorting sequence;
[0188] Determine the product of the sorting sequence number of each first parameter value to be analyzed, the thinning rate and the first preset value to obtain a first value;
[0189] The sum of the first numerical value and each first parameter value to be analyzed is determined to obtain at least one first target parameter value.
[0190] In other embodiments of the present application, when the processor executes the step of adjusting each second parameter value to be analyzed based on the thinning rate and the second preset value to obtain at least one second target parameter value, it can be achieved by the following steps:
[0191] Determine the product of the thinning rate and a second preset value to obtain a second value;
[0192] The sum of the second numerical value and each second parameter value to be analyzed is determined to obtain at least one second target parameter value.
[0193] In other embodiments of the present application, the target layer is at least one specific neural network layer in the neural network model to be pruned.
[0194] It should be noted that the specific implementation process of the steps executed by the processor in this embodiment can refer to Figures 1 to 3The implementation process of the data processing method provided in the corresponding embodiment will not be repeated here.
[0195] An electronic device provided by an embodiment of the present application determines a compression ratio and a sparsification rate after determining at least one first parameter value corresponding to a target parameter of a target layer in a neural network model to be pruned, and then performs sparsification pruning processing on the neural network model to be pruned based on the compression ratio, the sparsification rate and the at least one first parameter value to obtain a target neural network model, and finally performs sparsification pruning processing on the data to be pruned based on the target neural network model. In this way, at least one first parameter value corresponding to a target parameter of a target layer in a neural network model to be pruned is subjected to sparsification pruning processing by using a compression ratio and a sparsification rate to obtain a target neural network model, thereby solving the problem that the pruning and compression process is relatively time-consuming in the current model pruning and compression process, and realizing a technical solution for quickly obtaining a pruned and compressed model with better pruning accuracy, thereby effectively improving the efficiency of model pruning.
[0196] Based on the foregoing embodiments, the embodiments of the present application provide a computer-readable storage medium, referred to as a storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the following. Figures 1 to 3 The implementation process of the method provided in any of the above embodiments will not be repeated here.
[0197] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of hardware embodiments, software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.
[0198] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0199] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0200] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0201] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. A data processing method, the method comprising: Determine at least one first parameter value corresponding to a target parameter of a target layer in the neural network model to be pruned; Determine the compression ratio and the sparsification ratio according to the neural network model to be pruned and the hardware resources of the hardware device running the neural network model to be pruned; the hardware resources include the computing power and storage capacity of the hardware device; Based on the compression ratio, the at least one first parameter value is grouped to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed; wherein each of the first parameter values to be analyzed is smaller than each of the second parameter values to be analyzed; Based on the sparsification rate, adjusting the at least one first parameter value to be analyzed and the at least one second parameter value to be analyzed respectively, to obtain at least one first target parameter value and at least one second target parameter value in sequence; Using each of the first target parameter values to replace the corresponding first parameter value to be analyzed in the neural network model to be trimmed, and each of the second target parameter values to replace the corresponding second parameter value to be analyzed in the neural network model to be trimmed, to obtain a target neural network model; The data to be cropped is subjected to sparse cropping processing based on the target neural network model.
2. The method according to claim 1, wherein the grouping process of the at least one first parameter value based on the compression ratio to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed comprises: Determine a first compression reference ratio and a preset step value; wherein the first compression reference ratio is associated with the compression ratio, and the first compression reference ratio is less than or equal to the compression ratio; Based on the first compression reference ratio, grouping the at least one first parameter value to obtain at least one third parameter value to be analyzed and at least one fourth parameter value to be analyzed; Based on the thinning rate, adjusting the at least one third parameter value to be analyzed and the at least one fourth parameter value to be analyzed respectively, to obtain at least one first reference parameter value and at least one second reference parameter value in sequence; Using each of the first reference parameter values to replace the corresponding first parameter value to be analyzed in the neural network model to be trimmed, and using each of the second reference parameter values to replace the corresponding second parameter value to be analyzed in the neural network model to be trimmed, to obtain a first reference neural network model; Obtain at least one second parameter value corresponding to the target parameter of the target layer in the first reference neural network model; Determine a sum of the first compression reference ratio and the preset step value to obtain a second compression reference ratio; If the second compression reference ratio is equal to the compression ratio, the at least one second parameter value is grouped based on the compression ratio to obtain the at least one first parameter value to be analyzed and the at least one second parameter value to be analyzed.
3. The method according to claim 2, further comprising: If the second compression reference ratio is less than the compression ratio, grouping the at least one second parameter value based on the second compression reference ratio to obtain at least one fifth parameter value to be analyzed and at least one sixth parameter value to be analyzed; wherein each of the fifth parameter values to be analyzed is less than each of the sixth parameter values to be analyzed; Based on the thinning rate, adjusting the at least one fifth parameter value to be analyzed and the at least one sixth parameter value to be analyzed respectively, to obtain at least one third reference parameter value and at least one fourth reference parameter value in sequence; Using each of the third reference parameter values to replace the corresponding fifth parameter value to be analyzed in the first reference neural network model, and each of the fourth reference parameter values to replace the corresponding sixth parameter value to be analyzed in the first reference neural network model, to obtain a second reference neural network model; Obtain at least one third parameter value corresponding to the target parameter of the target layer in the second reference neural network model; Determine a sum of the second compression reference ratio and the preset step value to obtain a third compression reference ratio; If the third compression reference ratio is less than the compression ratio, the at least one third parameter value is grouped based on the third compression reference ratio, and this is repeated until the sum of the fourth compression reference ratio and the preset step value is the compression ratio, then based on the compression ratio, at least one fourth parameter value corresponding to the target parameter of the target layer in the third reference neural network model is grouped to obtain the at least one first parameter value to be analyzed and the at least one second parameter value to be analyzed; wherein the third reference neural network model is a neural network model obtained based on the fourth compression reference ratio and has an associated relationship with the neural network model to be trimmed.
4. The method according to any one of claims 1 to 3, wherein based on the sparsification rate, the at least one first parameter value to be analyzed and the at least one second parameter value to be analyzed are adjusted respectively to obtain at least one first target parameter value and at least one second target parameter value in sequence, comprising: Based on at least one of the first parameter values to be analyzed, the thinning rate and a first preset value, adjusting each of the first parameter values to be analyzed to obtain at least one of the first target parameter values; wherein the first preset value is less than or equal to 0; Based on the thinning rate and the second preset value, each of the second parameter values to be analyzed is adjusted to obtain at least one second target parameter value; wherein the second preset value is greater than or equal to 0.
5. The method according to claim 4, wherein adjusting each of the first parameter values to be analyzed based on at least one of the first parameter values to be analyzed, the thinning rate, and a first preset value to obtain at least one of the first target parameter values comprises: Sort at least one of the first parameter values to be analyzed in ascending order to obtain a target arrangement order of at least one of the first parameter values to be analyzed; Determining a sorting sequence number of each of the first parameter values to be analyzed from the target arrangement sequence; Determine the product of the sorting sequence number of each of the first parameter values to be analyzed, the thinning rate and the first preset value to obtain a first value; The sum of the first numerical value and each of the first parameter values to be analyzed is determined to obtain at least one of the first target parameter values.
6. The method according to claim 5, wherein adjusting each of the second parameter values to be analyzed based on the thinning rate and the second preset value to obtain at least one second target parameter value comprises: Determine the product of the thinning rate and the second preset value to obtain a second value; The sum of the second numerical value and each of the second parameter values to be analyzed is determined to obtain at least one second target parameter value.
7. According to the method of claim 1, the target layer is at least one specific neural network layer in the neural network model to be pruned.
8. An electronic device, comprising: A processor, a memory, and a communication bus; wherein: The memory is used to store executable instructions; The communication bus is used to realize the communication connection between the processor and the memory; The processor is used to execute the data processing program stored in the memory to implement the following steps: Determine at least one first parameter value corresponding to a target parameter of a target layer in the neural network model to be pruned; Determine the compression ratio and the sparsification ratio according to the neural network model to be pruned and the hardware resources of the hardware device running the neural network model to be pruned; the hardware resources include the computing power and storage capacity of the hardware device; Based on the compression ratio, the at least one first parameter value is grouped to obtain at least one first parameter value to be analyzed and at least one second parameter value to be analyzed; wherein each of the first parameter values to be analyzed is smaller than each of the second parameter values to be analyzed; Based on the sparsification rate, adjusting the at least one first parameter value to be analyzed and the at least one second parameter value to be analyzed respectively, to obtain at least one first target parameter value and at least one second target parameter value in sequence; Using each of the first target parameter values to replace the corresponding first parameter value to be analyzed in the neural network model to be trimmed, and each of the second target parameter values to replace the corresponding second parameter value to be analyzed in the neural network model to be trimmed, to obtain a target neural network model; The data to be cropped is subjected to sparse cropping processing based on the target neural network model.
9. A storage medium having a data processing program stored thereon, wherein the data processing program, when executed by a processor, implements the steps of the data processing method according to any one of claims 1 to 7.
