A deep convolutional neural network pruning method and system based on co-evolution

By automatically selecting redundant convolution kernels in deep convolutional neural networks based on collaborative evolution, the problem of relying on expert experience and repeated trial and error in the existing technology is solved, and the pruning effect of significantly reducing computational overhead without losing accuracy is achieved.

CN114580512BActive Publication Date: 2025-04-25NANJING UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210177728.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-25
Publication Date
2025-04-25
Estimated Expiration
2042-02-25

AI Technical Summary

Technical Problem

The existing deep convolutional neural network pruning methods rely highly on expert experience and repeated trial and error, making them difficult to automate and efficient, resulting in hindering the application in scenarios with resource limitations.

Method used

Using the deep convolutional neural network pruning method based on collaborative evolution, through three main steps of grouping, intra-group evolution and merging, the redundant convolution kernel is automatically selected and the cropping ratio is determined, reducing calculation overhead and maintaining network accuracy.

Benefits of technology

The pruning effect of significantly reducing neural network computing overhead without losing accuracy is achieved, avoiding dependence on expert knowledge, and the optimization process is easy to parallel and scale.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114580512B_ABST
    Figure CN114580512B_ABST
Patent Text Reader

Abstract

The present invention discloses a deep convolutional neural network pruning method and system based on co-evolution. First, a neural network to be pruned is read; data with a proportion of k is randomly selected from a training set; data is grouped according to the structure of the network to be pruned; and an evolutionary algorithm is used in parallel to optimize the networks; after each group completes the evolution within the group, the pruning results corresponding to the best individuals in the last generation population of each group are spliced ​​together as the pruning results of this round; after the splicing is completed, the network corresponding to the spliced ​​network that has completed a round of pruning is retrained, and the retrained network is set as the initial network to be pruned in the next round of pruning, and the network is added to the solution set A generated by the algorithm; the co-evolution cycle termination judgment is made; according to the needs of the actual application scenario, the pruning results are selected from A for use; the pruning results are deployed on a terminal device, and the data to be predicted is input into the pruned network to complete the prediction of the data category.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a deep convolutional neural network pruning method and system, and in particular to a deep convolutional neural network pruning method and system based on collaborative evolution. Background Art

[0002] Deep learning methods represented by deep convolutional neural networks have achieved great success in face recognition, speech recognition, autonomous driving and other fields. However, the smooth operation of deep learning systems often requires a large amount of computing resources, which hinders their application in resource-constrained scenarios. Therefore, lightweighting of neural networks is one of the important development directions of deep learning, and neural network pruning is one of the representative methods.

[0003] Neural network pruning methods reduce model parameters and computational overhead by pruning redundant neurons and connections between neurons in the neural network. In this process, how to identify redundant neurons and connections, and how to determine the pruning ratio of each layer in the deep neural network are the two biggest difficulties. Existing methods often use expert-defined rules to determine the importance of neurons and connections, and directly specify the pruning ratio for each layer based on expert experience. However, this process requires a lot of expert knowledge and experience, and usually requires a trial-and-error process, which hinders the practical application of existing methods.

[0004] Taking the image classification task as an example, when the deep learning system is running, it first loads the trained neural network, then uses the image to be predicted as the input of the neural network, and finally obtains the image category prediction result through layer-by-layer calculation of the deep convolutional neural network. Here, each convolution layer is composed of several convolution kernels. Usually, in the above process, all convolution kernels will participate in the prediction of the image, which will bring huge computing overhead, making it difficult to deploy the deep learning system on terminals with limited computing resources such as mobile phones. Summary of the invention

[0005] Purpose of the invention: In view of the problems and shortcomings in the prior art, deep neural convolutional network pruning is a better solution. The deep convolutional neural network pruning technology uses the trained deep convolutional neural network as the application object, and its purpose is to delete the redundant convolution kernels therein, while reducing the computational overhead required for neural network prediction without significantly damaging the accuracy of the neural network. For the deep convolutional neural network pruning technology, its key points and difficulties lie in how to identify redundant neurons and connections, and how to determine the pruning ratio of each layer in the deep neural network. The existing technical methods often require experts to define pruning rules to determine the importance of convolution kernels, and directly specify the pruning ratio for each layer of the neural network based on expert experience. However, the large amount of expert experience required for this process is often difficult to obtain, and usually requires a process of repeated trial and error, which hinders the practical application of pruning technology.

[0006] The present invention provides a collaboratively-evolution-based, efficient and automatic deep convolutional neural network pruning method and system, which reduces the computing resources required for the operation of the deep learning system and solves the problem that the deep convolutional neural network pruning method is highly dependent on expert experience and trial and error.

[0007] The essence of the deep convolutional neural network pruning problem is to select a part of the redundant convolutional kernels from all the convolutional kernels and delete them, while retaining the rest. Therefore, the deep convolutional neural network pruning problem can be naturally modeled as a subset selection problem, in which each convolutional kernel in the deep convolutional neural network corresponds to an individual in the set, and all the convolutional kernels contained in the unpruned deep convolutional neural network constitute the entire set, which is regarded as the full set of the problem. To solve this problem, the most important individuals are selected from the full set for retention, and the unselected individuals are deleted. In view of this, this scheme invents a deep convolutional neural network pruning method based on co-evolution, which includes three main steps of grouping, intra-group evolution, and merging during operation. Each main step contains several sub-steps. Among them, grouping occurs in the early stage of the solution, that is, the solution space is grouped by using the structural characteristics of the neural network to cope with the difficulty of solving the problem caused by the huge search space. Then, the two main steps of intra-group evolution and merging are repeated to complete the pruning process.

[0008] Technical solution: A deep convolutional neural network pruning method based on co-evolution adopts the following modeling form: for a given deep convolutional neural network, if it contains n convolutional layers to be pruned, the number of convolutional kernels in each convolutional layer is {l1,l2,…,l n}, then the convolution kernel of the i-th layer can be used To express it. Using indicator variable σ ij To indicate whether the jth convolution kernel of the i-th layer is retained, that is, if σ ij=1, then keep the corresponding convolution kernel. If σ ij = 0, the corresponding convolution kernel is deleted, and the pruned neural network is formalized as

[0009]

[0010] During the pruning process, it is necessary to maintain the accuracy of the network while reducing the convolution kernel. This process can be formalized as an optimization problem, that is, by optimizing F, the accuracy of the neural network is maximized while minimizing the computational overhead of the neural network. Using floating point calculations (FLOPs for short) to represent the computational overhead of the network, the optimization problem can be expressed as:

[0011]

[0012] The present invention proposes a neural network pruning method based on co-evolution, which includes three main steps: grouping, intra-group evolution, and merging. The above optimization target will be used as the fitness evaluation index of individuals in intra-group evolution. The algorithm performs natural selection in intra-group evolution according to the index to obtain a pruning result with high accuracy and low computational overhead.

[0013] Specifically, considering the characteristics of forward propagation of deep neural networks, the solution space is grouped, that is, each layer of the neural network corresponds to a group. After that, the subproblems in each group are optimized using the evolutionary algorithm (algorithm flow 2), and this process can be completed independently in each group in parallel. After each group evolves a given number of rounds within the group, the information is updated by merging between groups, that is, the convolutional layers obtained by the evolution of each group are merged into a pruned neural network in the original order before grouping. After that, the pruned network will be retrained on the training set for a certain number of rounds to help the network adapt to the pruned changes and restore accuracy. The algorithm flow is as follows:

[0014] Algorithm flow 1:

[0015] Input: Neural network Φ to be pruned; Maximum number of co-evolution rounds T1

[0016] Output: A set of pruned neural networks

[0017] 1) Initialize the co-evolution round counter t1 = 0 and initialize the set of pruned neural networks Initialize the network to be pruned in each round Φ0=Φ.

[0018] 2) When t1 <T1:

[0019] 3) Group the neural network to be pruned by layers.

[0020] 4) In parallel, use the evolutionary algorithm to optimize each group to obtain the pruning results of the corresponding layer. The detailed steps of the evolution in each group are shown in Algorithm 2.

[0021] 5) Merge the pruning results of each group to obtain a pruned neural network.

[0022] 6) Retrain the pruned neural network to help the network adapt to the pruning and restore accuracy. Add the retrained network Φ′ to the set A.

[0023] 7) Set the neural network to be pruned in the next iteration to Φ0 = Φ′.

[0024] 8)t1=t1+1.

[0025] 9) Output a set A of pruned neural networks, which includes T1 pruned neural networks with different computational costs for users to choose according to actual needs.

[0026] The detailed process of intra-group evolution is as follows:

[0027] Algorithm flow 2:

[0028] For the above-mentioned intra-group evolution process, the detailed process is as follows:

[0029] Input: A layer in a neural network, which contains l convolution kernels; the maximum number of rounds of single-group evolution is T2

[0030] Output: A layer of neural network after pruning

[0031] 1) Encoding: Encode the neural network layer into a 0-1 string of length l, where each bit indicates whether a neuron is retained or not. Each individual solution in the evolution process corresponds to a 0-1 string of length l.

[0032] 2) Population initialization, define the population size as m, and the mutation rate in the initialization phase as p1. First, add the solution with all 1s to the population. Then, use the solution with all 1s as the parent individual, and generate m-1 new individuals through the mutation operator with a mutation rate of p1, which together form the initial population.

[0033] 3) Initialize the round counter t2=0.

[0034] 4) When t2 <T2:

[0035] 5) When the number of newly generated offspring individuals is less than m:

[0036] 6) Randomly select an individual from the population as the parent individual.

[0037] 7) Execute the mutation operator with a mutation rate of p2 on the selected parent individual to generate a new offspring individual.

[0038] 8) Calculate the accuracy of n newly generated offspring individuals.

[0039] 9) Sort the 2n individuals in the parent and child generations in descending order according to their precision. For individuals with the same precision, the individuals with smaller FLOPs are ranked first. According to the sorting results, the first n individuals are selected and retained as the parent individuals of the next cycle, and the individuals not retained are eliminated.

[0040] 10)t2=t2+1.

[0041] 11) Output the individual with the highest accuracy in the last generation population as the pruning result of this layer.

[0042] In each round of iteration, the number of convolution kernels pruned from each layer should not exceed a certain ratio u of the total number of convolution kernels in that layer. This restriction can smooth the pruning process to achieve better pruning results.

[0043] According to the above process, the pruning of the neural network can be completed. As shown in the algorithm flow 1, during the execution of this method, a set of solutions with different pruning ratios will be generated, and the user can select the solution that meets the conditions according to the computational complexity limit of the actual application scenario.

[0044] According to the above ideas, the deep neural network pruning method based on collaborative evolution proposed in the present invention includes the following steps:

[0045] Step 1: Read the neural network to be pruned. From the training set D train Randomly select a proportion of k data from the k , which is used for individual evaluation of subsequent evolution within the group.

[0046] Step 2: Grouping according to the structure of the network to be pruned. Specifically, if the neural network contains n convolutional layers to be pruned, the search space of the problem can be divided into n groups by layer.

[0047] Step 3: Use the evolutionary algorithm to optimize in each group in parallel. This includes four sub-steps: initialization, generation of new solutions, evaluation of solutions, and natural selection. Before executing this step, the following hyperparameters need to be given: population size m, maximum number of evolutionary rounds within the group t, and maximum reduction ratio u of the convolution kernel in each evolution within the group. The evolution process within each group is as follows:

[0048] Step 3.1: Initialization. Encode the neural network layer corresponding to the current group into a 0-1 string. The length of the string depends on the number of convolution kernels it contains, and each convolution kernel corresponds to one bit of the string. The all-1 solution is first added to the population. Then, the mutation operator with a mutation rate of p1 is executed m-1 times on the all-1 solution to generate m-1 new individuals, which together with the all-1 solution constitute an initial population of size m. Among them, the operation of the mutation operator with a mutation rate of p and a maximum pruning ratio of u is as follows: each bit of the 0-1 string has a probability of flipping with p. When a bit of the 0-1 string is about to flip from 1 to 0, if the proportion of 0 in the 0-1 string is greater than u at this time, the flip of the bit is abandoned. This restriction can make the pruning process smoother to prevent too many convolution kernels from being pruned in a single round, resulting in loss of precision, and ultimately achieve better pruning results.

[0049] Step 3.2: Generate a new solution. Use a mutation operator with probability p2, that is, first randomly select a parent individual from the current population. For the 0-1 string corresponding to the parent individual, each bit has a probability of p2 to flip to generate a child. As described in the technical solution, in order to make the pruning process smooth, at most a proportion u of convolution kernels are deleted in each evolution within the group. To ensure this rule, when the mutation operator is used to generate offspring, if the proportion of remaining convolution kernels of the offspring at the current moment is less than or equal to 1-u, the convolution kernel will not be deleted any further. Both p1 and p2 can be set to 0.1.

[0050] Step 3.3: Solution evaluation. After generating m offspring, these m offspring need to be evaluated. Specifically, for each individual, it represents the pruning result of a certain layer of the corresponding network. When evaluating, it is necessary to combine this layer with other layers of the network into a complete neural network to evaluate the effect of pruning this layer. Here, other layers can be directly obtained from the network to be pruned in this round of co-evolution. k Input the combined network and put it in D k The accuracy on is approximately the accuracy of this individual.

[0051] Step 3.4: Selection. At this point, the population has 2m individuals, and m individuals need to be selected as the next generation population. The selection is based on accuracy. When the accuracy is the same, the solution with smaller FLOPs, that is, the solution with smaller number of remaining convolution kernels, is retained.

[0052] Step 3.5: Determine whether the intra-group evolution cycle is terminated. The value of the intra-group evolution round number recorder of the current group is increased by 1. If the maximum number of intra-group evolution rounds has not been reached, jump to step 3.2.

[0053] Step 4: Splicing. After each group has completed the evolution within the group, the pruning results corresponding to the best individuals in the last generation of each group will be spliced ​​together as the pruning results of this round. Generally speaking, when selecting the best individual in each group, the individual with the highest accuracy is regarded as the best individual. If the accuracy of two individuals is the same, the individual with fewer remaining convolution kernels is selected.

[0054] Step 5: Retrain to restore accuracy. After the splicing is completed, the network that has completed a round of pruning after the splicing needs to be retrained to restore accuracy. The retrained network is set as the initial network to be pruned in the next round of pruning, and the network is added to the solution set A generated by the algorithm.

[0055] Step 6: Determine whether the co-evolution cycle is terminated. The value of the co-evolution round recorder t1 is increased by 1. If the preset maximum number of co-evolution rounds T1 is not reached, jump to step 2. Here, since each round of pruning process is relatively independent, the cycle can be terminated in advance after the ideal pruning rate is reached, and the pruning result at this time is output.

[0056] Step 7: Select a suitable pruning result from A according to the actual application scenario. During the operation of this method, several pruning results with different pruning ratios can be generated. Generally speaking, the accuracy of a neural network with a high pruning ratio will be lower.

[0057] Step 8: Deploy the pruning results to the terminal device, input the data to be predicted into the pruned network, and complete the prediction of the data category.

[0058] The deep neural network pruning method based on co-evolution is a deep neural network pruning method based on co-evolution for image classification. In step 8, the pruning result is deployed on the terminal device, and the image to be predicted is input into the pruned network to complete the prediction of the image category.

[0059] The training set D train It is an image dataset used to apply for network model training.

[0060] The neural network to be pruned is a neural network model obtained after training with input image data.

[0061] In the retraining and accuracy recovery step, a portion of the image data is taken as a training sample to train the spliced ​​neural network.

[0062] In the step 3.3: solution evaluation, the selected part of the training set D k Input the combined network and put it in D k The accuracy on the partial training set D is approximately the accuracy of the pruned network. kRefers to part of the image data sampled from the image dataset.

[0063] A deep convolutional neural network pruning system based on co-evolution, comprising:

[0064] Reading module: used to read the neural network to be pruned, from the training set D train Randomly select a proportion of k data from the k ;

[0065] Grouping module: grouping according to the structure of the network to be cut;

[0066] Co-evolution module: optimizes in each group using evolutionary algorithms in parallel;

[0067] Splicing module: After each group completes the internal evolution, the pruning results corresponding to the best individuals in the last generation of each group will be spliced ​​together as the pruning results of this round;

[0068] Retraining and restoring accuracy module: After the splicing is completed, the network that has completed a round of pruning after the splicing needs to be retrained, and the retrained network is set as the initial network to be pruned in the next round of pruning, and the network is added to the solution set A generated by the algorithm;

[0069] The co-evolution cycle termination judgment module: the value of the co-evolution round number recorder t1 is increased by 1; if the preset maximum number of co-evolution rounds T1 is not reached, the grouping module is notified to group the networks to be pruned, and then the co-evolution module performs optimization, and then the training recovery accuracy module performs retraining, and the retrained network is set as the initial network to be pruned in the next round of pruning, and the network is added to the solution set A generated by the algorithm, and the co-evolution cycle termination judgment module performs its function; since each round of pruning process is relatively independent, the cycle can be terminated in advance after the preset pruning rate is reached, and the pruning result at this time is output;

[0070] Selection module: select the pruning result from A to use according to the actual application scenario;

[0071] Prediction module: deploys the pruning results to the terminal device, inputs the data to be predicted into the pruned network, and completes the prediction of the data category.

[0072] The implementation process of the system is the same as the implementation process of the method, and will not be repeated here.

[0073] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the deep convolutional neural network pruning method based on collaborative evolution as described above is implemented.

[0074] A computer-readable storage medium stores a computer program for executing the deep convolutional neural network pruning method based on collaborative evolution as described above.

[0075] Beneficial effects: Compared with the prior art, the deep convolutional neural network pruning method and system based on co-evolution provided by the present invention can effectively prune the deep neural network using the idea of ​​co-evolution, so as to significantly reduce the computational overhead of the neural network without losing accuracy. Compared with the existing pruning methods, this method does not rely on expert knowledge, is easy to parallelize, and the optimization process is highly independent and scalable, and has great practical application potential.

[0076] Furthermore, the pruning results are deployed on the terminal device, and the image to be predicted is input into the pruned network to complete the prediction of the image category. When using the pruned network for image category prediction, the network parameter storage overhead and the computational overhead required for a single prediction can be significantly reduced without losing accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0077] Figure 1 is a method flow chart of an embodiment of the present invention;

[0078] Figure 2 is a flow chart of each group performing intra-group evolution in parallel in an embodiment of the present invention;

[0079] Figure 3 2 is a comparison chart of experimental effects of the embodiments of the present invention. DETAILED DESCRIPTION

[0080] The present invention is further explained below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention. After reading the present invention, various equivalent forms of modifications to the present invention by those skilled in the art all fall within the scope defined by the claims attached to this application.

[0081] A deep convolutional neural network pruning method based on co-evolution can automatically obtain a set of high-quality pruning results through operations such as grouping, evolution within the group, and merging.

[0082] Take the pruning of ResNet-50 on ILSVRC2012 as an example. ILSVRC2012 is one of the most mainstream image classification datasets, containing a total of 1,000 categories, of which the training set contains about 1.28 million images and the test set contains 100,000 images. ResNet-50 is one of the most classic network models in the field of deep learning. It contains 16 bottleneck blocks, and each bottleneck block consists of 3 convolutional layers. When pruning, we prune the first and second convolutional layers of each bottleneck block and keep the third convolutional layer unchanged to ensure that the output dimension of each bottleneck block does not change and maintain the effectiveness of the ResNet structure itself.

[0083] In this case, the pruning process proposed in this embodiment is as follows:

[0084] Step 1: Read the ResNet-50 neural network to be pruned. This network is a neural network model that has been fully trained on the ILSVRC2012 training set. Read the ILSVRC2012 training set, denoted as D train From the training set D train Randomly select data D with a proportion of k k , where k = 0.01, is used for individual evaluation of subsequent intra-group evolution.

[0085] Step 2: According to the network structure of ResNet-50, the convolution kernels to be pruned can be divided into 2x16=32 groups.

[0086] Step 3: Perform intra-group evolution in each group in parallel. It includes four sub-steps: initialization, generation of new solutions, evaluation of solutions, and natural selection. In this implementation, for intra-group evolution, the population size m is set to 5, and the maximum number of evolution rounds T2 in the group is set to 10. The maximum reduction ratio u of the convolution kernel is set to 0.15.

[0087] Step 3.1: Initialization. Encode the solution space into a 0-1 string. The length of the string of the current group is determined by the number of remaining convolution kernels of the convolution layer corresponding to the current group. Each convolution kernel corresponds to one bit of the string. The all-1 solution is first added to the population, and the remaining solutions are sampled from the all-1 solution according to the initialization probability p1. The probability of each bit having p1 flips from 1 to 0, where p1 = 0.1.

[0088] Step 3.2: Generate a new solution. This implementation uses a mutation operator with probability p2 = 0.1, that is, first randomly select the parent from the current population, and for the 0-1 string corresponding to the parent, each bit has a probability of p2 to flip to generate a child. As described in the technical solution, in order to make the pruning process smooth, at most a proportion u of convolution kernels are deleted in each evolution within the group. To ensure this rule, when the mutation operator is used to generate offspring, if the proportion of remaining convolution kernels of the offspring at the current moment is less than or equal to 1-u, the convolution kernel will not be deleted any further.

[0089] Step 3.3: Solution evaluation. After generating 5 offspring, we need to evaluate them. k Input the pruned network, and pass the pruned network in D k The accuracy on is used to approximate the accuracy of the pruned network.

[0090] Step 3.4: Natural selection. At this point, there are 10 individuals in the population, and 5 individuals need to be selected as the next generation population. The selection is based on accuracy. After sorting the 10 individuals by accuracy, the individuals with high accuracy are retained. When the accuracy is the same, the individuals with a smaller number of remaining convolution kernels are selected and retained.

[0091] Step 3.5: Loop termination judgment. The value of the intra-group evolution round number recorder of the current group is increased by 1. If the maximum number of intra-group evolution rounds has not been reached, jump to step 2.2.

[0092] Step 4: Splicing. After each group has completed the intra-group evolution, the pruning results corresponding to the best solutions in the last generation of populations in each group will be spliced ​​together as the pruning results of this round. Generally speaking, when selecting the best solution in each group, the solution with the highest accuracy is considered the best solution. If the accuracy of two solutions is the same, the solution with fewer remaining convolution kernels is selected. In this implementation, in order to speed up the pruning process, if all the convolution kernels corresponding to the solution with the highest accuracy are retained, the solution with the second highest accuracy is selected to participate in splicing and the next round of optimization.

[0093] Step 5: Retrain to restore accuracy. After the splicing is completed, the neural network corresponding to the splicing that has completed the trimming process needs to be retrained to restore accuracy. Here, during the retraining, the input data is all the training sets D train , the training algorithm is SGD, the number of retraining rounds is 60 epochs, the initial learning rate is 0.01, and the learning rate decays by a multiple of 0.1 at the 20th, 40th, and 50th epochs. The batch size is 256. The momentum is 0.9, and the weight decay is 0.0001. The retrained network is set as the initial network to be pruned in the next round of pruning, and the network is added to the solution set A generated by the algorithm.

[0094] Step 6: Loop termination judgment. The value of the coevolution round number recorder is increased by 1. If the preset maximum number of coevolution rounds is not reached, jump to step 2. The preset maximum number of coevolution rounds in this experiment is 13.

[0095] Step 7: Pruning effect test. Select several pruned networks from solution set A, input the image data of the test set into the pruned network, obtain its prediction results, and calculate the accuracy of the pruned network on the test set.

[0096] A deep convolutional neural network pruning system based on co-evolution, comprising:

[0097] Reading module: used to read the neural network to be pruned, from the training set D train Randomly select a proportion of k data from the k ;

[0098] Grouping module: grouping according to the structure of the network to be cut;

[0099] Co-evolution module: optimizes in each group using evolutionary algorithms in parallel;

[0100] Splicing module: After each group completes the internal evolution, the pruning results corresponding to the best individuals in the last generation of each group will be spliced ​​together as the pruning results of this round;

[0101] Retraining and restoring accuracy module: After the splicing is completed, the network that has completed a round of pruning after the splicing needs to be retrained, and the retrained network is set as the initial network to be pruned in the next round of pruning, and the network is added to the solution set A generated by the algorithm;

[0102] The co-evolution cycle termination judgment module: the value of the co-evolution round number recorder t1 is increased by 1; if the preset maximum number of co-evolution rounds T1 is not reached, the grouping module is notified to group the networks to be pruned, and then the co-evolution module performs optimization, and then the training recovery accuracy module performs retraining, and the retrained network is set as the initial network to be pruned in the next round of pruning, and the network is added to the solution set A generated by the algorithm, and the co-evolution cycle termination judgment module performs its function; since each round of pruning process is relatively independent, the cycle can be terminated in advance after the preset pruning rate is reached, and the pruning result at this time is output;

[0103] Selection module: select the pruning result from A to use according to the actual application scenario;

[0104] Prediction module: deploys the pruning results to the terminal device, inputs the data to be predicted into the pruned network, and completes the prediction of the data category.

[0105] The results are as follows Figure 3As shown, the line connected by the five-pointed star represents the method proposed in this embodiment, the other points represent the existing deep convolutional neural network pruning method, the horizontal axis represents the network pruning rate, and the vertical axis represents the accuracy of the pruned network. It can be seen intuitively from the figure that the method proposed in the embodiment of the present invention can maintain higher accuracy while ensuring a higher pruning rate. The detailed numerical results are shown in Table 1.

[0106]

[0107] Obviously, those skilled in the art should understand that the various steps of the deep convolutional neural network pruning method based on co-evolution or the various modules of the deep convolutional neural network pruning system based on co-evolution of the above-mentioned embodiments of the present invention can be implemented by a general-purpose computing device, which can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. Optionally, they can be implemented with program codes executable by the computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be performed in a different order from that shown here, or they can be made into individual integrated circuit modules respectively, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present invention are not limited to any specific combination of hardware and software.

Claims

1. A deep convolutional neural network pruning method based on co-evolution, characterized in that: The following steps are involved: Step 1: Read the neural network to be pruned; from the training set D train Randomly select a proportion of k data from the k ; Step 2: Group the networks to be cut according to their structure; Step 3: Use evolutionary algorithms to optimize in each group in parallel; Step 4: Splicing: After each group has completed the internal evolution, the pruning results corresponding to the best individuals in the last generation of each group will be spliced ​​together as the pruning results of this round; Step 5: Retrain to restore accuracy; after the splicing is completed, the network that has completed a round of pruning after the splicing needs to be retrained, and the retrained network is set as the initial network to be pruned in the next round of pruning, and the network is added to the solution set A generated by the algorithm; Step 6: Determine the termination of the co-evolution cycle; add 1 to the value of the co-evolution round number recorder t1; if the preset maximum number of co-evolution rounds T1 is not reached, jump to step 2; since each round of pruning process is relatively independent, the cycle can be terminated in advance after the pruning rate is reached, and the pruning result at this time is output; Step 7: Select the pruning result from A to use according to the actual application scenario; Step 8: Deploy the pruning results to the terminal device, input the data to be predicted into the pruned network, and complete the prediction of the data category; The deep neural network pruning method based on co-evolution is a deep neural network pruning method based on co-evolution for image classification. In step 8, the pruning result is deployed on the terminal device, and the image to be predicted is input into the pruned network to complete the prediction of the image category.

2. The deep convolutional neural network pruning method based on collaborative evolution according to claim 1, characterized in that: The training set D train is a picture data set used for training a neural network model; the neural network to be pruned is a neural network model obtained after training with input picture data.

3. The deep convolutional neural network pruning method based on collaborative evolution according to claim 1, characterized in that: In step 2, grouping is performed according to the structure of the network to be pruned; if the neural network contains a total of n convolutional layers to be pruned, the search space is divided into n groups by layer.

4. The deep convolutional neural network pruning method based on collaborative evolution according to claim 1, characterized in that: In step 4, after each group completes the intra-group evolution, the pruning results corresponding to the best individuals in the last generation of each group will be spliced ​​together as the pruning results of this round; when selecting the best individual in each group, the individual with the highest accuracy is regarded as the best individual; if the accuracy of two individuals is the same, the individual with fewer remaining convolution kernels is selected.

5. The deep convolutional neural network pruning method based on collaborative evolution according to claim 1, characterized in that: In the retraining and accuracy recovery step, a portion of the image data is taken as a training sample to train the spliced ​​neural network.

6. The deep convolutional neural network pruning method based on collaborative evolution according to claim 1, characterized in that: Step 3: Use the evolutionary algorithm to optimize in each group in parallel, including initialization, generation of new solutions, evaluation of solutions, and natural selection. Before executing this step, the following hyperparameters need to be given: population size m, maximum number of evolutionary rounds within the group t, and maximum reduction ratio u of the convolution kernel in each evolution within the group. The evolution process within each group is as follows: Step 3.1: Initialization; Encode the neural network layer corresponding to the current group into a 0-1 string. The length of the string depends on the number of convolution kernels it contains, and each convolution kernel corresponds to one bit of the string. The all-1 solution is first added to the population. Then, the mutation operator with a mutation rate of p1 is executed m-1 times on the all-1 solution to generate m-1 new individuals, which together with the all-1 solution constitute an initial population of size m. Among them, the operation of the mutation operator with a mutation rate of p and a maximum clipping ratio of u is as follows: Each bit of the 0-1 string has a probability of p to flip. When a bit of the 0-1 string is about to flip from 1 to 0, if the proportion of 0 in the 0-1 string is greater than u at this time, the flip of the bit is abandoned. Step 3.2: Generate a new solution; use a mutation operator with probability p2, that is, first randomly select a parent individual from the current population, and for the 0-1 string corresponding to the parent individual, each bit has a probability of p2 to flip to generate a child; in each intra-group evolution, at most a proportion of u convolution kernels are deleted. To ensure this rule, when using the mutation operator to generate children, if the proportion of the remaining convolution kernels of the children at the current moment is less than or equal to 1-u, the convolution kernel will not be deleted any more; Step 3.3: Solution evaluation: After generating m offspring, these m offspring need to be evaluated. For each individual, it represents the pruning result of a corresponding layer of the network. When evaluating, it is necessary to combine this layer with other layers of the network into a complete neural network to evaluate the effect of pruning this layer. Here, other layers can be directly obtained from the network to be pruned in this round of co-evolution. The selected part of the training set D k Input the combined network and put it in D k The accuracy on is taken as the accuracy of the individual; Step 3.4: Selection; At this time, there are 2m individuals in the population, and m individuals need to be selected as the next generation population; The selection is based on accuracy first. When the accuracy is the same, the solution with smaller FLOPs, that is, the solution with a smaller number of remaining convolution kernels, is retained; Step 3.5: Determine the termination of the intra-group evolution cycle; add 1 to the value of the intra-group evolution round number recorder of the current group; if the maximum number of intra-group evolution rounds has not been reached, jump to step 3.

2.

7. A deep convolutional neural network pruning system based on co-evolution, characterized in that: include: Reading module: used to read the neural network to be pruned, from the training set D train Randomly select a proportion of k data from the k ; Grouping module: grouping according to the structure of the network to be cut; Co-evolution module: optimizes in each group using evolutionary algorithms in parallel; Splicing module: After each group completes the internal evolution, the pruning results corresponding to the best individuals in the last generation of each group will be spliced ​​together as the pruning results of this round; Retraining and restoring accuracy module: After the splicing is completed, the network that has completed a round of pruning after the splicing needs to be retrained, and the retrained network is set as the initial network to be pruned in the next round of pruning, and the network is added to the solution set A generated by the algorithm; The co-evolution cycle termination judgment module: the value of the co-evolution round number recorder t1 is increased by 1; if the preset maximum number of co-evolution rounds T1 is not reached, the grouping module is notified to group the networks to be pruned, and then the co-evolution module performs optimization, and then the training recovery accuracy module performs retraining, and the retrained network is set as the initial network to be pruned in the next round of pruning, and the network is added to the solution set A generated by the algorithm, and the co-evolution cycle termination judgment module performs its function; since each round of pruning process is relatively independent, the cycle can be terminated in advance after the preset pruning rate is reached, and the pruning result at this time is output; Selection module: select the pruning result from A to use according to the actual application scenario; Prediction module: deploys the pruning results to the terminal device, inputs the data to be predicted into the pruned network, and completes the prediction of the data category; The deep neural network pruning method based on co-evolution is a deep neural network pruning system based on co-evolution for image classification. In the prediction module, the pruning result is deployed on the terminal device, and the image to be predicted is input into the pruned network to complete the prediction of the image category.

8. A computer device, characterized in that: The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the deep convolutional neural network pruning method based on collaborative evolution as described in any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program for executing the deep convolutional neural network pruning method based on collaborative evolution as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Product surface defect efficient model construction method based on network collaborative pruning

    CN111429415A

  • Neural network automatic pruning method based on evolutionary algorithm

    CN111507383A