Neural network pruning method, medium and electronic device

Through evolutionary algorithm search and pruning optimization, it solves the problems of low efficiency of neural network pruning technology and imbalance of multiple performance indicators, and achieves efficient application in resource-limited platforms and real-time online processing scenarios.

CN114239826BActive Publication Date: 2024-10-22TONGJI UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111607946.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-21
Publication Date
2024-10-22
Estimated Expiration
2041-12-21

AI Technical Summary

Technical Problem

Existing neural network pruning technology is inefficient and difficult to achieve a balance between multiple performance indicators, resulting in limited application in platforms with limited resources and real-time online processing scenarios.

Method used

Use an evolutionary algorithm to search multiple candidate network structures, optimize at least two performance indicators through the objective function, inherit some parameters of the pre-trained neural network, and perform pruning to obtain the optimal candidate network structure.

Benefits of technology

It improves the efficiency of the pruning process, achieves a balance between multiple performance indicators, reduces computing resources and time costs, and improves pruning efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114239826B_ABST
    Figure CN114239826B_ABST
Patent Text Reader

Abstract

The present invention provides a neural network pruning method, medium and electronic device. The neural network pruning method comprises: pre-training a target neural network to obtain a pre-trained neural network; initializing the pruning rate of each layer of the target neural network to obtain a candidate network structure, the number of the candidate network structures is at least three; using an evolutionary algorithm to search the candidate network structure to obtain an optimal candidate network structure, and in addition, during the search process of the evolutionary algorithm, each of the candidate network structures inherits part of the parameters of the pre-trained neural network; pruning the optimal candidate network structure to obtain a pruning model. The method can quickly obtain a series of pruned networks with different compression degrees and achieve a balance between at least two pruning indicators, reducing the computing resources and time cost required for pruning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a neural network compression method, and in particular to a neural network pruning method, medium and electronic equipment. Background Art

[0002] In recent years, deep learning algorithms represented by convolutional neural networks have made breakthrough progress in computer vision, natural language processing, speech recognition and other fields. Although common neural network models have achieved performance that exceeds that of humans in multiple tasks, this is only an attempt at the scientific research level. In the actual deployment process, the shortcomings of high storage and high power consumption of neural network models seriously restrict their application in resource-limited platforms and scenarios that require real-time online processing. How to reduce the storage space and computational complexity of neural network models and ensure that the performance of neural networks remains unchanged or only slightly decreases is one of the current research hotspots. Existing model compression optimization methods include: low-rank decomposition, network pruning, model quantization, knowledge distillation and compact network design.

[0003] Pruning technology reduces the complexity of the model by removing redundant connections in the neural network, thereby compressing the neural network. For the compression rate of the model, the total pruning rate is usually determined based on human needs or experience, and the same pruning threshold is assigned to each convolutional layer. This processing method leads to low efficiency in the pruning process, and a complete pruning process can only obtain a pruned model with an expected compression amount. At the same time, when the uniform pruning strategy involves two or more performance indicators, it is difficult to achieve a balance between the performance indicators. Summary of the invention

[0004] In view of the above-mentioned shortcomings of the prior art, the object of the present invention is to provide a neural network pruning method, medium and electronic device for solving the problems of low efficiency of the pruning process and imbalance between multiple performance indicators in the prior art.

[0005] To achieve the above-mentioned purpose and other related purposes, the first aspect of the present invention provides a neural network pruning method, which includes: pre-training a target neural network to obtain a pre-trained neural network; initializing the pruning rate of each layer of the target neural network to obtain a candidate network structure, the number of the candidate network structures is at least three; using an evolutionary algorithm to search the candidate network structures to obtain an optimal candidate network structure, wherein the objective function of the evolutionary algorithm is a function of at least two performance indicators, and the optimal candidate network structure is one or more of the candidate network structures, and in addition, during the search process of the evolutionary algorithm, each of the candidate network structures inherits some parameters of the pre-trained neural network; pruning the optimal candidate network structure to obtain a pruned model.

[0006] In an embodiment of the first aspect, the performance indicators include: model calculation amount, model parameter amount, running memory, forward reasoning time and / or model accuracy.

[0007] In an embodiment of the first aspect, before using the evolutionary algorithm to search for the candidate network structure, the neural network pruning method further includes: performing regularization training on the candidate network structure to obtain a sparse candidate network structure.

[0008] In an embodiment of the first aspect, the implementation method of obtaining the optimal candidate network structure according to the objective function and searching the candidate network structure through an evolutionary algorithm includes: obtaining an initial population of the evolutionary algorithm based on the candidate network structure, wherein the individuals of the initial population correspond one-to-one to the candidate network structure; obtaining the parameters of the candidate network structure according to the parameters of the pre-trained neural network; processing the training data set through a forward propagation algorithm to adjust the statistical parameters of the normalization layer of the candidate network structure; obtaining a non-dominated solution set of the evolutionary algorithm according to the objective function and through mutation, crossover and selection operations; and obtaining the optimal candidate network structure based on the individuals in the non-dominated solution set.

[0009] In an embodiment of the first aspect, the statistical parameters of the normalization layer include mean and variance.

[0010] In an embodiment of the first aspect, each individual in the initial population corresponds to a list, and each element of the list is the number of convolution kernel channels required to be pruned in each layer of the candidate network structure.

[0011] In an embodiment of the first aspect, the optimal candidate network structure is pruned to obtain a pruned model, and the implementation method includes: obtaining parameters of the optimal candidate network structure according to parameters of the pre-trained neural network; pruning the optimal candidate network structure to obtain the pruned model; and retraining the pruned model based on the training data set.

[0012] In an embodiment of the first aspect, the evolutionary algorithm includes a multi-objective differential evolution algorithm.

[0013] A second aspect of the present invention provides a computer-readable storage medium, and when the computer program is executed by a processor, it implements the neural network pruning method described in any one of the first aspects of the present invention.

[0014] The third aspect of the present invention provides an electronic device, comprising: a memory on which a computer program is stored; and a processor, which is communicatively connected to the memory and executes the neural network pruning method described in any one of the first aspects of the present invention when the computer program is called.

[0015] As described above, the neural network pruning method, medium and electronic device of the present invention have the following beneficial effects:

[0016] The neural network pruning method searches for candidate network structures through an evolutionary algorithm and prunes the searched optimal candidate network structure, wherein the objective function of the evolutionary algorithm is a function of at least two performance indicators, and the optimal candidate network structure is one or more of the candidate network structures, so that the neural network pruning method can obtain a series of pruned networks with different compression degrees according to the Pareto solution set of the evolutionary algorithm. In addition, since the objective function is a function of at least two performance indicators, it is possible to achieve a balance between two or more performance indicators during the pruning process, thereby reducing the computing resources and time cost required for pruning and improving pruning efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 Shown is a flowchart of a specific embodiment of the neural network pruning method of the present invention.

[0018] Figure 2 Shown is a flowchart of the neural network pruning method of the present invention in a specific embodiment using an evolutionary algorithm to search the candidate network structure to obtain the optimal candidate network structure.

[0019] Figure 3 Shown is a flowchart of pruning the optimal candidate network structure to obtain a pruning model in a specific embodiment of the neural network pruning method of the present invention.

[0020] Figure 4 Shown is a flowchart of a specific embodiment of the neural network pruning method of the present invention.

[0021] Figure 5 Shown is a schematic structural diagram of the electronic device of the present invention in a specific embodiment.

[0022] Component number description

[0023] 500 Server

[0024] 510 Memory

[0025] 520 processor

[0026] Steps S11-S14

[0027] Steps S21-S25

[0028] Steps S31-S33

[0029] Steps S41-S59 DETAILED DESCRIPTION

[0030] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects 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. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.

[0031] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0032] In the existing pruning technology, a uniform pruning strategy is generally adopted, that is, the total pruning rate is determined by human needs or experience and the same pruning threshold is assigned to each convolutional layer. This processing strategy leads to an inefficient pruning process. A complete pruning process can only obtain a pruning model with an expected compression amount in a targeted manner. Moreover, when the uniform pruning strategy involves two or more performance indicators, it is difficult to achieve a balance between the performance indicators.

[0033] In view of the above problems, the present invention provides a neural network pruning method, which includes pre-training a target neural network to obtain a pre-trained neural network; initializing the target neural network to obtain a candidate network structure, the number of the candidate network structures is at least three; using an evolutionary algorithm to search the candidate network structure to obtain an optimal candidate network structure, and in addition, during the search process of the evolutionary algorithm, each of the candidate network structures inherits the parameters of the pre-trained neural network; pruning the optimal candidate network structure to obtain a pruning model. Compared with the conventional uniform pruning strategy, the neural network pruning method improves the efficiency of the entire pruning process and achieves a balance between two or more pruning indicators.

[0034] In one embodiment of the present invention, specifically, please refer to Figure 1 , the neural network pruning method comprises:

[0035] S11, pre-training the target neural network to obtain a pre-trained neural network. The target neural network is, for example, a convolutional neural network, but the present invention is not limited thereto.

[0036] S12, initialize the pruning rate of each layer of the target neural network to obtain a candidate network structure, and the number of the candidate network structures is at least three. Specifically, by initializing the pruning rate of each layer of the target neural network, a plurality of different pruned network structures can be obtained, and the pruned network structure is the candidate network structure, and the number of the candidate network structures is at least three. Optionally, the initialization method may include uniform initialization and random initialization. Optionally, the number of the candidate network structures is generally 50-100.

[0037] S13, using an evolutionary algorithm to search the candidate network structure to obtain the optimal candidate network structure, wherein the objective function of the evolutionary algorithm is a function of at least two performance indicators, and the optimal candidate network structure is one or more of the candidate network structures, and in addition, during the search process of the evolutionary algorithm, each of the candidate network structures inherits some parameters of the pre-trained neural network. Specifically, the evolutionary algorithm is also called an evolutionary algorithm (EAs), which is a mature global optimization method with high robustness and wide applicability, with the characteristics of self-organization, self-adaptation, and self-learning, and can be free from the nature of the problem, and effectively handle complex problems that are difficult to solve by traditional optimization algorithms. In this embodiment, the candidate network structure can be obtained by searching the candidate network structure through the evolutionary algorithm as the optimal candidate network structure. Optionally, in this embodiment, the evolutionary algorithm may include a multi-objective differential evolution algorithm, but the present invention is not limited thereto. Optionally, the optimal candidate network structure is included in the Pareto frontier, generally consisting of dozens of solution sets. The evolutionary algorithm can achieve a balance between two or more performance indicators, and there will be no problems such as small model calculation amount but serious reduction in accuracy.

[0038] In addition, during the search process of the evolutionary algorithm, each of the candidate network structures inherits some parameters of the pre-trained neural network to achieve fine-tuning of the candidate network structure, thereby improving the search efficiency.

[0039] Optionally, the performance indicators may include model calculation amount, model parameter amount, running memory, forward reasoning time and / or model accuracy, etc., wherein the model calculation amount refers to the number of floating-point number operations of the forward propagation of the neural network model; the forward reasoning time refers to: after the neural network model is deployed on a specific hardware, the time required to input a test image into the model and output the result; the running memory refers to the size of the memory occupied by the neural network model in the process of processing a group of images; the model accuracy refers to the accuracy that the neural network model can obtain under a given data set.

[0040] S14, pruning the optimal candidate network structure to obtain a pruned model. Specifically, the optimal candidate network structure may be pruned once to obtain a pruned model corresponding to the optimal candidate network. It should be noted that in this embodiment, a specific number of optimal candidate network structures may be selected for pruning as needed, or each of the optimal candidate network structures may be pruned.

[0041] According to the above description, the neural network pruning method described in this example can make the candidate network structure obtained subsequently inherit some parameters of the pre-trained neural network by pre-training the target neural network, so as to adjust the statistical parameters of the normalization layer of the candidate network structure and improve the efficiency of evaluating the accuracy of the candidate network structure. By initializing the pruning rate of each layer of the target neural network to obtain the candidate network structure, it is no longer necessary to manually set an expected pruning threshold as a constraint, and all integers within the width of each convolution layer can be used as possible pruning thresholds, which greatly expands the search space and is conducive to obtaining more potential optimal solutions in a large space. In addition, this embodiment searches for candidate network structures through an evolutionary algorithm and prunes the searched optimal candidate network structure, wherein the objective function of the evolutionary algorithm is a function of at least two performance indicators, and the optimal candidate network structure is one or more of the candidate network structures, so that after each search is completed, a series of candidate solutions with different pruning indicators and different compression amounts can be obtained, and then the appropriate structure is selected for pruning according to actual needs, so that the neural network pruning method can reduce the search time of the candidate network structure and improve the efficiency of the entire pruning process. Furthermore, since the objective function is a function of at least two performance indicators, a balance between various pruning indicators can be achieved.

[0042] In one embodiment of the present invention, before the evolutionary algorithm is used to search for the candidate network structure, the neural network pruning method further includes: performing regularization training on the candidate network structure to obtain a sparse candidate network structure. In this embodiment, by performing regularization training on the candidate network structure, the storage space of the candidate network structure can be effectively reduced, the evaluation of the evolutionary algorithm search process can be facilitated, and the amount of computation of the entire pruning process can be effectively reduced, and the efficiency of the entire pruning process can be improved.

[0043] See also Figure 2 In one embodiment of the present invention, an evolutionary algorithm is used to search the candidate network structure, and a method for obtaining the optimal candidate network structure includes:

[0044] S21, acquiring an initial population of the evolutionary algorithm based on the candidate network structure, wherein individuals of the initial population correspond one-to-one to the candidate network structure.

[0045] Optionally, each individual in the initial population corresponds to a list, and each element of the list is the number of convolution kernel channels required to be pruned in each layer of the candidate network structure.

[0046] S22, acquiring parameters of the candidate network structure according to the parameters of the pre-trained neural network. For example, the candidate network structure may acquire some parameters of the pre-trained neural network as its parameters by inheritance.

[0047] S23, processing the training data set through the forward propagation algorithm to adjust the statistical parameters of the normalization layer of the candidate network structure. Specifically, when the training data set is a small data set, all the training data can be processed by the forward propagation algorithm to adjust the statistical parameters of the normalization layer. When the training data set is a large data set, part of the training data can be processed by the forward propagation algorithm to complete the fine-tuning of the statistical parameters of the normalization layer. Therefore, whether the training data set is a large data set and / or a small data set, this embodiment can greatly improve the efficiency of the evolutionary algorithm search. In this embodiment, the statistical parameters are, for example, mean and variance.

[0048] S24, obtaining a non-dominated solution set of the evolutionary algorithm according to the objective function through mutation, crossover and selection operations.

[0049] Specifically, in this embodiment, the non-dominated solution set of the evolutionary algorithm can be obtained by iteration. During the iteration process, each round of mutation, crossover and selection operations is performed, and the current number of iterations is increased by 1 and it is determined whether the current number of iterations reaches the set maximum number. If the iteration is not completed, the current population is continued to be crossover, mutation and other operations. If the iteration is completed, the non-dominated solution set in the current population is output. Optionally, the initial number of iterations in this embodiment can be set to 0.

[0050] During the iteration process, the fitness value of the individuals in the population can be determined according to the objective function. Optionally, when the objective function is a maximum problem, the fitness value of the individual can be determined by taking the objective function to be solved as the fitness function of the individual. When the objective function is a minimum problem, the fitness function of the individual is symmetric with the objective function to be solved about the x-axis, and the fitness value of the individual can be determined by solving the fitness function of the individual. One implementation of the mutation operation is to select two individuals from the population at random, scale the difference between the two, and sum it with the individual to be mutated. One implementation of the crossover operation is to perform a single-point gene crossover on the mutated individuals. One implementation of the selection operation is to mix the mutated individuals with the original population, then perform non-dominated hierarchical sorting on each individual in the mixed parent and child populations, sort them according to the dominance relationship between the hierarchies according to the number of dominance solutions, and select the first N individuals as the next generation population, where N is greater than or equal to 1.

[0051] S25, obtaining the optimal candidate network structure according to the individuals in the non-dominated solution set.

[0052] According to the above description, the neural network pruning algorithm described in this example greatly improves the iteration process of the evolutionary algorithm by fine-tuning the statistical parameters of the normalization layer in the process of searching the candidate network structure using the evolutionary algorithm, thereby improving the efficiency of the evolutionary algorithm in searching the candidate network structure. In addition, with the help of the objective function, the evolutionary algorithm can automatically complete the search for candidate network structures with different compression degrees, and can select the compression structure that meets the scene requirements as needed, thereby increasing the flexibility and robustness of the neural network model pruning and improving the generalization ability of the neural network model.

[0053] See also Figure 3 In one embodiment of the present invention, the optimal candidate network structure is pruned to obtain a pruned model, and the implementation method includes:

[0054] S31, acquiring parameters of the optimal candidate network structure according to the parameters of the pre-trained neural network. Specifically, the optimal candidate network structure may acquire part of the parameters of the pre-trained neural network as its parameters in an inheritance manner.

[0055] S32, pruning the optimal candidate network structure to obtain the pruned model. Specifically, the optimal candidate network structure may be pruned once to obtain the pruned model corresponding to each optimal candidate network.

[0056] S33, retraining the pruned model based on the training data set. Preferably, the value of the learning rate can be adjusted during the retraining process so that the learning rate decays with the increase in the number of training times. During the entire fine-tuning process, the learning rate should be much smaller than the value of the initial training, so as to improve the performance of the pruned model.

[0057] According to the above description, the neural network pruning method described in this example includes retraining the pruning model to ensure that the pruning model has better performance.

[0058] In one embodiment of the present invention, one of the performance indicators of the objective function is accuracy. At this time, the neural network pruning method can further refine the contribution of neural network layers to the accuracy of the neural network by initializing the pruning rate of each layer of the target neural network, and greatly expand the search space, which is conducive to obtaining more potential better solutions in a large space, and effectively solves the problem of ignoring the relationship between neural network layers in conventional uniform pruning strategies. Under the same compression amount, a smaller drop in accuracy can be obtained, thereby having better accuracy. In addition, the value of the learning rate can be adjusted during the retraining process. During the fine-tuning process, the learning rate should be much smaller than the value of the initial training, so as to further improve the accuracy of the pruning model.

[0059] See also Figure 4 In one embodiment of the present invention, the neural network pruning method includes:

[0060] S41, pre-training the target neural network to obtain a pre-trained neural network. The target neural network is, for example, a convolutional neural network, but the present invention is not limited thereto.

[0061] S42, initialize the pruning rate of each layer of the target neural network to obtain a candidate network structure, and the number of the candidate network structures is at least three. Specifically, by initializing the pruning rate of each layer of the target neural network, a plurality of different pruned network structures can be obtained, and the pruned network structure is the candidate network structure, and the number of the candidate network structures is at least three. Optionally, the initialization method may include uniform initialization and random initialization. Optionally, the number of the candidate network structures is generally 50-100.

[0062] S43, performing regularization training on the candidate network structure to obtain a sparse candidate network structure.

[0063] S44, acquiring an initial population of the evolutionary algorithm based on the candidate network structure, wherein individuals of the initial population correspond one-to-one to the candidate network structure.

[0064] Optionally, each individual in the initial population corresponds to a list, and each element of the list is the number of convolution kernel channels required to be pruned in each layer of the candidate network structure. For example, if the candidate network structure has 14 layers of convolution kernel channels that need to be pruned, then the convolution kernel channels required to be pruned for the individuals corresponding to the candidate network structure can be expressed as: α = [α1, α2, ..., α 14 ], where α i It is the pruning threshold of each convolutional layer.

[0065] S45, acquiring parameters of the candidate network structure according to the parameters of the pre-trained neural network. Specifically, the candidate network structure may acquire part of the parameters of the pre-trained neural network as its parameters by inheritance.

[0066] S46, processing the training data set by a forward propagation algorithm to adjust the statistical parameters of the normalization layer of the candidate network structure. Specifically, when the training data set is a small data set, the forward propagation algorithm can be used to process all the training data to adjust the statistical parameters of the normalization layer. When the training data set is a large data set, the forward propagation algorithm can be used to process part of the training data to complete the fine-tuning of the normalization layer. Optionally, the statistical parameters may include a mean and a variance. For example, the normalization layer of the candidate network structure may be described as Where x and y are the input and output data of the normalization layer, the scale parameter γ and the bias parameter β are the learnable parameters of the normalization layer, and μ and σ 2 is the mean and variance obtained based on the statistics of the training data set. ε is a very small constant to prevent the denominator from being zero. μ and σ 2 It can be updated by the following formula, μ t =m×μ t-1 +(1-m)×μ b , Where t refers to the number of training iterations, μ b and Indicates the mean and variance of the input data in the current batch. The default value of m is 0.9. In training mode, μ can be updated by forward reasoning with only a small amount of training data. b and This reduces the problem of mismatching statistical parameters of the normalization layer between the candidate network structure and the pre-trained model, and after updating the statistical parameters, a fast and effective evaluation of the candidate network structure can be achieved.

[0067] S47, according to the objective function and through mutation, crossover and selection operations, obtain the non-dominated solution set of the evolutionary algorithm. Specifically, the objective function of the evolutionary algorithm is determined according to the performance index, and based on the objective function, the candidate network structure is searched by the evolutionary algorithm to obtain the optimal candidate network structure. In practical applications, the non-dominated solution set can be obtained in an iterative manner. Specifically, each round of mutation, crossover and selection operations requires adding 1 to the current number of iterations and judging whether the current number of iterations reaches the set maximum number. If the iteration is not completed, continue to perform crossover, mutation and other operations on the current population. If the iteration is completed, the non-dominated solution set in the current population is output. Optionally, the initial number of iterations can be set to 0. Optionally, the evolutionary algorithm can include a multi-objective differential evolution algorithm.

[0068] Optionally, the performance indicators may include model calculation amount, model parameter amount, running memory, forward reasoning time and / or model accuracy, etc. Among them, the model calculation amount refers to the number of times the forward propagation of the neural network model is run. The forward reasoning time refers to the time required for the neural network model to be deployed on a specific hardware, input a test image into the model, and output the result. The running memory refers to the size of the memory occupied by the neural network model in the process of predicting a group of images. The model accuracy refers to the accuracy that the neural network model can obtain under a given data set.

[0069] For example, when the selected performance indicators are FLOPs (Floating Point Operations, model calculation amount) and model accuracy, the objective function can be expressed as: max a F(a)=(f1(a),f2(a)),sta=(a1,a2,…,a l ), where f1 and f2 represent the compression of FLOPs and the accuracy of the pruned model, a i is the pruning threshold of each convolutional layer, where the calculation formula of FLOPs can be expressed as: FLOPs i =(N i-1 -α i-1 )×(N i -α i )×K 2 ×H i ×W i , Among them, N i and N i+1 represents the number of input and output channels of the i-th layer, K 2 is the filter size, H i ×W iis the length and width of the output feature map of this layer, and l represents the number of convolutional layers of the model. One implementation of the mutation operation is to select two individuals from the population at random, scale the difference between the two, and sum it with the individual to be mutated. This process can be expressed as u n,g+1 =x n1,g +F×(x n2,g -x n3,g ), where x n1,g is the g-th generation individual to be mutated, x n2,g and x n3,g are two random individuals of the gth generation, and u n,g+1 is the (g+1)th generation individual after mutation, and F is the scaling factor, which can be 0.2. One implementation of the crossover operation is to perform a single-point gene crossover on the mutated individual, and the process can be expressed as Among them, CR is the crossover probability, which can be 0.9, n rand is a random integer, so as to ensure that at least one dimension of genes in the crossover operation comes from the genes generated by the mutation operation. One implementation of the selection operation is to mix the mutated individuals with the original population, and then perform non-dominated hierarchical sorting on each individual in the mixed parent and child populations, sort them according to the dominance relationship between the hierarchies according to the number of dominating solutions, and select the first N individuals as the next generation population, where N is greater than or equal to 1.

[0070] S48, obtaining the optimal candidate network structure according to the individuals in the non-dominated solution set. Specifically, individuals that meet preset conditions can be obtained from the non-dominated solution set as the optimal candidate network structure.

[0071] S49, pruning the optimal candidate network structure to obtain a pruned model.

[0072] Optionally, a method for pruning the optimal candidate network structure to obtain a pruned model includes: obtaining parameters of the optimal candidate network structure according to parameters of the pre-trained neural network, pruning the optimal candidate network structure to obtain the pruned model, and retraining the pruned model based on the training data set.

[0073] Optionally, the optimal candidate network structure can obtain some parameters of the pre-trained neural network as its parameters by inheritance. In addition, the present embodiment can perform a one-time pruning on the optimal candidate network structure to obtain a pruned model corresponding to each optimal candidate network. The present embodiment preferably retrains the pruned model according to the training data set. During the retraining process, the value of the learning rate can be adjusted so that the learning rate decays with the number of training times. In the entire fine-tuning process, the learning rate should be much smaller than the value of the initial training, so as to improve the performance of the pruned model.

[0074] According to the above description, the neural network pruning method in this example includes pre-training the target neural network to obtain a pre-trained neural network, initializing the target neural network to obtain a candidate network structure, using an evolutionary algorithm to search the candidate network structure to obtain an optimal candidate network structure, and pruning the optimal candidate network structure. Compared with the conventional uniform pruning method, a series of pruned networks with different compression degrees can be quickly obtained and a balance between multiple pruning indicators can be achieved, reducing the computing resources and time cost required for pruning.

[0075] Based on the above description of the neural network pruning method, the present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, Figure 1 or Figure 4 The neural network pruning method shown.

[0076] Based on the above description of the neural network pruning method, the present invention also provides an electronic device. Figure 5 In one embodiment of the present invention, the electronic device 500 includes: a memory 510 on which a computer program is stored; a processor 520, which is connected to the memory 510 for executing the computer program and implementing Figure 1 or Figure 4 The neural network pruning method shown.

[0077] The protection scope of the neural network pruning method described in the present invention is not limited to the execution order of the steps listed in this embodiment. All solutions implemented by adding, reducing or replacing steps in the prior art based on the principles of the present invention are included in the protection scope of the present invention.

[0078] In summary, the neural network pruning method, medium and electronic device of the present invention are used to simultaneously optimize multiple performance indicators of the neural network model, achieve the acquisition of sub-networks with different compression degrees at the time cost of one search, reduce the search cost in the pruning process, and achieve the best balance between multiple performance indicators. Therefore, the present invention effectively overcomes various shortcomings in the prior art and has a high industrial utilization value.

[0079] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.

Claims

1. A neural network pruning method, characterized in that: The neural network pruning method comprises: Pre-training a target neural network to obtain a pre-trained neural network, wherein the target neural network is applied to the field of image processing; Initializing the pruning rate of each layer of the target neural network to obtain a candidate network structure, where the number of the candidate network structures is at least three; An evolutionary algorithm is used to search the candidate network structure to obtain an optimal candidate network structure, wherein the objective function of the evolutionary algorithm is a function of at least two performance indicators, and the optimal candidate network structure is one or more of the candidate network structures. In addition, during the search process of the evolutionary algorithm, each of the candidate network structures inherits some parameters of the pre-trained neural network, and the performance indicators include: model calculation amount, model parameter amount, running memory, forward reasoning time and / or model accuracy. The forward reasoning time refers to the time required for the neural network to be deployed on a specific hardware, input a test image into the model, and output the result. The running memory refers to the size of the memory occupied by the neural network model in the process of predicting a group of images. Pruning the optimal candidate network structure to obtain a pruned model; Before using the evolutionary algorithm to search for the candidate network structure, the neural network pruning method further includes: performing regularization training on the candidate network structure to obtain a sparse candidate network structure; The method for implementing the search of the candidate network structure by an evolutionary algorithm to obtain the optimal candidate network structure includes: obtaining an initial population of the evolutionary algorithm based on the candidate network structure, wherein the individuals of the initial population correspond one-to-one to the candidate network structure; obtaining the parameters of the candidate network structure according to the parameters of the pre-trained neural network; processing the training data set by a forward propagation algorithm to adjust the statistical parameters of the normalization layer of the candidate network structure; obtaining the non-dominated solution set of the evolutionary algorithm according to the objective function and through mutation, crossover and selection operations; obtaining the optimal candidate network structure according to the individuals in the non-dominated solution set; the statistical parameters of the normalization layer include mean and variance; each individual in the initial population corresponds to a list, and each element of the list is the number of convolution kernel channels required to be pruned in each layer of the candidate network structure.

2. The neural network pruning method according to claim 1, characterized in that: The method for pruning the optimal candidate network structure to obtain a pruning model includes: Obtaining parameters of the optimal candidate network structure according to the parameters of the pre-trained neural network; Pruning the optimal candidate network structure to obtain the pruned model; The pruned model is retrained based on the training data set.

3. The neural network pruning method according to claim 1, characterized in that: The evolutionary algorithm includes a multi-objective differential evolution algorithm.

4. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the neural network pruning method described in any one of claims 1 to 3 is implemented.

5. An electronic device, characterized in that: The electronic device comprises: A memory storing a computer program; A processor is communicatively connected to the memory, and executes the neural network pruning method according to any one of claims 1 to 3 when calling the computer program.

Citation Information

Patent Citations

  • Multi-objective optimization control method and system for sewage treatment

    CN113189881A

  • Lossless Model Compression by Batch Normalization Layer Pruning in Deep Neural Networks

    US20190370656A1

  • Global optimization, searching and machine learning method based on lamarck acquired genetic principle

    WO2018161468A1