Network pruning method and system based on multi-scale weight analysis
By employing a network pruning method based on multi-scale weight analysis, combined with gradient analysis and geometric similarity to assess channel importance, the problem of decreased model accuracy in existing technologies is solved, achieving efficient deployment of deep neural networks in resource-constrained environments.
Patent Information
- Application Number
- CN202411866668.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2026-01-16
- Estimated Expiration
- 2044-12-18
AI Technical Summary
Existing network pruning methods fail to fully consider the correlation between channels, resulting in decreased model accuracy and limited pruning effects, making it difficult to efficiently deploy deep neural networks in resource-constrained environments.
A network pruning method based on multi-scale weight analysis is adopted. The sensitivity value of the convolutional layer is calculated through gradient analysis, and the importance of the channel is evaluated by combining L2 norm, Euclidean distance and KL divergence. The pruning ratio is automatically calculated and redundant channels are removed first. Then, fine-tuning and retraining are performed to restore the model performance.
It significantly improved the model's recognition accuracy and pruning rate, while increasing the model's operating efficiency and adaptability while keeping computational and storage requirements unchanged.
Smart Images

Figure CN119918608B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of lightweight deep learning network, and particularly relates to a network pruning method and system based on multi-scale weight analysis. The present application realizes efficient pruning by evaluating the importance of network channels, reduces the amount of calculation and storage demand while maintaining model accuracy, and is suitable for deep learning model deployment of resource-constrained devices. BACKGROUND
[0002] With the rapid development of deep learning in the field of computer vision and natural language processing, deep neural networks have shown excellent performance in many applications. However, deep neural networks usually have a large number of parameters, high computational and storage requirements, making it difficult to be directly deployed in resource-constrained environments such as embedded systems and edge devices. Therefore, model lightweight technology has gradually become a key research direction for network deployment.
[0003] Network pruning, as one of the main methods of model lightweight, aims to remove redundant weights or channels to reduce computational complexity and storage occupancy, thereby accelerating the inference process and reducing resource consumption. Traditional pruning methods are usually based on L1 norm, L2 norm or weight threshold, but these methods cannot fully consider the similarity or relevance between different channels, which may lose important model information or retain redundant channels during the pruning process, thereby affecting model accuracy and lightweight effect. In order to solve this problem, in recent years, a pruning method based on Euclidean distance has been introduced, which evaluates the redundancy by calculating the geometric similarity between channels and preferentially removes channels with higher redundancy, effectively reducing the parameter redundancy of the model. However, this method may still retain channels with low weight values and small actual contributions while removing redundant channels, which limits the pruning effect. Therefore, how to further improve the network compression rate while ensuring the model accuracy is still an important problem to be solved in pruning research. Based on this, the present application proposes a network pruning method and system based on multi-scale weight analysis. SUMMARY
[0004] In view of the problem that the selection of redundant channels is not accurate in the existing network model lightweight process, and the traditional pruning method fails to fully consider the relevance between channels, resulting in significant decline in model performance, in order to improve the running efficiency of deep neural networks in resource-constrained environments and further improve the pruning rate while maintaining model accuracy, the present application proposes a network pruning method and system based on multi-scale weight analysis.
[0005] In order to achieve the above purpose, the present application adopts the following technical scheme:
[0006] A network pruning method based on multi-scale weight analysis, comprising the following steps:
[0007] S1, load a pre-trained network model that needs to be lightened;
[0008] S2, calculate the sensitivity value of each convolution layer in step S1 based on the gradient analysis method;
[0009] S3, according to the sensitivity value obtained in step S2, calculate the pruning ratio of each convolution layer, and calculate the number of channels to be pruned according to the pruning ratio;
[0010] S4, construct a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence, calculate the importance score of the channels in each convolution layer of the pre-trained network model, and according to the number of channels to be pruned in step S3, execute the pruning operation on the channels whose scores are lower than the predetermined pruning ratio;
[0011] S5, fine-tune and retrain the pruned model.
[0012] Further, in step S1, a pre-trained deep neural network model containing weight parameters is loaded, and the model file contains network architecture and corresponding parameters. Check whether the parameters and architecture meet the requirements of subsequent operations.
[0013] Further, in step S2, the sensitivity of each convolution layer in the model is calculated based on the gradient analysis method, and the specific steps are as follows:
[0014] Step S21, load a representative input data sample dataset, perform forward propagation according to the loss function used in the pre-trained network model (such as cross-entropy loss in classification task or mean square error loss in regression task), and calculate the loss function L output by the model:
[0015]
[0016] Where N represents the total number of sample data sets, y i represents the true label of the i-th sample, represents the prediction output of the model for the sample, and l(·) represents the loss of a single sample.
[0017] Step S22, perform back propagation on the model to calculate the gradient l i of the loss L with respect to the convolution kernel weight W
[0018]
[0019] Where, represents the partial derivative, and W l i represents the convolution kernel weight matrix of the i-th channel of the l-th layer, a gradient value of a convolution kernel weight of an i-th channel of an l-th layer with respect to a loss L;
[0020] Step S23, calculating a root mean square of gradient values of all channel weights of each convolution layer as a sensitivity value S of the layer l :
[0021]
[0022] wherein, a gradient value of a convolution kernel weight of an i-th channel of an l-th layer with respect to a loss L, n represents a total number of weights of the l-th layer;
[0023] Step S24, normalizing the sensitivity values of all convolution layers to obtain normalized sensitivity values S
[0024]
[0025] wherein, S k a sensitivity value of a k-th layer, K represents a total number of convolution layers of the pre-trained model, S l a sensitivity value of an l-th layer.
[0026] Further, in step S3, a pruning ratio of each convolution layer is calculated, and the number of channels to be pruned in each layer is calculated according to the pruning ratio, and the specific steps are as follows:
[0027] Step S31, calculating a pruning ratio P of a model of an l-th layer according to the normalized sensitivity value S l :
[0028]
[0029] wherein, a normalized sensitivity value of a k-th layer, C k a number of channels of the k-th layer, a normalized sensitivity value of an l-th layer, P total a target total pruning ratio, C l a number of channels of the l-th layer, k represents a total number of convolution layers;
[0030] Step S32, calculating the number of pruned channels of each layer according to the pruning ratio P l
[0031]
[0032] wherein, P l a pruning ratio of an l-th layer, n represents a number of channels of the l-th layer, represents a floor function.
[0033] Further, in step S4, the model design specific steps are as follows:
[0034] Step S41, for each convolution channel in the lth layer, calculate its channel L2 norm:
[0035]
[0036] Wherein, C in represents the number of input channels, K h and K w respectively represent the spatial dimensions of the convolution kernel, i.e. height and width, W i,j,p,q represents the weight value of the i-th output channel, the j-th input channel, the p-th row, and the q-th column in the weight matrix.
[0037] Step S42, calculate the Euclidean distance of the convolution kernel W i and W j of any two channels in the lth layer, shape [n,n], n is the number of channels, and the Euclidean distance d ij is calculated as follows:
[0038]
[0039] Wherein, W i,a,p,q and W j,a,p,q respectively represent the weight of the a-th input channel, the p-th row, and the q-th column of the convolution kernel of channel i and channel j, C in represents the number of input channels, K h and K w respectively represent the spatial dimensions of the convolution kernel, i.e. height and width.
[0040] Step S43, perform Softmax operation on the negative Euclidean distance of each channel, and calculate the similarity distribution P ij between channel i and channel j:
[0041]
[0042] Wherein, d ik represents the Euclidean distance between channel i and channel k, and k represents the output channel index of the convolution layer.
[0043] Step S44, use the KL divergence formula to evaluate the concentration degree of the convolution channel similarity distribution:
[0044]
[0045] Wherein, P ij represents the similarity distribution of channel i and channel j, P ikScorei,k represents the similarity distribution between channel i and channel k, e -7 Scorei represents the smoothing term for preventing the denominator from being zero;
[0046] Step S45, sum the rows of the KL divergence matrix to obtain the similarity score of each channel based on the Euclidean distance; add the L2 norm value of the convolution channel in each layer to the similarity score of its Euclidean distance as the comprehensive importance score of each channel:
[0047]
[0048] wherein, KL(P ij ) represents the concentration degree of the similarity distribution of channel i, W i represents the L2 norm of channel i, and alpha represents a hyperparameter, preferably between 0 and 1;
[0049] Step S46, sort the comprehensive importance scores of the convolution channels in each layer from large to small; according to the channel pruning number of each layer in S32 perform pruning operation on the channels with lower comprehensive importance scores:
[0050] Score=[Score1,Score2,...,Score k ] and Score1≥Score2≥···≥Score k
[0051] Further, in step S5, the weights of the model before pruning are used as initialization after pruning, and the weights of the unpruned part are retained; the pruned model is retrained, and the training data set is unchanged. Similar to the original model training, but the training strategy needs to be adjusted appropriately, including learning rate, training rounds, optimizer, etc.
[0052] Further, after step S5, step S6 is performed to test and evaluate the performance of the pruned model, to ensure that the model performance meets the requirements.
[0053] Further, in step S6, the performance of the pruned model is comprehensively evaluated, and the test set is used to verify whether the model affects the model performance, specifically in terms of accuracy, loss value, parameter quantity and computational complexity (FLOPs: Floating Point Operations).
[0054] The application also discloses a network pruning system based on multi-scale weight analysis, which is used to execute the above method, and specifically includes the following modules:
[0055] Model loading module: load the pre-trained model that needs to be lightened, and check whether the parameters and architecture meet the subsequent operation requirements.
[0056] Automatic pruning channel number calculation module: using the method of gradient analysis to automatically calculate the sensitivity value of each convolutional layer in the pre-trained network model, and according to the sensitivity value of each layer, the pruning ratio of each convolutional layer is calculated, and the number of channels to be pruned in each layer is calculated according to the pruning ratio, and the layer with low sensitivity value will be allocated more pruning ratio.
[0057] Network pruning module: a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence is constructed, the comprehensive importance score of the convolutional channel in each convolutional layer is calculated, according to the number of channels to be pruned, the channels with lower comprehensive importance score are removed first, and the important channels with higher score are reserved to reduce the performance loss.
[0058] Fine-tuning module: the pruned model is fine-tuned and retrained, the same data set as the pre-trained model is used, and the training is similar to the original model, but the training strategy needs to be adjusted appropriately to restore and optimize the performance of the model.
[0059] Further preferably, the system further comprises an evaluation module: the pruned model is comprehensively analyzed and verified, focusing on its performance in accuracy, parameter quantity and computational complexity, etc., to ensure that the pruning operation meets the lightweight demand while maintaining the predictive ability and adaptability of the model, and provides a scientific basis for subsequent deployment.
[0060] Compared with the prior art, the beneficial effects of the present application are:
[0061] 1、The present application proposes a network pruning method based on gradient analysis to solve the problems of subjectivity, irrationality and time-consuming parameter adjustment in the traditional pruning process. By calculating the sensitivity of each convolutional layer, the pruning ratio is automatically calculated and reasonably allocated, realizing a more intelligent pruning process and significantly improving the adaptability and accuracy of the pruning strategy.
[0062] 2、The present application constructs a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence to solve the problem of losing important model information and retaining redundant channels in existing pruning methods. A new convolutional channel importance calculation method is proposed. This method not only considers the weight size comprehensively, but also combines the geometric similarity information between features, accurately quantifying the redundancy between channels. In the pruning process, it can effectively retain unique features that are critical to model performance, realizing more accurate and stable pruning optimization.
[0063] 3、The present application takes VGG16 model as an example for experimental simulation, and the results show that compared with existing pruning methods, the pruning technology of the present application significantly improves the model performance while keeping the model parameter quantity and computational complexity basically unchanged. In the experiment on CIFAR10 data set, the recognition rate is improved by 0.92%.
[0064] In summary, the network pruning method and system based on multi-scale weight analysis provided by the present application can accurately evaluate the redundancy and importance of each connection, further improve the recognition accuracy of the model while keeping the model parameter amount and computational complexity basically unchanged compared with the pruning method of the prior art, and fully verifies the significant advantages of the present application in network pruning and performance optimization. BRIEF DESCRIPTION OF DRAWINGS
[0065] Figure 1 The flowchart of the network pruning method based on multi-scale weight analysis of the preferred embodiment of the present application is shown in the figure.
[0066] Figure 2 The evaluation principle diagram of the importance of the convolution kernel based on the L2 norm is shown in the figure.
[0067] Figure 3 The calculation principle diagram based on the Euclidean distance of the convolution kernel is shown in the figure.
[0068] Figure 4 The schematic diagram of the VGG16 model structure is shown in the figure.
[0069] Figure 5 The accuracy comparison diagram of the pruning method of the multi-scale weight analysis of the preferred embodiment with the L2 norm and the Euclidean distance method is shown in the figure.
[0070] Figure 6 The accuracy comparison diagram of the pruning method of the multi-scale weight analysis of the preferred embodiment after fine-tuning with the L2 norm and the Euclidean distance method is shown in the figure.
[0071] Figure 7 The block diagram of the network pruning system based on multi-scale weight analysis of the preferred embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0072] The implementation process of the present application is described below through the preferred embodiment, and other advantages of the present application can be easily understood by those skilled in the art from the content disclosed in the specification. The present application can also be implemented or applied through other different specific embodiments, and various modifications or changes can be made to the details in the specification based on different views and applications without departing from the spirit of the present application.
[0073] Reference Figure 1 The present embodiment provides a network pruning method based on multi-scale weight analysis, which specifically includes the following steps:
[0074] S1, load the pre-trained model that needs to be lightened. The specific steps are as follows:
[0075] S11, load the pre-trained network model file containing weight parameters. The model file needs to contain the network architecture and corresponding parameters.
[0076] S12, check whether the model architecture is correctly loaded and whether it meets the requirements of subsequent operations.
[0077] S2, calculate the sensitivity of each convolutional layer in the model in step S1 based on the gradient analysis method. The specific steps are as follows:
[0078] S21, load a representative input data sample dataset, perform forward propagation according to the loss function used in the pre-trained network model, and calculate the loss function L of the model output:
[0079]
[0080] where N represents the total number of sample data sets, y i represents the true label of the i-th sample, represents the prediction output of the model for the sample, and l(·) represents the loss of a single sample.
[0081] S22, perform back propagation on the model to calculate the gradient l i of the loss L with respect to the convolutional kernel weight W
[0082]
[0083] where represents the partial derivative, and W l i represents the convolutional kernel weight matrix of the i-th channel of the l-th layer, represents the gradient value of the convolutional kernel weight of the i-th channel of the l-th layer with respect to the loss L.
[0084] S23, calculate the root mean square of the gradient values of all convolutional channel weights of the l-th layer as the sensitivity value S l of the layer:
[0085]
[0086] where represents the gradient value of the convolutional kernel weight of the i-th channel of the l-th layer with respect to the loss L, and n represents the total number of weights in the layer.
[0087] S24, normalize the sensitivity values of all convolutional layers to obtain the sensitivity normalized value S
[0088]
[0089] where S k represents the sensitivity value of the k-th layer, K represents the total number of convolutional layers of the pre-trained model, and S lSensitivity value of the lth layer.
[0090] S3, according to the sensitivity value, calculate the pruning ratio of each convolutional layer, and calculate the number of channels to be pruned according to the pruning ratio. The specific steps are as follows:
[0091] S31, calculate the pruning ratio P of the lth layer l :
[0092]
[0093] wherein, Sensitivity value of the kth layer, C k Number of channels of the kth layer, Sensitivity value of the lth layer, P total Target total pruning ratio, C l Number of channels of the lth layer, k represents the total number of convolutional layers.
[0094] S32, calculate the number of pruned channels of each layer:
[0095]
[0096] wherein, P l Pruning ratio of the lth layer, n represents the number of channels of the lth layer, Downward rounding.
[0097] S4, construct a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence, calculate the importance score of the convolution kernel of each channel in the convolutional layer of the pre-trained network model, and execute the pruning operation on the channel with lower score according to the number of channels to be pruned in the layer obtained in step S3. The specific steps are as follows:
[0098] S41, calculate the L2 norm of the convolution kernel of the lth layer channel i:
[0099]
[0100] wherein, C in Input channel number, K h And K w Respectively represent the spatial dimensions of the convolution kernel, i.e. height and width, W i,j,p,q The weight value of the i-th output channel, the j-th input channel, the p-th row and the q-th column in the weight matrix, the importance evaluation principle of the convolution kernel based on L2 norm is as shown in Figure 2 .
[0101] S42, calculate the convolution kernel W i And W jEuclidean distance matrix, shape [n, n], n is the number of channels, Euclidean distance d ij The calculation formula is:
[0102]
[0103] Wherein, W i,a,p,q and W j,a,p,q respectively represent the weight of the convolution kernel of channel i and channel j in the a-th input channel, the p-th row and the q-th column of the convolution kernel, C in represents the number of input channels, K h and K w respectively represent the spatial dimensions of the convolution kernel, i.e. height and width, and the calculation principle of the Euclidean distance based on the convolution kernel is as shown in Figure 3 .
[0104] S43, Softmax operation is performed on the negative Euclidean distance of each channel of the l-th layer, and the similarity distribution P ij between channel i and channel j is calculated.
[0105]
[0106] Wherein, d ik represents the Euclidean distance between channel i and channel k, and k represents the output channel index of the convolution layer.
[0107] S44, the concentration degree of the channel similarity distribution is evaluated using the KL divergence formula:
[0108]
[0109] Wherein, P ij represents the similarity distribution of channel i and channel j, P ik represents the similarity distribution of channel i and channel k, e -7 represents a smoothing term for preventing the denominator from being zero.
[0110] S45, sum the rows of the KL divergence matrix, and add the L2 norm value of its own convolution channel to obtain the comprehensive importance score of channel i:
[0111]
[0112] Wherein, KL(P ij ) represents the concentration degree of the similarity distribution of channel i, W i represents the L2 norm of channel i, and a represents a hyperparameter, which is between 0 and 1 in the embodiment.
[0113] S46, sort the comprehensive importance scores of all channels of the l-th layer in descending order, and sort the channels with lower scores in the last The channel performs a pruning operation.
[0114] Score = [Score1, Score2, …, Score k ] and Score1≥ Score2≥ ··· ≥ Score k
[0115] S5, fine-tuning retraining, the specific steps are as follows:
[0116] S51, using the weight of the model before pruning as initialization after pruning, and keeping the part of the weight that is not pruned.
[0117] S52, retraining using the pruned model, the training data set is unchanged. Similar to the original model training, but need to adjust the training strategy, including learning rate, training rounds, optimizer, etc.
[0118] S6, using the test set to comprehensively evaluate the pruned model, check whether the pruned model significantly affects the model performance. The following are common evaluation indicators, including accuracy, loss value and parameter quantity, computational complexity, etc.
[0119] According to the above embodiment, the experiment is carried out: taking CIFAR-10 dataset as an example, wherein the training sample is 50,000 and the test sample is 10,000. The VGG16 model is trained and pruned in this experiment, and the VGG16 model structure is as follows Figure 4 . The total pruning ratio P total is set to be between 0.1 and 0.9, the network pruning method based on multi-scale weight analysis of the preferred embodiment of the application is used to prune the model, wherein the hyperparameter a is set to 0.8, and the traditional L2 norm pruning and the pruning method based on Euclidean distance are compared. The specific results are shown in Figure 5 , Figure 5 It is shown that under the same pruning ratio, the recognition effect of the pruned model of the method of the application is better than that of the traditional method. In the comparison test of fine-tuning retraining of the pre-trained model for 200 rounds after pruning, the results are shown in Figure 6 . Figure 6 It is shown that the recognition effect of the method of the application after pruning is still better than that of the traditional method, which further verifies the superiority of the multi-scale weight analysis pruning method of the application. Therefore, the network pruning method of this embodiment significantly improves the recognition accuracy of the model while keeping the model lightweight.
[0120] As shown in Figure 7 , the embodiment discloses a network pruning system based on multi-scale weight analysis, which is used to execute the above method embodiments, and specifically includes the following modules:
[0121] The model loading module loads a pre-trained network model that needs to be lightened, and checks whether the parameters and architecture of the pre-trained network model meet the requirements of subsequent operations.
[0122] The automatic channel pruning number calculation module automatically calculates the sensitivity values of each convolutional layer in the pre-trained network model using a gradient analysis method, calculates the pruning proportion of each convolutional layer according to the sensitivity value of each layer, calculates the number of channels to be pruned for each layer according to the pruning proportion, and allocates more pruning proportion to the layer with a lower sensitivity value.
[0123] The network pruning module constructs a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence, calculates the importance score of the convolution kernel of each channel in each convolutional layer, performs channel pruning operation on the convolutional layer according to the number of channels to be pruned, preferentially removes channels with lower comprehensive importance score, and preserves important channels with higher score to reduce performance loss.
[0124] The fine-tuning module fine-tunes and re-trains the pruned model, uses the same training data set as the original model, and adjusts the training strategy appropriately to restore and optimize the performance of the model.
[0125] The evaluation module comprehensively analyzes and verifies the performance of the pruned model, focuses on evaluating its performance in terms of accuracy, parameter quantity and computational complexity, and ensures that the pruning operation meets the lightening requirements while maintaining the predictive ability and adaptability of the model, providing a scientific basis for subsequent deployment.
[0126] Other contents of the embodiment can refer to the above method embodiment.
[0127] The above is only the preferred embodiment of the present application and the technical principle applied. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and various obvious changes, re-adjustments and substitutions can be made without departing from the scope of the present application. Therefore, although the present application has been described in detail through the above embodiments, the present application is not limited to the above embodiments, and can include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.
Claims
1. A network pruning method based on multi-scale weight analysis, characterized in that, Specifically comprising the following steps: S1, load the pre-trained network model that needs to be lightened; S2, calculate the sensitivity value of each convolutional layer in step S1 based on the gradient analysis method; S3, calculate the pruning ratio of each convolutional layer according to the sensitivity value obtained in step S2, and calculate the number of channels to be pruned in each convolutional layer according to the pruning ratio; S4, construct a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence, calculate the importance score of the channels in each convolutional layer of the pre-trained network model, and perform pruning operation on the channels with a score lower than the predetermined pruning ratio according to the number of channels to be pruned in the layer; S5, fine-tune and retrain the pruned model; Step S2 is specifically as follows: S21, load a representative input data sample dataset, perform forward propagation according to a loss function used in the pre-trained network model, calculate the loss function of the model output L : where N denotes the total number of sample datasets, y i denotes the true label of the i-th sample, denotes the predicted output of the model for this sample, denotes the loss for a single sample; S22, performing back propagation on the model to calculate the gradient of the loss L with respect to the convolution kernel weight of the i-th channel of the l-th layer : wherein, denotes a partial derivative, denotes a convolution kernel weight matrix of the i-th channel of the l-th layer, denotes a gradient value of the convolution kernel weight of the i-th channel of the l-th layer with respect to the loss L; S23, calculate the root mean square of the gradient values of all convolution channel weights of the lth layer as the sensitivity value S of the lth layer l : wherein, denotes the gradient value of the convolution kernel weight of the i-th channel of the l-th layer to the loss L, and n denotes the total number of weights of the l-th layer; S24, normalize the sensitivity values of all convolutional layers to obtain the sensitivity normalized value of the lth layer : wherein S k represents the sensitivity value of the kth layer, K represents the total number of pre-training model convolution layers, S l represents the sensitivity value of the lth layer.
2. The method of claim 1, wherein, In step S1, the pre-trained network model file containing weight parameters is loaded, and the model file contains network architecture and corresponding parameters.
3. The method of claim 1, wherein the method further comprises: Step S3 is specifically as follows: S31, calculate the lth layer pruning ratio P l : wherein, denotes the normalized sensitivity value of the kth layer, C k denotes the number of channels of the kth layer, denotes the normalized sensitivity value of the lth layer, P total denotes the target total pruning ratio, C l denotes the number of channels of the lth layer, k denotes the total number of convolutional layers; S32, calculate the number of pruned channels in each layer: where P l represents the pruning ratio of the lth layer, n represents the number of channels of the lth layer, represents the floor function.
4. The network pruning method based on multi-scale weight analysis according to claim 3, characterized in that, In step S4, a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence is constructed, the importance score of the convolution kernel of each channel in each convolutional layer is calculated, and pruning operation is performed on the channels with smaller score, the specific steps are as follows: S41, calculate the L2 norm of the convolution kernel of the i-th channel in the l-th layer: wherein C in represents the number of input channels, K h and K w respectively represent the spatial dimension height and width of the convolution kernel, W i,j,p,q represents the weight value of the i-th output channel, the j-th input channel, the p-th row, and the q-th column in the weight matrix; S42, calculate the convolution kernel W of any two channels of the lth layer i and W j Euclidean distance, shape [n, n], n is the number of channels, Euclidean distance d ij The calculation formula is: wherein W i,a,p,q and W j,a,p,q respectively represent the weight of the convolution kernel of channel i and channel j at the a-th input channel, the p-th row and the q-th column of the convolution kernel, C in represents the number of input channels, K h and K w respectively represent the spatial dimension height and width of the convolution kernel; S43, Softmax operation is performed on the negative Euclidean distance of each channel of the first layer to calculate the similarity distribution P of channel i and channel j ij : where d ik denotes the Euclidean distance between channel i and channel k, k denotes the output channel index of the convolutional layer; S44, use the KL divergence formula to evaluate the concentration degree of the similarity distribution of the channel: where P ij represents the similarity distribution of channel i with channel j, P ik represents the similarity distribution of channel i with channel k, e -7 represents a smoothing term to prevent the denominator from being zero; S45, sum the rows of the KL divergence matrix, and add the L2 norm value of the convolution channel itself to obtain the comprehensive importance score of the channel i: where KL(P ij ) denotes the concentration of the similarity distribution of channel i, W i denotes the L2 norm of channel i, denotes a hyperparameter; S46, rank the integrated importance scores of all channels in the lth layer in descending order and perform pruning operation on the channels with lower scores in the back 。 5. The network pruning method based on multi-scale weight analysis according to any one of claims 1-4, characterized in that, In step S5, fine-tune and retrain, the specific steps are as follows: S51, use the weights of the model before pruning as initialization after pruning, and keep the weights of the part not pruned; S52, retrain the pruned model using the same training data set; Train in the same way as the original model.
6. The network pruning method based on multi-scale weight analysis according to any one of claims 1-4, characterized in that, After step S5, step S6 is performed: performance test and evaluation of the pruned model.
7. The network pruning method based on multi-scale weight analysis according to claim 6, characterized in that, In step S6, the evaluation indexes include accuracy, loss value, parameter quantity and calculation complexity.
8. A network pruning system based on multi-scale weight analysis for performing the method of any one of claims 1-5, characterized in that, The system specifically comprises the following modules: Model loading module: load the pre-trained network model that needs to be lightened; Automatic calculation of pruning channel number module: use the gradient analysis method to calculate the sensitivity value of each convolutional layer in the pre-trained network model after normalization, and calculate the pruning ratio of each convolutional layer according to the sensitivity value of each convolutional layer, and calculate the number of channels to be pruned in each convolutional layer according to the pruning ratio; Network pruning module: construct a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence, calculate the importance score of the convolution kernel of each channel in each convolutional layer, and perform pruning operation on the channels with a score lower than the predetermined pruning ratio according to the number of channels to be pruned; Fine-tuning module: fine-tune and retrain the pruned model.
9. The system for network pruning based on multi-scale weight analysis of claim 8, wherein, Also includes: Evaluation module: performance test and evaluation of the pruned model.
Citation Information
Patent Citations
Convolutional neural network channel self-selection compression and acceleration method based on knowledge migration
CN109993302A
Hidden information detection method and system based on generation of embedded probability graph
CN112785478A