Model pruning method and device, computer device, storage medium and program product

By optimizing model pruning through iterative learning and distillation learning algorithms, the problems of low pruning efficiency and insufficient model performance are solved, achieving efficient model pruning and a high-performance pruning model.

CN116384471BActive Publication Date: 2026-06-02伟光有限公司(CN)

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
伟光有限公司(CN)
Filing Date
2023-03-09
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing model pruning techniques have shortcomings in balancing pruning efficiency and post-pruning model performance. In particular, traditional methods require separate training of pruning algorithms for initializing each parameter, resulting in large data processing volume and low training efficiency.

Method used

By obtaining an initial model set, iterative learning is performed. The target model is trained using a reference model and the current model set is updated until the target model set is obtained. The pruned model is determined based on the selection criteria, and the model performance is optimized by combining the distillation learning algorithm.

Benefits of technology

This improved pruning efficiency, ensured the performance of the pruned model, reduced the number of iterations and data processing, and enhanced the overall efficiency and effectiveness of model pruning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116384471B_ABST
    Figure CN116384471B_ABST
Patent Text Reader

Abstract

The application relates to a model pruning method and device, computer equipment, a storage medium and a program product. The method comprises the following steps: acquiring an initial model set corresponding to a source model to be pruned, each initial model in the initial model set being obtained by pruning the source model by using each initial pruning algorithm; taking the initial model set as a current model set, performing iterative learning, for each iteration process, determining a target model and a reference model from the current model set, training the target model by using the reference model, and updating the current model set by using the trained target model until a target model set is obtained; and determining a model pruned from the source model based on the target model set and a screening condition. The method can improve pruning efficiency while ensuring the performance of the pruned model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of model pruning technology, and in particular to a model pruning method, apparatus, computer equipment, storage medium, and program product. Background Technology

[0002] Model pruning is a technique that reduces the number of parameters in a neural network model (hereinafter referred to as the source model) and is widely used in lightweight model deployment. The main process of model pruning is as follows: allocate compression ratios to the weight layers in the source model that need to be pruned according to the compression ratio requirements, then weigh the importance of weights in different dimensions of each weight layer, delete the less important weights, and retain the more important weights.

[0003] Currently, there are various pruning algorithms. If it is necessary to prune a source model, the relevant technologies usually train each pruning algorithm separately, and then select the optimal solution as the pruning model to prune the source model.

[0004] However, in specific business scenarios, it is necessary to consider not only the performance of the pruned model, but also the pruning efficiency. The above-mentioned model pruning method has the problem of low pruning efficiency. Summary of the Invention

[0005] This application provides a model pruning method, apparatus, computer device, storage medium, and program product, which can improve pruning efficiency while ensuring the performance of the pruned model.

[0006] Firstly, a model pruning method is provided, which includes:

[0007] Obtain the initial model set corresponding to the source model to be pruned, wherein each initial model in the initial model set is obtained by pruning the source model using each initial pruning algorithm;

[0008] The initial model set is used as the current model set for iterative learning. For each iteration, a target model and a reference model are determined from the current model set. The target model is trained using the reference model, and the current model set is updated using the trained target model until the target model set is obtained.

[0009] Based on the target model set and the screening criteria, the pruned model corresponding to the source model is determined.

[0010] Secondly, a model pruning device is provided, the device comprising:

[0011] The acquisition module is used to acquire the initial model set corresponding to the source model to be pruned. Each initial model in the initial model set is obtained by pruning the source model using each initial pruning algorithm.

[0012] The iteration module is used to take the initial model set as the current model set and perform iterative learning. For each iteration, the target model and reference model are determined from the current model set, the target model is trained using the reference model, and the current model set is updated using the trained target model until the target model set is obtained.

[0013] The determination module is used to determine the pruned model corresponding to the source model based on the target model set and the screening conditions.

[0014] Thirdly, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor causes the processor to perform the steps of the method described in the first aspect above.

[0015] Fourthly, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, performs the steps of the method described in the first aspect above.

[0016] Fifthly, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the steps of the method described in the first aspect above.

[0017] The beneficial effects of the technical solutions provided in this application include at least the following:

[0018] The process involves obtaining an initial model set corresponding to the source model to be pruned. Each initial model in this set is obtained by pruning the source model using a different initial pruning algorithm. Then, this initial model set is used as the current model set for iterative learning. In each iteration, a target model and a reference model are determined from the current model set. The target model is trained using the reference model, and the current model set is updated using the trained target model. This process continues until a target model set is obtained. Based on the target model set and selection criteria, the pruned model corresponding to the source model is determined. These selection criteria could include, for example, selecting the best-performing pruned model from the target model set as the pruned model corresponding to the source model; selecting the best-performing pruned model from the target model set and then retraining it to obtain the pruned model corresponding to the source model; or selecting multiple best-performing pruned models from the target model set, retraining each of them, and then selecting the best-performing model from the retraining results as the pruned model corresponding to the source model. The model, etc., in this embodiment, continuously updates and optimizes the current model set through iterative learning. After iteration, the best-performing model is selected as the pruned model corresponding to the source model based on the above selection criteria, thereby ensuring the performance of the pruned model. In addition, compared with the traditional method of training each parameter initialization pruning algorithm separately using training samples, the traditional method requires multiple iterations during training, resulting in a large amount of data processing and low training efficiency, leading to low pruning efficiency. However, in this embodiment, each initial pruning algorithm of parameter initialization is directly used to prune the source model, without the need to train each parameter initialization pruning algorithm separately. Furthermore, the method of using the reference model to train the target model to iteratively update the current model set has a much smaller data processing volume than training each parameter initialization pruning algorithm separately using training samples, due to the smaller number of iterations (for example, the number of iterations can be the same as the number of initial models in the initial model set). Thus, this embodiment also improves pruning efficiency. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a classification diagram of the pruning algorithm in one embodiment;

[0021] Figure 2 This is a flowchart of a model pruning method in one embodiment;

[0022] Figure 3 This is a flowchart illustrating the training of a target model using a reference model in one embodiment;

[0023] Figure 4 This is a flowchart illustrating the determination of a target model and a reference model from the current model set in one embodiment.

[0024] Figure 5 Here is a flowchart of step 201 in one embodiment;

[0025] Figure 6 This is a schematic diagram comparing the number of convolutional kernels in the target convolutional layer of an exemplary ground source model and the target convolutional layer of a target source model in one embodiment;

[0026] Figure 7 This is a flowchart illustrating the process of determining a target pruning model from a set of target models in one embodiment.

[0027] Figure 8 This is a schematic diagram of the overall framework of an exemplary model pruning method in one embodiment;

[0028] Figure 9 This is a schematic diagram illustrating an example of pruning the source model using various initial pruning algorithms in one embodiment;

[0029] Figure 10 This is a structural block diagram of the model pruning device in one embodiment;

[0030] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0031] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0032] Model pruning, a technique for compressing and optimizing neural network models, is widely used in lightweight deployments and practical applications of neural network models because it can reduce the number of parameters in the model.

[0033] The main basis for model pruning is that the trained neural network model (hereinafter referred to as the source model for convenience) has a certain degree of redundancy, and some weights can be removed while maintaining performance. The main process of model pruning is as follows: according to the compression ratio requirements of the compression task, a compression ratio is assigned to all weight layers (such as convolutional layers, Dense fully connected layers, etc.) in the source model that need to be pruned according to a certain allocation algorithm. Then, the importance of weights in different dimensions of each weight layer is measured according to a certain metric. Weights with lower importance are deleted, and weights with higher importance are retained, so that the source model becomes a new model with fewer parameters. Subsequently, the weights of the new model are retrained and fine-tuned using a certain method to make its performance approach or even better than that of the source model.

[0034] Currently, a large number of pruning algorithms have evolved in the field of model pruning. Taking the measurement of the importance of weights in different dimensions of each weight layer as an example, some pruning algorithms select important channels based on different norms of the weight layer (L1 norm, L2 norm, etc.), some pruning algorithms select important channels based on the number of geometric centers, some pruning algorithms select channels of the corresponding weight layer based on the training parameters of the BN layer, some pruning algorithms select channels based on the mean or statistical zero value in the output feature tensor of the weight layer, and some pruning algorithms select important channels based on the Taylor expansion estimate of the backpropagation gradient of the weight layer, and so on.

[0035] Taking 2D convolution operations (with a corresponding 4D tensor kernel) as an example, see [link to relevant documentation]. Figure 1 Pruning algorithms can be categorized into four types based on their dimensions:

[0036] 1) Fine-grained pruning is pruning at the individual element level, represented by 0-D, that is, pruning connections or neurons. It is the smallest granular pruning.

[0037] 2) Vector-level pruning is a pruning method that subtracts entire columns. It is represented using 1-D and has a larger granularity than fine-grained pruning. It belongs to the pruning of the convolution kernel.

[0038] 3) Kernel-level pruning is a pruning method that removes the entire convolution kernel. It is represented in 2-D, meaning that removing a certain convolution kernel will discard the response of the corresponding computation channel in the input channel.

[0039] 4) Filter-level pruning is the pruning of the entire convolutional kernel group. Represented in 3D, it will cause a change in the number of output feature channels during inference.

[0040] The degree of structuring of the above four pruning algorithms increases in that order, and the more structured the pruning scheme, the more friendly it is to the deployment of neural network models.

[0041] In practical tasks, different pruning algorithms perform differently. A pruning algorithm trained for a specific task is unlikely to perform well on other tasks. Moreover, most pruning algorithms have hyperparameters, and changes in these parameters can lead to different results and affect their performance. If model pruning is required for a specific source model, each parameter-initialized pruning algorithm must be trained separately. After training, the optimal solution is selected as the pruning model to prune the source model. However, this approach requires multiple iterations for each parameter-initialized pruning algorithm during training, resulting in massive data processing, low training efficiency, and consequently, low pruning efficiency.

[0042] Moreover, in specific business scenarios, it is necessary to consider not only the efficiency of pruning, but also the performance of the model after pruning.

[0043] To address the aforementioned problems, this application provides a model pruning method that can improve pruning efficiency while maintaining the performance of the pruned model. The implementation process of this application embodiment is described below, in conjunction with the application environment in which the model pruning method of this application is applied.

[0044] The model pruning method provided in this application embodiment can be applied to computer devices, which can be servers. Servers can be implemented using independent servers or server clusters composed of multiple servers.

[0045] In one embodiment, such as Figure 2 As shown, a model pruning method is provided, including the following steps:

[0046] Step 201: Obtain the initial model set corresponding to the source model to be pruned.

[0047] The source model can be any neural network model that requires pruning. For example, the source model can be a classification model in a classification task, an object detection model in an object detection task, and so on. The computer device obtains the initial model set corresponding to the source model, which includes multiple initial models. The following provides an exemplary description of the concepts of each initial model and the methods by which the computer device obtains each initial model.

[0048] In this embodiment, each initial model in the initial model set is obtained by pruning the source model using different initial pruning algorithms. Each initial pruning algorithm refers to a parameter initialization pruning algorithm. For example, taking common pruning algorithms in decision trees, these initial pruning algorithms include Reduced-Error Pruning (REP), Pessimistic-Error Pruning (PEP), Cost-Complexity Pruning (CCP), and so on. Parameter initialization can be understood as assigning random values ​​to the hyperparameters of the pruning algorithm.

[0049] In one possible implementation of step 201, the computer device acquires the source model and selects multiple pruning algorithms. The computer device sets the hyperparameters of each selected pruning algorithm to random values, thereby obtaining multiple initial pruning algorithms. Then, for each initial pruning algorithm, the computer device uses the initial pruning algorithm to prune the source model to obtain the initial model corresponding to the initial pruning algorithm. The initial models corresponding to each initial pruning algorithm then form an initial model set.

[0050] In another possible implementation of step 201, the process of pruning to obtain the initial models described above can also be implemented in other devices. In this embodiment, the computer device obtains the final set of initial models from these other devices. The specific method of obtaining the initial model set is not limited here.

[0051] In this embodiment, the source model is pruned using each initial pruning algorithm. This can be done by subtracting the entire convolution kernel (i.e., kernel pruning) or by pruning the entire convolution kernel group (i.e., filter pruning). Compared to fine-grained pruning and vector pruning, kernel pruning and filter pruning have a higher degree of structure, which is beneficial for the deployment of the pruned model corresponding to the final source model.

[0052] Step 202: Use the initial model set as the current model set for iterative learning. For each iteration, determine the target model and reference model from the current model set, train the target model using the reference model, and update the current model set using the trained target model until the target model set is obtained.

[0053] The computer device uses the initial model set as the current model set, which means that the computer device uses the initial model set as the current model set in the first iteration process.

[0054] For the first iteration, the computer device determines the target model and the reference model from the initial model set. Then, it uses the reference model to train the target model to obtain the trained target model. The computer device then uses the trained target model to update the initial model set to obtain the updated model set corresponding to the first iteration.

[0055] For the second iteration, the computer device uses the updated model set corresponding to the previous iteration (i.e., the first iteration) as the current model set for the second iteration. Then, the computer device determines the target model and reference model from the current model set and continues the same training and update process as the previous iteration to obtain the updated model set corresponding to the second iteration.

[0056] Similarly, the subsequent iterations follow the same pattern, and the computer device eventually obtains the updated model set corresponding to the last iteration, which is the target model set.

[0057] The process of training the target model using the aforementioned computer equipment with a reference model can be based on a distillation learning algorithm, a transfer learning algorithm, or other machine learning algorithms with similar effects (i.e., the effect of using a reference model to guide the training of the target model).

[0058] Taking the distillation learning algorithm as an example, the computer device can use the reference model as the teacher network and the target model as the student network. The teacher network guides the output of the student network. During the training process, the output of the reference model and the real labels can be used as the labels for the output of the target model for training. In this way, through the joint supervision of the output of the reference model and the real labels, the performance of the target model after training is better than the performance of the target model before training.

[0059] The following is an exemplary description of the process by which a computer device updates the current model set using the trained target model.

[0060] In one possible implementation, the computer device can determine candidate models in the current model set whose performance index value is lower than that of the trained target model, and then replace the candidate models in the current model set with the trained target model. That is, the computer device selects candidate models from the current model set whose model performance is worse than that of the trained target model. The number of candidate models can be one or more, and then the trained target model is used to replace the one or more candidate models.

[0061] In another possible implementation, the computer device updates the current model set using the trained target model, or it can select the candidate model with the worst performance from the current model set and then replace the candidate model with the trained target model.

[0062] As can be seen, the embodiments of this application continuously eliminate candidate models with poor performance and iteratively update the current model set, making the model performance of the models in the current model set increasingly better. Moreover, as the model performance of the models in the current model set becomes better, the model performance of the reference model selected by the computer device also becomes better, further improving the supervision effect on the target model and improving the model performance of the trained target model.

[0063] Furthermore, the number of iterations in the iterative learning of this application embodiment can be the same as the number of initial models in the initial model set. Of course, the number of iterations in the iterative learning can also be set by the user in actual implementation. Compared with the traditional technology of training each parameter initialization pruning algorithm using training samples, each pruning algorithm needs to repeat the iteration loop many times, resulting in a huge amount of data processing, the data processing amount of the iterative learning of this application embodiment is much smaller than that of the training method in the traditional technology due to the fewer iterations and the simpler iterative learning process, which is conducive to improving the pruning efficiency of this application embodiment.

[0064] Step 203: Based on the target model set and the screening conditions, determine the pruned model corresponding to the source model.

[0065] As mentioned above, the target model set is the updated model set corresponding to the last iteration. Compared with the initial model set, some or all of the pruned models in the target model set are high-performance models trained using the corresponding reference models.

[0066] Based on the target model set, the computer equipment determines the pruned model corresponding to the source model based on the screening criteria.

[0067] In one possible implementation, the computer device can select the best-performing pruned model from the target model set and use that pruned model as the pruned model corresponding to the source model.

[0068] In another possible implementation, the computer device may determine the best-performing pruned model from the target model set, retrain it, and use the retrained model as the pruned model corresponding to the source model.

[0069] In other possible implementations, the computer device may also select multiple pruned models with the best performance from the target model set, retrain them separately, and finally select the model with the best performance from the retraining results as the pruned model corresponding to the source model.

[0070] The aforementioned retraining of the pruning model can be based on the distillation learning algorithm, using the source model as the teacher network and the pruning model as the student network. The source model guides the output of the pruning model, and the retraining process can further adjust the model parameters of the pruning model, making its performance approach or even surpass that of the source model.

[0071] Overall, the above embodiments obtain an initial model set corresponding to the source model to be pruned. Each initial model in this initial model set is obtained by pruning the source model using a different initial pruning algorithm. Then, the initial model set is used as the current model set for iterative learning. For each iteration, a target model and a reference model are determined from the current model set. The target model is trained using the reference model, and the current model set is updated using the trained target model until the target model set is obtained. Then, based on the target model set and selection criteria, the pruned model corresponding to the source model is determined. The selection criteria can be, for example, selecting the best-performing pruned model from the target model set as the pruned model corresponding to the source model; or, for example, selecting the best-performing pruned model from the target model set and then retraining it to obtain the pruned model corresponding to the source model; or, for example, selecting multiple best-performing pruned models from the target model set, retraining them separately, and then selecting the best-performing model from the retraining results as the pruned model corresponding to the source model. The pruned model, etc., in this embodiment, the current model set is continuously updated and optimized through iterative learning. After the iteration is completed, the model with the best performance is determined as the pruned model corresponding to the source model based on the above selection criteria, thereby ensuring the performance of the pruned model. In addition, compared with the traditional method of training each parameter initialization pruning algorithm separately using training samples, the traditional method of each parameter initialization pruning algorithm needs to be iterated many times during the training process, which has a huge amount of data processing and low training efficiency, resulting in low pruning efficiency. In this embodiment, each parameter initialization initialization initialization pruning algorithm is directly used to prune the source model, without having to train each parameter initialization pruning algorithm separately. Moreover, the method of using the reference model to train the target model to iteratively update the current model set in this embodiment has a much smaller amount of data processing due to the fewer iterations (the number of iterations can be the same as the number of initial models in the initial model set), which is much smaller than the amount of data processing when training each parameter initialization pruning algorithm separately using training samples. Therefore, this embodiment also improves the pruning efficiency.

[0072] In one embodiment, based on Figure 2 The illustrated embodiment can be found in [reference]. Figure 3 This embodiment relates to the process by which a computer device trains a target model using a reference model. For example... Figure 3 As shown, the process includes steps 301 and 302:

[0073] Step 301: Obtain the reference output of the reference model for the target input sample, and obtain the target output of the target model for the target input sample.

[0074] The target input sample is the sample that meets the input requirements of the reference model and the target model. For example, if both the reference model and the target model are image classification models, then the target input sample is any image sample that needs to be classified.

[0075] The computer device inputs the target input sample into the reference model and the target model respectively, and obtains the reference output result of the reference model and the target output result of the target model.

[0076] Step 302: Train the target model based on the reference output, the target output, and the preset machine learning algorithm.

[0077] Taking the distillation learning algorithm as an example, the implementation process of step 302 will be described exemplarily.

[0078] In one possible implementation, step 302 may include the following steps A1 and A2:

[0079] Step A1: Calculate the loss value based on the reference output, the target output, and the loss function corresponding to the preset machine learning algorithm.

[0080] In this embodiment, the selected reference model is used to perform knowledge distillation on the target model to optimize the fast training of the target model. The loss function of the distillation learning algorithm uses a combination of cross-entropy (CE) and KL (Kullback-Leibler) divergence to calculate the gradient during the back propagation (BP) process. The expression of the loss function of the distillation learning algorithm is as follows:

[0081]

[0082] Where x and y represent the input sample (i.e., the target input sample) and the true label in the training set, respectively, p* represents the reference model, p represents the objective function, and w p* w represents the model parameters (or weights) of p*. p p*(x,w) represents the model parameters of p. p* p* represents the output of input x (i.e., the reference output result mentioned above), p(x,w) p ) represents the output of p with respect to input x (i.e., the target output result mentioned above), L CE (y,p(x,w p )) is the basic term of the loss function, representing the cross-entropy between the output of p and the true label, L KD (p*(x,w p* ),p(x,w p)) is an additional term in distillation learning, representing the KL divergence between the output of p and the output of p*, where η represents the learning rate. Indicates based on w p The gradient.

[0083] Step A2: Adjust the model parameters of the target model based on the loss value.

[0084] By inputting the reference output and the target output into the loss function, the loss value can be calculated, and then the model parameters of the target model p can be adjusted by backpropagation based on the loss value.

[0085] In the above embodiments, during the distillation learning process, the training of the target model is jointly supervised by the real label y and the reference output result, so that the performance of the target model after training is better than that of the target model before training.

[0086] In another possible implementation, step 302 may include steps B1, B2, and A2 as follows, that is, step A1 can be implemented by steps B1 and B2 as follows:

[0087] Step B1: Obtain the matching degree between the reference model and the target model.

[0088] Step B2: Input the reference output, target output, and matching degree into the loss function to obtain the loss value.

[0089] Step A2: Adjust the model parameters of the target model based on the loss value.

[0090] The matching degree between the reference model and the target model can be calculated by a computer device using a matching network. This matching network, trained independently, can be composed of a simple two-layer fully connected network. The expression for calculating the matching network is shown below:

[0091] ρ(p,p*)=Meta((p(x,w p )-p*(x,w p* )),θ)

[0092] Where ρ(p,p*) represents the matching degree between the reference model and the target model, θ represents a parameter with a fixed value in the matching network, and the meanings of the other letters are as described above.

[0093] As can be seen from the expression calculated by the matching network, the computer device inputs the difference between the above reference output and the target output into the matching network to obtain the matching degree between the reference model and the target model output by the matching network. This matching degree is a scalar normalized to (0, 1).

[0094] The computer equipment calculates the loss value based on the reference output, the target output, and the matching degree, and adjusts the model parameters of the target model according to the loss value. The model parameters w of the target model... p The updated expression is as follows

[0095]

[0096] That is, based on the expression of the loss function of the above distillation learning algorithm, the computer device uses the matching degree as an additional term L in the distillation learning of the loss function. KD (p*(x,w p* ),p(x,w p The adjustment coefficient of the target model p is used to calculate the loss value, and the model parameters w are adjusted based on the loss value through backpropagation. p .

[0097] In this embodiment, the matching degree is negatively correlated with the loss value; that is, the higher the matching degree between the reference model and the target model, the greater the loss value. KD (p*(x,w p* ),p(x,w p The greater the proportion of the function value in the loss value, the smaller the loss value, the faster the target model converges, and the greater the guiding significance of the reference model, so as to obtain a target model with excellent model performance after training, and thus obtain a set of target models with excellent model performance.

[0098] Then, based on the target model set and the screening conditions, the computer device determines the pruned model corresponding to the source model. Thus, the model pruning method of this application embodiment integrates existing pruning algorithms and combines distillation learning algorithm to retrieve the optimal pruned model. As a part of model pruning, distillation learning algorithm is beneficial for selecting appropriate pruning algorithms and hyperparameters for the source model. At the same time, it uses excellent reference models to assist the existing model (i.e., the target model) during parameter update, thereby improving the trained target model through distillation learning.

[0099] In one embodiment, based on Figure 2 The illustrated embodiment can be found in [reference]. Figure 4 This embodiment describes the process by which a computer device determines a target model and a reference model from a current set of models. For example... Figure 4 As shown, the process includes steps 401, 402, and 403:

[0100] Step 401: Randomly select the target model from the current model set.

[0101] As mentioned above, for the Nth iteration, the computer device uses the updated model set corresponding to the (N-1)th iteration as the current model set for the Nth iteration. Then, the computer device randomly selects a model from the current model set as the target model for the current iterative learning.

[0102] Step 402: For each other model in the current model set, use the matching network to calculate the matching degree between the target model and other models.

[0103] The process by which computer equipment uses a matching network to calculate the matching degree between the target model and other models can be found in step B1 above, where the matching degree is obtained. It will not be repeated here.

[0104] Step 403: If the matching degree is greater than the preset matching degree threshold, then other models are determined as reference models.

[0105] Setting this preset matching threshold ensures that the matching degree of the reference model is the highest among the matching degrees of all other models. In other words, the model with the highest matching degree with the target model is selected from all other models in the current model set as the reference model.

[0106] In this way, after the computer device determines the target model and the reference model, it uses the reference model as the teacher network for subsequent training of the target model to guide the training of the target model. For the specific training process, please refer to the embodiment described above, which will not be repeated here.

[0107] based on Figure 4 The embodiment shown in this application further includes updating the network parameters of the matching network based on the output of the target model and the output of the reference model.

[0108] The following section describes the process of updating the network parameters of the matching network.

[0109] In this embodiment, the loss function of the distillation learning algorithm described above is used to guide the parameter update of the matching network. The loss function L of the matching network... meta The expression is as follows:

[0110]

[0111]

[0112] Where ρ(θ) is an expression based on θ, and the meanings of the other letters are described above.

[0113] The implicit meaning of the loss function of the matching network is that if the reference model selected by the matching network is more instructive for the target model, then the target model will achieve a smaller loss value on the validation set after updating. Therefore, the goal of the loss function of the matching network is to guide the matching network to find the most suitable reference model for the target network. In this way, the R value can be calculated from the outputs of the target model and the reference model, and further, the loss value corresponding to the matching network can be obtained. The computer device then uses this loss value to backpropagate and adjust the network parameters of the matching network.

[0114] In this embodiment, the update frequency of the matching network parameters is greater than or equal to the iteration frequency of iterative learning. This is because when the computer device adjusts the matching network parameters based on the loss value through backpropagation, it derives the result in reverse. The process involves solving the gradient of the gradient, and matrix expansion is relatively complex and time-consuming. Therefore, the matching network can be set to update its parameters once every certain period. Every certain period means every several iterations of learning, rather than updating the network parameters of the matching network in every iteration of learning. This improves the update rate of the network parameters of the matching network and is beneficial to improving the pruning efficiency of the embodiments of this application.

[0115] In one embodiment, based on Figure 2 The illustrated embodiment can be found in [reference]. Figure 5 This embodiment relates to the process by which a computer device obtains the initial model set corresponding to the source model to be pruned. For example... Figure 5 As shown, step 201 includes:

[0116] Step 2011: Set the hyperparameters of each initial pruning algorithm to random values.

[0117] The computer device selects several basic pruning algorithms, such as REP, PEP, and CCP mentioned above, and then sets the hyperparameters of each pruning algorithm to random values.

[0118] Step 2012: For each initial pruning algorithm, the source model is pruned using the initial pruning algorithm and the target compression ratio to obtain an initial model, thus obtaining an initial model set.

[0119] The target compression ratio can be the compression ratio required by the source model for the current compression task, such as 50%, which means that the number of parameters in the source model needs to be compressed by 50%.

[0120] Then, for each initial pruning algorithm, the computer device uses the initial pruning algorithm and the target compression ratio to prune the source model, thereby obtaining the initial model corresponding to the initial pruning algorithm.

[0121] Please continue reading Figure 5 Step 201 also includes:

[0122] Step 2013: For each initial model, check whether the number of model parameters and the model computing power of the initial model meet the preset conditions.

[0123] Model parameter count refers to the number of model parameters, and model computing power refers to the number of dot products when the model is used. In this embodiment, in order to avoid the initial model obtained by pruning the source model using the initial pruning algorithm and the target compression ratio from not meeting the requirements of the compression task, preset conditions are set to detect the model parameter count and model computing power of the initial model. The preset conditions may be that the model parameter count of the initial model is less than the parameter count limit threshold, and the model computing power of the initial model is less than the computing power limit threshold.

[0124] Step 2014: If the number of model parameters and the model computing power of the initial model meet the preset conditions, then add the initial model to the initial model set.

[0125] Only when the number of model parameters and the model computing power of the initial model meet the preset conditions will it be added to the initial model set. In other words, the number of model parameters and the model computing power of the initial models in the initial model set all meet the above preset conditions, thereby improving the matching degree between each initial model and the compression business corresponding to the source model and improving the effect of model pruning.

[0126] In one possible implementation, before step 2012, the model pruning method of this application embodiment further includes: performing convolution kernel addition processing on the target convolutional layer of the source model to obtain the target source model.

[0127] For example, see Figure 6 , Figure 6 This is a schematic diagram comparing the number of convolutional kernels in the target convolutional layer of an exemplary ground source model and the target convolutional layer of a target source model.

[0128] The target convolutional layer's layer number is less than a preset layer number threshold, meaning the target convolutional layer is a shallow convolutional layer. Taking a two-dimensional convolutional layer as an example, the kernel dimension of the target convolutional layer in the source model is assumed to be (H, W, C). in C out For the number of output channels C out Adding n convolutional kernels results in the kernel dimension of the target convolutional layer of the target source model being (H, W, C). in C out +n).

[0129] Accordingly, the computer equipment uses an initial pruning algorithm and a target compression ratio to prune the target source model, thereby realizing the process of obtaining an initial model by pruning the source model using the initial pruning algorithm and the target compression ratio.

[0130] In this way, by expanding the channels of shallow convolutional layers, we can improve their original performance, thereby indirectly improving the performance of the pruned model. On the other hand, when using the initial pruning algorithm to prune them, the retrieval space of the pruning path is expanded, increasing the options available.

[0131] In one embodiment, based on Figure 2 The illustrated embodiment can be found in [reference]. Figure 7 This embodiment relates to the process by which a computer device determines the pruned model corresponding to the source model based on a set of target models and selection criteria. For example... Figure 7 As shown, the process includes steps 701 and 702:

[0132] Step 701: Obtain the performance index values ​​of each pruning model in the target model set.

[0133] The performance index is a quantitative value of the performance of the pruning model. For example, if the pruning model is a classification model, then the performance index of the pruning model can be the classification accuracy of the pruning model.

[0134] In this embodiment of the application, the computer device can test the performance of each pruning model one by one based on a preset validation set to obtain the performance index value of each pruning model.

[0135] Step 702: Determine the model after pruning based on the performance index values ​​of each pruning model.

[0136] In one possible implementation of step 702, the computer device can select the best-performing pruned model from the target model set as the pruned model corresponding to the source model based on the performance index values ​​of each pruned model.

[0137] In another possible implementation of step 702, the computer device can determine the pruning model with the largest performance index value from each pruning model, that is, determine the best-performing pruning model from the target model set, and then retrain the pruning model with the largest performance index value, that is, further train until convergence, to obtain the pruned model corresponding to the source model.

[0138] In another possible implementation of step 702, the computer device may also determine multiple candidate pruning models from each pruning model in descending order of performance index values. For example, select the top n (n is an integer greater than 1) best-performing pruning models (i.e., multiple candidate pruning models), and then retrain each candidate pruning model. After convergence, multiple retrained pruning models are obtained. Finally, the retrained pruning model with the largest performance index value (i.e., the best performance) among the retrained pruning models is taken as the pruned model corresponding to the source model.

[0139] Thus, in the retraining phase of the model, this embodiment directly selects one or more of the best-performing pruned models for retraining, reducing the number of pruned models to be retrained, thereby reducing the amount of data processing during training and improving the efficiency of model pruning.

[0140] See Figure 8 , Figure 8 This is a schematic diagram of the overall framework of an exemplary model pruning method. Figure 9 This is an exemplary diagram illustrating the pruning of the source model using various initial pruning algorithms. The following, combined with... Figure 8 and Figure 9 The overall process of the model pruning method in the embodiments of this application will be briefly described. The model pruning method includes:

[0141] 1) The computer device adds convolution kernels to the target convolutional layer of the source model to obtain the target source model. The layer number of the target convolutional layer is less than the preset layer number threshold.

[0142] 2) The computer equipment sets the hyperparameters of each initial pruning algorithm to random values.

[0143] 3) For each initial pruning algorithm, the computer equipment prunes the target source model using the initial pruning algorithm and the target compression ratio to obtain the initial model.

[0144] Please see Figure 8 and Figure 9 Using A i Let represent the initial pruning algorithm, i = 1, 2, ..., N, where N is the number of initial pruning methods, and a i This represents the hyperparameters of the corresponding initial pruning algorithm, a. i It has a certain retrieval space (i.e., a) i (The value can be adjusted).

[0145] The computer device randomly selects the initial pruning algorithm A each time. i and A i The hyperparameters are set to random values, and then the initial pruning algorithm A is used. iA preliminary model is obtained by pruning the target source model M(V).

[0146] 4) For each initial model, the computer device checks whether the number of model parameters and the model computing power of the initial model meet the preset conditions.

[0147] Let C represent the constraints for selecting the initial model, and Count_params() represent the function that calculates the number of model parameters in the initial model. param This indicates the parameter limit threshold; Count_flops() is the function that calculates the computational power of the initial model; C flops This indicates the computing power limit threshold.

[0148] C = {C param C flops The preset conditions are:

[0149] Count_params(p) <C param And Count_flops(p) <C flops

[0150] 5) If the number of model parameters and the computing power of the initial model meet the preset conditions, the computer device will add the initial model to the initial model set.

[0151] 6) The computer device uses the initial model set as the current model set for iterative learning. For each iteration, the target model and reference model are determined from the current model set. The target model is trained using the reference model, and the current model set is updated using the trained target model until the target model set is obtained.

[0152] During the first iteration, Figure 8 The sub-model pool shown is the initial model set. As iterative learning continues, the sub-model pool is continuously updated. After the iteration is complete, Figure 8 The sub-model pool shown is the target model set.

[0153] The process of determining the target model and reference model from the current model set includes: the computer device randomly selecting the target model from the current model set; for each other model in the current model set, using a matching network to calculate the matching degree between the target model and other models; if the matching degree is greater than a preset matching degree threshold, then the other model is determined as the reference model.

[0154] Optionally, the computer device can also update the network parameters of the matching network based on the output of the target model and the output of the reference model, and the update frequency of the network parameters of the matching network is greater than or equal to the iteration frequency of the iterative learning.

[0155] The process of training the target model using a reference model includes: obtaining the reference output of the reference model for the target input sample using a computer device, and obtaining the target output of the target model for the target input sample; obtaining the matching degree between the reference model and the target model; inputting the reference output, the target output, and the matching degree into the loss function corresponding to the distillation learning algorithm to obtain the loss value, wherein the magnitude of the matching degree is negatively correlated with the magnitude of the loss value; and adjusting the model parameters of the target model based on the loss value.

[0156] The computer device updates the current model set using the trained target model, including: determining candidate models in the current model set, where the performance index value of the candidate model is less than the performance index value of the trained target model; and replacing the candidate model in the current model set with the trained target model.

[0157] 7) The computer equipment acquires the performance index values ​​of each pruning model in the pruning model set;

[0158] 8) The computer equipment determines the pruning model with the highest performance index value from all pruning models, and retrains the pruning model with the highest performance index value to obtain the pruned model corresponding to the original model; or,

[0159] The computer equipment determines multiple candidate pruning models from each pruning model according to the performance index values ​​in descending order; each candidate pruning model is retrained to obtain multiple retrained pruning models; the retrained pruning model with the largest performance index value among the retrained pruning models is taken as the pruned model corresponding to the source model.

[0160] Please continue reading Figure 8 In general, the sub-model pool in this embodiment is used to store the pruned models with excellent performance. M(V) represents the source model (or the target source model). The model p is obtained from M(V) through the initial pruning algorithm. It is checked whether p meets the limitations of computing power and number of parameters. If it does, it is added to the sub-model pool. Meta(θ) is used as the matching network. p* that matches p is selected from the sub-model pool. p is trained quickly. During the training process, p* is used for distillation assistance. Then, the sub-model pool is replaced and updated using the trained p. The network parameters of the matching network are also updated regularly. After a certain iteration cycle, the best-performing pruned model is selected from the sub-model pool as the final output.

[0161] This application integrates multiple basic pruning algorithms (i.e., each initial pruning algorithm), and divides the pruning optimization process into two parts: retrieval and retraining. During the retrieval process, the pruning algorithm, parameter selection, and model training are combined to dynamically select the optimal model.

[0162] The sub-model pool established in this embodiment can provide matching p* for distillation learning of p during the model retrieval and tuning stages, and also preserves the excellent models in the retrieval process. During the model retraining stage, the model with the best performance can be directly selected as the final output, avoiding re-retrieval and relocation.

[0163] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0164] Based on the same inventive concept, this application also provides a model pruning device for implementing the model pruning method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more model pruning device embodiments provided below can be found in the limitations of the model pruning method described above, and will not be repeated here.

[0165] In one embodiment, such as Figure 10 As shown, a model pruning device is provided, comprising:

[0166] The acquisition module 1001 is used to acquire the initial model set corresponding to the source model to be pruned, wherein each initial model in the initial model set is obtained by pruning the source model using each initial pruning algorithm.

[0167] The iteration module 1002 is used to take the initial model set as the current model set and perform iterative learning. For each iteration, the target model and the reference model are determined from the current model set, the target model is trained using the reference model, and the current model set is updated using the trained target model until the target model set is obtained.

[0168] The determination module 1003 is used to determine the pruned model corresponding to the source model based on the target model set and the screening conditions.

[0169] In one embodiment, the iteration module 1002 includes:

[0170] The first acquisition unit is used to acquire the reference output result of the reference model for the target input sample, and to acquire the target output result of the target model for the target input sample;

[0171] The training unit is used to train the target model based on the reference output, the target output, and a preset machine learning algorithm.

[0172] In one embodiment, the training unit is specifically used to calculate a loss value based on the reference output result, the target output result, and the loss function corresponding to the preset machine learning algorithm; and to adjust the model parameters of the target model based on the loss value.

[0173] In one embodiment, the training unit is specifically used to obtain the matching degree between the reference model and the target model; input the reference output result, the target output result and the matching degree into the loss function to obtain the loss value, wherein the magnitude of the matching degree is negatively correlated with the magnitude of the loss value.

[0174] In one embodiment, the preset machine learning algorithm is a distillation learning algorithm.

[0175] In one embodiment, the iteration module 1002 further includes:

[0176] A selection unit is used to randomly select the target model from the current model set;

[0177] A matching unit is used to calculate the matching degree between the target model and the other models using a matching network for each other model in the current model set.

[0178] The first determining unit is used to determine the other model as the reference model if the matching degree is greater than a preset matching degree threshold.

[0179] In one embodiment, the iteration module 1002 further includes:

[0180] The update unit is used to update the network parameters of the matching network based on the output of the target model and the output of the reference model.

[0181] In one embodiment, the update frequency of the network parameters of the matching network is greater than or equal to the iteration frequency of the iterative learning.

[0182] In one embodiment, the iteration module 1002 further includes:

[0183] The second determining unit is used to determine a candidate model in the current model set, wherein the performance index value of the candidate model is less than the performance index value of the trained target model.

[0184] A replacement unit is used to replace the candidate model in the current model set with the trained target model.

[0185] In one embodiment, the acquisition module 1001 includes:

[0186] The setting unit is used to set the hyperparameters of each of the initial pruning algorithms to random values;

[0187] A pruning unit is used to prune the source model for each initial pruning algorithm using the initial pruning algorithm and the target compression ratio to obtain an initial model, thereby obtaining the initial model set.

[0188] In one embodiment, the acquisition module 1001 further includes:

[0189] An addition unit is used to perform convolution kernel addition processing on the target convolutional layer of the source model to obtain the target source model, wherein the layer number of the target convolutional layer is less than a preset layer number threshold.

[0190] The pruning unit is specifically used to prune the target source model using the initial pruning algorithm and the target compression ratio to obtain an initial model.

[0191] In one embodiment, the apparatus further includes:

[0192] The detection module is used to detect whether the number of model parameters and the model computing power of each initial model meet the preset conditions.

[0193] An addition module is used to add the initial model to the initial model set if the number of model parameters and the model computing power of the initial model meet the preset conditions.

[0194] In one embodiment, the determining module 1003 includes:

[0195] The second acquisition unit is used to acquire the performance index values ​​of each pruning model in the pruning model set;

[0196] The third determining unit is used to determine the pruned model based on the performance index values ​​of each pruned model.

[0197] In one embodiment, the third determining unit is specifically used to determine the pruning model with the largest performance index value from each of the pruning models; and to retrain the pruning model with the largest performance index value to obtain the pruned model.

[0198] In one embodiment, the third determining unit is specifically used to determine multiple candidate pruning models from each of the pruning models in descending order of performance index values; to retrain each of the candidate pruning models to obtain multiple retrained pruning models; and to select the retrained pruning model with the largest performance index value among the retrained pruning models as the pruned model.

[0199] Each module in the aforementioned model pruning device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0200] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 11 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores model pruning data. The I / O interfaces allow the processor to exchange information with external devices. The communication interface allows communication with external terminals via a network connection. When executed by the processor, the computer program implements a model pruning method.

[0201] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0202] This application also provides a computer-readable storage medium. One or more non-volatile computer-readable storage media containing computer-executable instructions, which, when executed by one or more processors, cause the processors to perform the steps of a model pruning method.

[0203] This application also provides a computer program product containing instructions that, when run on a computer, cause the computer to execute a model pruning method.

[0204] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0205] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0206] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0207] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A model pruning method, characterized in that, include: Obtain the initial model set corresponding to the source model to be pruned. Each initial model in the initial model set is obtained by pruning the source model using each initial pruning algorithm. The source model is a classification model or an object detection model. The initial model set is used as the current model set for iterative learning. For each iteration, a target model is randomly selected from the current model set. For each other model in the current model set, a matching network is used to calculate the matching degree between the target model and the other models. If the matching degree is greater than a preset matching degree threshold, the other model is determined as a reference model. The target model is trained using the reference model, and the current model set is updated using the trained target model until a target model set is obtained. The target model and the reference model are used to process images. Based on the target model set and the screening criteria, the pruned model corresponding to the source model is determined.

2. The method according to claim 1, characterized in that, Training the target model using the reference model includes: Obtain the reference output result of the reference model for the target input sample, and obtain the target output result of the target model for the target input sample; The target model is trained based on the reference output, the target output, and the preset machine learning algorithm.

3. The method according to claim 2, characterized in that, The step of training the target model based on the reference output, the target output, and a preset machine learning algorithm includes: The loss value is calculated based on the reference output result, the target output result, and the loss function corresponding to the preset machine learning algorithm; Adjust the model parameters of the target model based on the loss value.

4. The method according to claim 3, characterized in that, The step of calculating the loss value based on the reference output result, the target output result, and the loss function corresponding to the preset machine learning algorithm includes: Obtain the matching degree between the reference model and the target model; The reference output, the target output, and the matching degree are input into the loss function to obtain the loss value. The magnitude of the matching degree is negatively correlated with the magnitude of the loss value.

5. The method according to any one of claims 2-4, characterized in that, The preset machine learning algorithm is the distillation learning algorithm.

6. The method according to claim 1, characterized in that, The method further includes: The network parameters of the matching network are updated based on the output of the target model and the output of the reference model.

7. The method according to claim 6, characterized in that, The update frequency of the network parameters of the matching network is greater than or equal to the iteration frequency of the iterative learning.

8. The method according to claim 1, characterized in that, The step of updating the current model set using the trained target model includes: A candidate model is determined from the current model set, wherein the performance index value of the candidate model is less than the performance index value of the trained target model. The candidate model is replaced with the trained target model in the current model set.

9. The method according to claim 1, characterized in that, The initial model set corresponding to the source model to be pruned includes: Set the hyperparameters of each of the initial pruning algorithms to random values; For each of the initial pruning algorithms, the source model is pruned using the initial pruning algorithm and the target compression ratio to obtain an initial model, thus obtaining the initial model set.

10. The method according to claim 9, characterized in that, Before pruning the source model using the initial pruning algorithm and the target compression ratio to obtain the initial model, the method further includes: The target convolutional layer of the source model is subjected to kernel increase processing to obtain the target source model, wherein the layer number of the target convolutional layer is less than a preset layer number threshold. The process of pruning the source model using the initial pruning algorithm and the target compression ratio to obtain the initial model includes: The initial model is obtained by pruning the target source model using the initial pruning algorithm and the target compression ratio.

11. The method according to claim 9, characterized in that, The method further includes: For each initial model, check whether the number of model parameters and the model computing power of the initial model meet the preset conditions; If the number of model parameters and the model computing power of the initial model meet the preset conditions, then the initial model is added to the initial model set.

12. The method according to claim 1, characterized in that, The step of determining the pruned model corresponding to the source model based on the target model set and screening conditions includes: Obtain the performance index values ​​of each pruning model in the target model set; The pruned model is determined based on the performance index values ​​of each pruned model.

13. The method according to claim 12, characterized in that, The step of determining the pruned model based on the performance index values ​​of each pruned model includes: From all the pruning models described, determine the pruning model with the highest performance index value; The pruned model with the largest performance index value is retrained to obtain the pruned model.

14. The method according to claim 12, characterized in that, The step of determining the pruned model based on the performance index values ​​of each pruned model includes: Multiple candidate pruning models are determined from each pruning model according to the performance index values ​​in descending order. Each of the candidate pruning models is retrained to obtain multiple retrained pruning models. The retrained pruned model with the highest performance index value among all the retrained pruned models is taken as the pruned model.

15. A model pruning device, characterized in that, include: The acquisition module is used to acquire the initial model set corresponding to the source model to be pruned. Each initial model in the initial model set is obtained by pruning the source model using each initial pruning algorithm. The source model is a classification model or an object detection model. An iterative module is used to take the initial model set as the current model set and perform iterative learning. For each iteration, a target model is randomly selected from the current model set. For each other model in the current model set, a matching network is used to calculate the matching degree between the target model and the other models. If the matching degree is greater than a preset matching degree threshold, the other model is determined as a reference model. The target model is trained using the reference model, and the current model set is updated using the trained target model until a target model set is obtained. The target model and the reference model are used to process images. The determination module is used to determine the pruned model corresponding to the source model based on the target model set and the screening conditions.

16. A computer device, comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the computer program is executed by the processor, it causes the processor to perform the steps of the method as described in any one of claims 1 to 14.

17. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 14.

18. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 14.