Deep learning model pruning method
By creating initial random images in the deep learning model and optimizing them, combining the loss function and predicted probability, deep learning model pruning in the zero-sample situation is achieved, solving the problem that the existing technology cannot analyze the degree of influence of neurons and improving the reliability of model pruning.
Patent Information
- Application Number
- CN202411974650.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2044-12-30
AI Technical Summary
The prior art cannot effectively prune the deep learning model in the case of zero samples, especially when real samples or reference models cannot be obtained, and the extent of the impact of neurons on specific categories cannot be analyzed.
A zero-sample model pruning method based on deep learning is proposed. By creating an initial random image and normalizing it, the output mean and classification probability vector of neurons are calculated, the loss function is set for multiple rounds of optimization, and finally determining whether pruning is performed based on the predicted probability.
It realizes that critical neurons can be judged without real images or reference models in the case of zero samples, improving the reliability and applicability of model pruning.
Smart Images

Figure CN119903889A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of lightweight deep learning, and in particular to a model pruning method based on deep learning without the participation of real samples. Background Art
[0002] In the practical application of deep learning, there are a large number of scenarios where models need to be deployed on hardware with limited computing and storage resources. In this case, a lightweight model is needed to complete the task with a smaller number of parameters and a faster speed. Model pruning is an important way to lightweight the model. Its core idea is to select neurons with high information content and delete neurons with low information content. The current model pruning algorithm has a strong dependence on the data set. In most cases, it is necessary to use real samples to participate in the model verification process, or use the knowledge of other high-performance models as guidance information to determine the key neurons. However, if the training data set is not available and there is no reference model, the model cannot be pruned normally. For this, a zero-shot model pruning method is needed. However, the current zero-shot model pruning method is mainly based on the model weight coefficient and cannot analyze the degree of influence of neurons on specific categories. Summary of the invention
[0003] The purpose of the present invention is to fill the gaps in zero-sample and category-based model pruning methods and propose a deep learning model pruning method. The technical solution is as follows: A deep learning model pruning method: (1) Prepare an image classification model M to be pruned; (2) Create an initial random image and normalize it to obtain an initial deep dream; input the initial deep dream into the model M to obtain the output mean O and classification probability vector P of each neuron; (3) The loss function L is set by using the classification probability vector P, the output mean of the target neuron, and the output mean of other neurons in the convolutional layer to which the neuron belongs. The loss function is then used to perform multiple rounds of optimization on the deep dream, and finally denormalized to obtain the final deep dream. The obtained deep dream is re-input into the model M to obtain the predicted probability p of the target category. y ; (4) According to the predicted probability p of the target category y With a preset probability threshold p T Determine whether the neuron is important to the target category, and then decide whether to prune the neuron. The beneficial effects of the present invention are: (1) The present invention is a zero-shot model pruning method that can determine key neurons without the involvement of real images or the guidance of other models. (2) The present invention can be applied to a variety of models and is independent of the model structure. (3) This method has been verified through a large number of experiments, which effectively improves the reliability of the method. BRIEF DESCRIPTION OF THE DRAWINGS
[0004] Figure 1 It is the overall structure diagram of the present invention; DETAILED DESCRIPTION
[0005] To make the technical solution of the present invention clearer, the present invention is further described below in conjunction with the accompanying drawings. The present invention is specifically implemented according to the following steps: (1) Prepare an image classification model M to be pruned; (2) Create an initial random image that follows a uniform distribution Then, according to the mean μ (μ = [0.485, 0.456, 0.406]) and standard deviation σ (σ = [0.229, 0.224, 0.225]) of the ImageNet dataset, Normalized to x, as the initial depth dream; (3) Input the initial depth dream x into the model M, and obtain the classification probability vector P and the mean vector O of all neuron outputs of the convolutional layer where the neuron to be evaluated is located; (4) The loss function L is set by using the classification probability vector P, the mean output of the target neuron, and the mean output of other neurons in the convolutional layer to which the neuron belongs: Among them, β represents the weight coefficient, N c represents the number of categories, p j represents the probability of a deep dream being identified as the jth class, y represents the target class, m represents the convolutional layer where the target neuron is located, and N m represents the total number of neurons in the mth layer, represents the mean output value of the ith neuron in the mth layer, and z represents the target neuron located at the zth position in the mth layer. Then, the loss function is used to perform multiple rounds of optimization on the image x: Where α represents the learning rate, usually set to 0.2, x i represents the image optimized to the i-th round. Repeat this process until the preset number of rounds is reached, usually 20 rounds. Finally, the optimized image is denormalized to obtain the trained deep dream x final ; x final =σ*x+μ (5) Re-input the obtained deep dream into the model M to obtain the predicted probability p of the target category y ; (6) Preset a probability threshold p T , usually p T Set to 0.95, according to the predicted probability p of the target category y With probability threshold p T Determine whether the neuron is important to the yth class, and thus determine whether to prune the neuron. When p y Greater than the threshold p T , it means that the neuron is the key neuron for the y-th category classification and needs to be retained, otherwise it can be pruned.
Claims
1. A deep learning model pruning method, characterized in that: The steps to assess model information discrepancy include: (1) Prepare an image classification model M to be pruned; (2) Create initial random images that follow a uniform distribution and normalize them according to the mean and variance of the ImageNet dataset for training Deep Dream. (3) Input the initial deep dream into the model M, obtain the mean O of the output activation map of each neuron in each layer of the model and the classification probability vector P output by the model classifier; (4) The loss function L is set by using the classification probability vector P, the output mean of the neuron to be evaluated, and the output mean of other neurons in the convolutional layer to which the neuron belongs. Then, the loss function is used to perform multiple rounds of optimization on Deep Dream. Finally, the Deep Dream is denormalized according to the mean and variance of the ImageNet dataset to obtain the final Deep Dream. (5) Re-input the obtained deep dream into the model M to obtain the predicted probability p of the target category y ; (6) According to the predicted probability p of the target category y With a preset probability threshold p T Determine whether the neuron is important to the target category, and then decide whether to prune the neuron.
2. A deep learning model pruning method as claimed in claim 1, characterized in that: The method for obtaining deep dreams in step (4) is as follows: The loss function L is set by using the classification probability vector P, the mean output of the target neuron, and the mean output of other neurons in the convolutional layer to which the neuron belongs: Among them, β represents the weight coefficient, N c represents the number of categories, p j represents the probability of a deep dream being identified as the jth class, y represents the target class, m represents the convolutional layer where the target neuron is located, and N m represents the total number of neurons in the mth layer, represents the mean output value of the ith neuron in the mth layer, and z represents the target neuron located at the zth position in the mth layer. Then, the loss function is used to perform multiple rounds of optimization on the image x: Where α represents the learning rate, x i represents the image optimized to the i-th round. This process is repeated until the preset number of rounds is reached, and finally the optimized image is denormalized to obtain the trained deep dream.
3. A deep learning model pruning method as claimed in claim 1, characterized in that: The method for determining whether a neuron is a key neuron in step (6) is: The predicted probability p of a deep dream belonging to the target category according to the training y With the preset probability threshold p T Determine whether the neuron is important to the yth class, and thus determine whether to prune the neuron: When p y Greater than the threshold p T , it means that the neuron is the key neuron for the y-th category classification and needs to be retained, otherwise it can be pruned.
Citation Information
Patent Citations
CNN model compression method based on activation-entropy weight pruning
CN110097187A
DBNet-based secondary circuit terminal strip wiring detection method in intelligent substation
CN113160196A
Deep neural network model test method, system and device, and storage medium
CN115687118A
Deep neural network model compression method and compression device based on CIFAR data set
CN116502697A
Ocean current rendering method, device and equipment and storage medium
CN117994399A
Cited By
Engine damage identification method and system based on lightweight target detection model
CN122714762A