Network pruning method and system based on multi-scale weight analysis

The multi-scale weight analysis method evaluates the importance of channels in deep neural networks, which solves the problem that existing pruning methods cannot fully consider channel correlation, and achieves more efficient model lightweighting and performance improvement.

CN119918608AActive Publication Date: 2025-05-02HANGZHOU DIANZI UNIV

Patent Information

Application Number
CN202411866668.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-05-02
Estimated Expiration
2044-12-18

AI Technical Summary

Technical Problem

Existing network pruning methods cannot fully consider the correlation between channels, resulting in a degradation of model performance. Traditional methods are prone to losing important model information or retaining redundant channels during pruning.

Method used

The network pruning method based on multi-scale weight analysis is adopted to calculate the sensitivity value of the convolution layer through gradient analysis, and a multi-scale weight analysis model of L2 norm, Euclidean distance and KL divergence is constructed to calculate the importance score of the channel, and pruning operations are performed based on the score.

Benefits of technology

A more accurate channel importance assessment is achieved, and the key features of model performance is effectively retained, the recognition accuracy of the model is improved, and the pruning rate is significantly improved while keeping the model lightweight.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119918608A_ABST
    Figure CN119918608A_ABST
Patent Text Reader

Abstract

The invention discloses a network pruning method and system based on multi-scale weight analysis. The method comprises the following steps: S1, loading a pre-training network model which needs to be lightened; s2, calculating the normalized sensitivity value of each convolution layer in the model in the step S1 based on a gradient analysis method; s3, according to the sensitivity value obtained in the step S2, calculating the pruning proportion of each convolutional layer, and according to the pruning proportion, calculating the number of channels needing to be pruned in each layer; s4, constructing a multi-scale weight analysis model based on an L2 norm, an Euclidean distance and KL divergence, calculating importance scores of channels in each convolution layer of the pre-trained network model, obtaining the number of channels needing to be cut out of the layer according to the step S3, and performing pruning operation on the channels of which the scores are lower than a preset pruning proportion; and S5, performing fine tuning and re-training on the pruned model. According to the method, the channel redundancy and importance are accurately evaluated, so that the accuracy of image recognition can be further improved under the same pruning proportion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of lightweight deep learning networks, and specifically relates to a network pruning method and system for multi-scale weight analysis. The present invention achieves efficient pruning by evaluating the importance of network channels, reduces the amount of calculation and storage requirements while maintaining model accuracy, and is suitable for deep learning model deployment on resource-constrained devices. Background Art

[0002] With the rapid development of deep learning in fields such as 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 and high computing and storage requirements, making them difficult to deploy directly 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] As one of the main methods for model lightweighting, network pruning aims to reduce computational complexity and storage occupancy by removing redundant weights or channels, thereby accelerating the reasoning process and reducing resource consumption. Traditional pruning methods are usually based on standards such as L1 norm, L2 norm or weight threshold, but these methods cannot fully consider the similarity or correlation between different channels, and may lose important model information or retain redundant channels during the pruning process, thereby affecting the model accuracy and lightweight effect. In order to solve this problem, in recent years, a pruning method based on Euclidean distance has been introduced. It evaluates redundancy by calculating the geometric similarity between channels, and preferentially removes channels with higher redundancy, effectively reducing the parameter redundancy of the model. However, while removing redundant channels, this method may still retain channels with lower weight values ​​and smaller actual contributions, resulting in limited pruning effects. Therefore, how to further improve the network compression rate while ensuring that the model accuracy is not affected is still an important problem to be solved in pruning research. Based on this, the present invention proposes a network pruning method and system based on multi-scale weight analysis. Summary of the invention

[0004] In order to address the problems of inaccurate redundant channel selection in the lightweight process of existing network models and the failure of traditional pruning methods to fully consider the correlation between channels, resulting in a significant decline in model performance, in order to improve the operating efficiency of deep neural networks in resource-constrained environments and further improve the pruning rate while maintaining model accuracy, the present invention proposes a network pruning method and system based on multi-scale weight analysis.

[0005] In order to achieve the above purpose, the present invention adopts the following technical solutions:

[0006] A network pruning method based on multi-scale weight analysis comprises the following steps:

[0007] S1, load the pre-trained network model that needs to be lightweight;

[0008] S2, calculating the normalized sensitivity value of each convolutional layer in the model of step S1 based on the gradient analysis method;

[0009] 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 layer 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 channel in each convolutional layer of the pre-trained network model, obtain the number of channels to be pruned in the layer according to step S3, and perform pruning operations on channels whose scores are lower than the predetermined pruning ratio;

[0011] S5. Fine-tune and retrain the pruned model.

[0012] Furthermore, in step S1, a pre-trained deep neural network model including weight parameters is loaded, and the model file includes a network architecture and corresponding parameters, and its parameters and architecture are checked to see whether they meet the requirements of subsequent operations.

[0013] Furthermore, in step S2, the normalized sensitivity of each convolutional 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 data set, perform forward propagation according to the loss function used in the pre-trained network model (such as cross entropy loss in classification tasks or mean square error loss in regression tasks), 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 model’s predicted output for the sample, and l(·) represents the loss of a single sample;

[0017] Step S22, perform back propagation on the model and calculate the loss L about the convolution kernel weight W of the i-th channel of the l-th layer l i Gradient

[0018]

[0019] in, represents the partial derivative, W l i represents the convolution kernel weight matrix of the i-th channel of the l-th layer, Represents the gradient value of the convolution kernel weight of the i-th channel of the l-th layer to the loss L;

[0020] Step S23: Calculate the root mean square of the gradient values ​​of all channel weights of each convolutional layer as the sensitivity value S of the layer. l :

[0021]

[0022] in, represents the gradient value of the convolution kernel weight of the i-th channel of the l-th layer to the loss L, and n represents the total number of weights in the l-th layer;

[0023] Step S24, normalize the sensitivity values ​​of all convolutional layers to obtain the normalized sensitivity values ​​of each layer

[0024]

[0025] Among them, S k represents the sensitivity value of the kth layer, K represents the total number of convolutional layers of the pre-trained model, and S l Represents the sensitivity value of the lth layer.

[0026] Furthermore, in step S3, 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. The specific steps are as follows:

[0027] Step S31: based on the normalized sensitivity value of the first layer Calculate the pruning ratio P of the l-th layer model l :

[0028]

[0029] in, represents the normalized sensitivity value of the kth layer, C k represents the number of channels in the kth layer, represents the normalized sensitivity value of the lth layer, P total Indicates the target total pruning ratio, C l represents the number of channels in the lth layer, and k represents the total number of convolutional layers;

[0030] Step S32: according to the pruning ratio P l Calculate the number of pruning channels for each layer

[0031]

[0032] Among them, P l represents the pruning ratio of the lth layer, n represents the number of channels in the lth layer, Indicates rounding down.

[0033] Furthermore, in step S4, the specific steps of model design are as follows:

[0034] Step S41, for each convolution channel in the lth layer, calculate its channel L2 norm:

[0035]

[0036] Among them, C in Indicates the number of input channels, K h and K w Respectively represent the spatial dimensions of the convolution kernel, namely the height and width, W i,j,p,q Represents the weight value of the i-th output channel, j-th input channel, p-th row, and q-th column in the weight matrix;

[0037] Step S42, calculate the convolution kernel W of any two channels in the lth layer i and W j The Euclidean distance of the shape is [n,n], n is the number of channels, and the Euclidean distance d ij The calculation formula is:

[0038]

[0039] Among them, W i,a,p,q and W j,a,p,q represents the weights of the convolution kernel of channel i and channel j at the ath input channel, the pth row, and the qth column, respectively. in Indicates the number of input channels, K h and K w Respectively represent the spatial dimensions of the convolution kernel, namely height and width;

[0040] Step S43, perform a Softmax (normalized exponential function) operation on the negative Euclidean distance of each channel to calculate the similarity distribution P between channel i and channel j ij :

[0041]

[0042] Among them, d ik represents the Euclidean distance between channel i and channel k, where k represents the output channel index of the convolutional layer;

[0043] Step S44, use the KL divergence formula to evaluate the concentration of the convolution channel similarity distribution:

[0044]

[0045] Among them, P ij represents the similarity distribution between channel i and channel j, P ikrepresents the similarity distribution between channel i and channel k, e -7 represents a smoothing term used to prevent 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; the L2 norm value of the convolution channel in each layer plus the similarity score of its Euclidean distance is used as the comprehensive importance score of each channel:

[0047]

[0048] Among them, KL(P ij ) represents the concentration of the similarity distribution of channel i, W i represents the L2 norm of channel i, α represents a hyperparameter, preferably between 0 and 1;

[0049] Step S46, sort the comprehensive importance scores of each convolution channel layer from large to small; according to the number of channel pruning in each layer in S32 For those with lower overall importance scores Pruning is performed on each channel:

[0050] Score=[Score1,Score2,...,Score k ] and Score1≥Score2≥···≥Score k

[0051] Furthermore, in step S5, the weights of the model before pruning are used as initialization after pruning, and the weights of the unpruned parts are retained; the pruned model is retrained, and the training data set remains unchanged. This is similar to the original model training, but the training strategy needs to be appropriately adjusted, including the learning rate, number of training rounds, optimizer, etc.

[0052] Furthermore, after step S5, step S6 is performed to perform performance testing and evaluation on the pruned model to ensure that the model performance meets the requirements.

[0053] Furthermore, in step S6, the performance of the pruned model is comprehensively evaluated, and a test set is used to verify whether the model affects the performance of the model, specifically in terms of accuracy, loss value, number of parameters, and computational complexity (FLOPs: Floating Point Operations).

[0054] The present invention 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: loads the pre-trained model that needs to be lightweight and checks whether its parameters and architecture meet the requirements of subsequent operations.

[0056] Automatic calculation of the number of pruned channels module: Use the gradient analysis method to automatically calculate the sensitivity value of each convolutional layer in the pre-trained network model, and calculate the pruning ratio of each convolutional layer based on the sensitivity value of each layer. According to the pruning ratio, the number of channels to be pruned in each layer is calculated. Layers with low sensitivity values ​​will be allocated more pruning ratios.

[0057] Network pruning module: Construct a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence, calculate the comprehensive importance score of the convolution channel in each convolution layer, and remove channels with low comprehensive importance scores first according to the number of channels to be pruned, and retain important channels with higher scores to reduce performance loss.

[0058] Fine-tuning module: Fine-tune and retrain the pruned model using the same dataset as the pre-trained model. This is similar to the original model training, but the training strategy needs to be appropriately adjusted to restore and optimize the model's performance.

[0059] Further preferably, the system also includes an evaluation module: performing comprehensive performance analysis and verification on the pruned model, focusing on evaluating its performance in terms of accuracy, number of parameters, and computational complexity, to ensure that the pruning operation maintains the predictive ability and adaptability of the model while meeting lightweight requirements, providing a scientific basis for subsequent deployment.

[0060] Compared with the prior art, the present invention has the following beneficial effects:

[0061] 1. In order to solve the problems of subjectivity, irrationality and time-consuming parameter adjustment caused by manually setting the pruning ratio in the traditional pruning process, the present invention proposes a network pruning method based on gradient analysis. By calculating the sensitivity of each convolutional layer, the pruning ratio is automatically calculated and reasonably allocated, a more intelligent pruning process is achieved, which significantly improves the adaptability and accuracy of the pruning strategy.

[0062] 2. Aiming at the problem of losing important model information and retaining redundant channels in existing pruning methods, the present invention constructs a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence, and proposes a new convolution channel importance calculation method. This method not only comprehensively considers the weight size, but also combines the geometric similarity information between features to accurately quantify the redundancy between channels. During the pruning process, the unique features that are key to model performance can be effectively retained, achieving more accurate and stable pruning optimization.

[0063] 3. The present invention uses the VGG16 model as an example to conduct experimental simulations. The results show that compared with the existing pruning methods, the pruning technology of the present invention significantly improves the model performance while keeping the model parameters and computational complexity basically unchanged. In the experiment on the CIFAR10 dataset, the recognition rate increased by 0.92%.

[0064] In summary, the network pruning method and system based on multi-scale weight analysis proposed in the present invention, by accurately evaluating the redundancy and importance of each connection, further improves the recognition accuracy of the model while keeping the model parameter quantity and computational complexity basically unchanged compared with the pruning method in the prior art, fully verifying the significant advantages of the present invention in network pruning and performance optimization. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Figure 1 This is a flow chart of a network pruning method based on multi-scale weight analysis in a preferred embodiment of the present invention;

[0066] Figure 2 This is a schematic diagram of the convolution kernel importance evaluation based on the L2 norm;

[0067] Figure 3 Schematic diagram of the calculation principle based on the convolution kernel Euclidean distance;

[0068] Figure 4 Schematic diagram of the VGG16 model structure;

[0069] Figure 5 This is a comparison chart of the accuracy of the pruning method of multi-scale weight analysis in the preferred embodiment with the L2 norm and the Euclidean distance method;

[0070] Figure 6 This is a comparison chart of the accuracy of the pruning method of the multi-scale weight analysis in the preferred embodiment after fine-tuning and the L2 norm and Euclidean distance methods;

[0071] Figure 7 The figure is a block diagram of a network pruning system based on multi-scale weight analysis according to a preferred embodiment of the present invention. DETAILED DESCRIPTION

[0072] The following describes the implementation process of the present invention through preferred embodiments, and those skilled in the art can easily understand other advantages of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention.

[0073] See also Figure 1 This 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 lightweight. The specific steps are as follows:

[0075] S11. Load the pre-trained network model file containing weight parameters. The model file must contain the network architecture and corresponding parameters.

[0076] S12. Check whether the model architecture is loaded correctly and whether it meets the subsequent operation requirements.

[0077] S2. Calculate the normalized sensitivity of each convolutional layer in the model of 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 model’s predicted output for the sample, and l(·) represents the loss of a single sample;

[0081] S22. Perform back propagation on the model and calculate the loss L about the convolution kernel weight W of the i-th channel of the l-th layer l i Gradient

[0082]

[0083] in, represents the partial derivative, W l i represents the convolution kernel weight matrix of the i-th channel of the l-th layer, Represents the gradient value of the convolution kernel weight of the i-th channel of the l-th layer to the loss L.

[0084] S23, calculate the root mean square of the gradient values ​​of all convolution channel weights in layer l as the sensitivity value S of this layer l :

[0085]

[0086] in, It represents the gradient value of the convolution kernel weight of the i-th channel of the l-th layer to the loss L, and n represents the total number of weights of this layer.

[0087] S24. Normalize the sensitivity values ​​of all convolutional layers to obtain the normalized sensitivity value of the layer.

[0088]

[0089] Among them, S k represents the sensitivity value of the kth layer, K represents the total number of convolutional layers of the pre-trained model, and S lRepresents the sensitivity value of the lth layer.

[0090] S3. Calculate the pruning ratio of each convolutional layer based on the sensitivity value, and calculate the number of channels to be pruned in each layer based on the pruning ratio. The specific steps are as follows:

[0091] S31, calculate the pruning ratio P of the first layer l :

[0092]

[0093] in, represents the normalized sensitivity value of the kth layer, C k represents the number of channels in the kth layer, represents the normalized sensitivity value of the lth layer, P total Indicates the target total pruning ratio, C l represents the number of channels in the lth layer, and k represents the total number of convolutional layers.

[0094] S32. Calculate the number of pruning channels at each layer:

[0095]

[0096] Among them, P l represents the pruning ratio of the lth layer, n represents the number of channels in the lth layer, Indicates rounding down.

[0097] S4, build a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence, calculate the convolution kernel importance score of the channel in each convolution layer of the pre-trained network model, obtain the number of channels to be pruned in this layer according to step S3, and perform pruning operations on channels with lower scores. The specific steps are as follows:

[0098] S41. Calculate the L2 norm of the convolution kernel of channel i in layer l:

[0099]

[0100] Among them, C in Indicates the number of input channels, K h and K w Respectively represent the spatial dimensions of the convolution kernel, namely the height and width, W i,j,p,q Represents the weight value of the i-th output channel, j-th input channel, p-th row, and q-th column in the weight matrix. The principle of convolution kernel importance evaluation based on L2 norm calculation is as follows Figure 2 shown.

[0101] S42, calculate the convolution kernel W of any two channels in the lth layer i and W jThe Euclidean distance matrix of shape is [n,n], where n is the number of channels and the Euclidean distance d is ij The calculation formula is:

[0102]

[0103] Among them, W i,a,p,q and W j,a,p,q represents the weights of the convolution kernel of channel i and channel j at the ath input channel, the pth row, and the qth column, respectively. in Indicates the number of input channels, K h and K w They represent the spatial dimensions of the convolution kernel, namely the height and width, respectively. The calculation principle of the Euclidean distance of the convolution kernel is as follows: Figure 3 shown.

[0104] S43, perform Softmax operation on the negative Euclidean distance of each channel in the lth layer, and calculate the similarity distribution P between channel i and channel j ij :

[0105]

[0106] Among them, d ik represents the Euclidean distance between channel i and channel k, and k represents the output channel index of the convolutional layer.

[0107] S44. Use the KL divergence formula to evaluate the concentration of channel similarity distribution:

[0108]

[0109] Among them, P ij represents the similarity distribution between channel i and channel j, P ik represents the similarity distribution between channel i and channel k, e -7 represents a smoothing term used to prevent the denominator from reaching 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] Among them, KL(P ij ) represents the concentration of the similarity distribution of channel i, W i represents the L2 norm of channel i, α represents a hyperparameter, and in this embodiment, the value of α is between 0 and 1.

[0113] S46, sort the comprehensive importance scores of all channels in the first layer from large to small and sort the channels with lower scores. Pruning is performed on each channel.

[0114] Score=[Score1,Score2,...,Score k ] and Score1≥Score2≥···≥Score k

[0115] S5. Perform fine-tuning and retraining. The specific steps are as follows:

[0116] S51. After pruning, the weights of the model before pruning are used as initialization, and the weights that have not been pruned are retained.

[0117] S52: Retrain the pruned model with the same training data set. This is similar to the original model training, but the training strategy needs to be adjusted appropriately, including the learning rate, number of training rounds, and optimizer.

[0118] S6. Use the test set to fully evaluate the pruned model to check whether the pruned model significantly affects the model performance. The following are common evaluation indicators, including accuracy, loss value, number of parameters, computational complexity, etc.

[0119] According to the above embodiment, an experiment is conducted: taking the CIFAR-10 dataset as an example, there are 50,000 training samples and 10,000 test samples. This experiment trains and prunes the VGG16 model. The VGG16 model structure is as follows: Figure 4 Total pruning ratio P total The model is pruned using the network pruning method based on multi-scale weight analysis in the preferred embodiment of the present invention, where the hyperparameter α is set to 0.8, and compared with the traditional L2 norm pruning and the pruning method based on Euclidean distance. For specific results, see Figure 5 , Figure 5 It shows that under the same pruning ratio, the recognition effect of the model pruned by the proposed method is better than that of the traditional method. In the comparative test of fine-tuning and retraining 200 rounds after pruning the pre-trained model, the results are shown in Figure 6 . Figure 6 It shows that the recognition effect of the method of the present invention 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 present invention. Therefore, the network pruning method of this embodiment significantly improves the recognition accuracy of the model while keeping the model lightweight.

[0120] like Figure 7 As shown, this embodiment discloses a network pruning system based on multi-scale weight analysis, which is used to execute the above method embodiment, and specifically includes the following modules:

[0121] Model loading module: loads the pre-trained network model that needs to be lightweight and checks whether its parameters and architecture meet the requirements of subsequent operations.

[0122] Automatic calculation of the number of pruned channels module: Use the gradient analysis method to automatically calculate the sensitivity value of each convolutional layer in the pre-trained network model, calculate the pruning ratio of each convolutional layer based on the sensitivity value of each layer, and calculate the number of channels to be pruned in each layer based on the pruning ratio. Layers with low sensitivity values ​​will be allocated more pruning ratios.

[0123] Network pruning module: Construct a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence, calculate the convolution kernel importance score of the channel in each convolution layer, perform channel pruning operations on the convolution layer according to the number of channels to be pruned, and preferentially remove channels with lower comprehensive importance scores, retaining important channels with higher scores to reduce performance loss.

[0124] Fine-tuning module: Fine-tune and retrain the pruned model, using the same training dataset. This is similar to training the original model, but the training strategy needs to be adjusted appropriately to restore and optimize the model's performance.

[0125] Evaluation module: Performs comprehensive performance analysis and verification on the pruned model, focusing on evaluating its performance in terms of accuracy, number of parameters, and computational complexity, to ensure that the pruning operation meets lightweight requirements while maintaining the model's predictive ability and adaptability, providing a scientific basis for subsequent deployment.

[0126] For other contents of this embodiment, please refer to the above method embodiment.

[0127] The above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A network pruning method based on multi-scale weight analysis, characterized by: The specific steps include: S1, load the pre-trained network model that needs to be lightweight; S2, calculating the normalized sensitivity value of each convolutional layer in the model of 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 from each convolutional layer according to the pruning ratio; S4, constructing a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence, calculating the importance score of the channels in each convolution layer of the pre-trained network model, obtaining the number of channels to be pruned in the convolution layer according to step S3, and performing pruning operations on channels whose scores are lower than a predetermined pruning ratio; S5. Fine-tune and retrain the pruned model.

2. The network pruning method based on multi-scale weight analysis according to claim 1, characterized in that: In step S1, a pre-trained network model file containing weight parameters is loaded, and the model file contains a network architecture and corresponding parameters.

3. The network pruning method based on multi-scale weight analysis according to claim 2, characterized in that: Step S2 is specifically as follows: 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: Where N represents the total number of sample data sets, y i represents the true label of the i-th sample, Represents the model's predicted output for this sample, Represents the loss of a single sample; S22. Perform back propagation on the model and calculate the loss L about the convolution kernel weight W of the i-th channel of the l-th layer l i Gradient in, represents the partial derivative, W l i represents the convolution kernel weight matrix of the i-th channel of the l-th layer, Represents the gradient value of the convolution kernel weight of the i-th channel of the l-th layer to the loss L; S23, calculate the root mean square of the gradient values ​​of all convolution channel weights in the lth layer as the sensitivity value S of the lth layer l : in, represents the gradient value of the convolution kernel weight of the i-th channel of the l-th layer to the loss L, and n represents the total number of weights in the l-th layer; S24, normalize the sensitivity values ​​of all convolutional layers to obtain the normalized sensitivity value of the lth layer Among them, S k represents the sensitivity value of the kth layer, K represents the total number of convolutional layers of the pre-trained model, and S l Represents the sensitivity value of the lth layer.

4. The network pruning method based on multi-scale weight analysis according to claim 3 is characterized in that: Step S3 is as follows: S31, calculate the pruning ratio P of the first layer l : in, represents the normalized sensitivity value of the kth layer, C k represents the number of channels in the kth layer, represents the normalized sensitivity value of the lth layer, P total Indicates the target total pruning ratio, C l represents the number of channels in the lth layer, and k represents the total number of convolutional layers; S32. Calculate the number of pruning channels at each layer: Among them, P l represents the pruning ratio of the lth layer, n represents the number of channels in the lth layer, Indicates rounding down.

5. The network pruning method based on multi-scale weight analysis according to claim 4, characterized in that: In step S4, a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence is constructed to calculate the convolution kernel importance score of the channel in each convolution layer, and prune the channel with a smaller score. The specific steps are as follows: S41. Calculate the L2 norm of the convolution kernel of channel i in layer l: Among them, C in Indicates 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, j-th input channel, p-th row, and q-th column in the weight matrix; S42, calculate the convolution kernel W of any two channels in the lth layer i and W j The Euclidean distance of the shape is [n,n], n is the number of channels, and the Euclidean distance d ij The calculation formula is: Among them, W i,a,p,q and W j,a,p,q represents the weights of the convolution kernel of channel i and channel j at the ath input channel, the pth row, and the qth column, respectively. in Indicates the number of input channels, K h and K w Respectively represent the spatial dimension height and width of the convolution kernel; S43, perform Softmax operation on the negative Euclidean distance of each channel in the lth layer, and calculate the similarity distribution P between channel i and channel j ij : Among them, d ik represents the Euclidean distance between channel i and channel k, where k represents the output channel index of the convolutional layer; S44. Use the KL divergence formula to evaluate the concentration of channel similarity distribution: Among them, P ij represents the similarity distribution between channel i and channel j, P ik represents the similarity distribution between channel i and channel k, e -7 represents a smoothing term used to prevent the denominator from being zero; 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: Among them, KL(P ij ) represents the concentration of the similarity distribution of channel i, W i represents the L2 norm of channel i, and α represents a hyperparameter; S46, sort the comprehensive importance scores of all channels in the first layer from large to small and sort the channels with lower scores. Pruning is performed on each channel: Score = [Score1, Score2,..., Score k and Score1 ≥ Score2 ≥ ··· ≥ Score k .

6. The network pruning method based on multi-scale weight analysis according to any one of claims 1 to 5, characterized in that: In step S5, fine-tuning and retraining are performed, and the specific steps are as follows: S51, after pruning, use the weights of the model before pruning as initialization, and retain the weights of the unpruned part; S52, retrain using the pruned model, with the training data set unchanged; The training is performed in the same way as the original model.

7. The network pruning method based on multi-scale weight analysis according to any one of claims 1 to 5, characterized in that: After step S5, step S6 is performed: performance testing and evaluation of the pruned model.

8. The network pruning method based on multi-scale weight analysis according to claim 7, characterized in that: In step S6, the evaluation indicators include accuracy, loss value, parameter quantity, and computational complexity.

9. A network pruning system based on multi-scale weight analysis, used to execute the method according to any one of claims 1 to 6, characterized in that: The system specifically includes the following modules: Model loading module: loads pre-trained network models that need to be lightweight; Automatic calculation of the number of pruned channels module: Use the gradient analysis method to calculate the normalized sensitivity value of each convolutional layer in the pre-trained network model, and calculate the pruning ratio of each convolutional layer based on the sensitivity value of each convolutional layer, and calculate the number of channels to be pruned in each convolutional layer based on the pruning ratio; Network pruning module: constructs a multi-scale weight analysis model based on L2 norm, Euclidean distance and KL divergence, calculates the convolution kernel importance score of the channel in each convolution layer, and performs pruning operations on channels with scores 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.

10. The network pruning system based on multi-scale weight analysis according to claim 9, characterized in that: Also includes: Evaluation module: Perform performance testing and evaluation on 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

  • Pedestrian detection method based on knowledge migration pruning model

    CN117315722A

Cited By

  • Transform model lightweight method and power transmission line image analysis method

    CN120910703A

  • Fluid force field simulation prediction method based on lightweight conditional diffusion model

    CN120974942A

  • Offshore wind turbine generator fault defect identification system based on multi-source data fusion

    CN121024839A

  • Traffic flow prediction method and device based on model lightweight, and medium

    CN121438577A

  • Traffic sign detection method and device, and computer equipment

    CN121811369A