Filter pruning method, system and electronic equipment
The optimal reduction rate combination of filters is optimized through the reverse search genetic algorithm, and the filter similarity is evaluated using the filter feature map average distance of multiple samples, which solves the problem of incomplete filter similarity evaluation and the problem of limited pruning rate combination space in the prior art, and realizes efficient filter pruning and neural network model optimization.
Patent Information
- Application Number
- CN202310285049.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-22
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2043-03-22
AI Technical Summary
In the prior art, the filter similarity evaluation is incomplete and the pruning rate combination space is too large, resulting in the pruning rate combination space being limited, making it impossible to obtain the optimal network model structure.
The optimum pruning rate combination of the filter is optimized by using the reverse search genetic algorithm, and the population diversity is increased by initializing the population, and the pruning rate vector with the lowest fitness value is reversed after each iteration to obtain the optimized population. At the same time, the filter similarity is evaluated using a multi-sample filter feature map average distance to avoid the influence of sample deviation.
It is realized that the filter is effectively pruned without affecting the accuracy of the neural network to obtain the true optimal pruning rate combination, avoiding the adverse effects of algorithm precocious maturity and sample deviation.
Smart Images

Figure CN116402114B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of neural network pruning, and in particular to a filter pruning method, system and electronic equipment. Background Art
[0002] The existing pruning strategy is too simplistic, ignoring the structural integrity between layers of the convolutional network model and the correlation of global network information. It uses a uniformly set pruning rate to prune each layer, which may cause some layers to be over-pruned and some layers to still have structural redundancy, making it impossible to obtain the optimal network model structure. In addition, this fixed pruning rate pruning strategy relies on manual experience and requires repeated testing to find a better overall pruning rate.
[0003] Although there are some filter pruning algorithms that consider pruning sensitivity, due to the huge space of pruning rate combinations, existing methods artificially constrain the search space and only achieve the search for pruning rate combinations within a limited space.
[0004] Deep neural network pruning is one of the important methods for compressing and accelerating deep neural networks, but existing network pruning can basically be divided into two categories: one is to evaluate the filters of each layer according to a fixed pruning rate set manually, using the filter importance or similarity evaluation method, retaining important filters according to the pruning rate, and deleting unimportant filters. In the filter importance or similarity evaluation, each sample is evaluated once, and the impact of sample bias on the evaluation is not considered. The other is to consider pruning sensitivity so that each layer has a different pruning rate. Since the combination space of pruning rates of each layer of the deep model is too large, many current methods use certain means to limit or compress the combination space of pruning rates, and use algorithms to search for the optimal pruning rate combination in a subspace.
[0005] The disadvantages of the prior art are as follows:
[0006] (1) In the current deep network model pruning strategy, the impact of sample bias on the evaluation is not considered in the filter similarity evaluation, and the filter similarity cannot be fully reflected.
[0007] (2) Since the space of pruning rate combinations for each layer of the deep model is too large, many current methods use certain means to limit or compress the space of pruning rate combinations (for example, the pruning rate value range is 0-0.5), and use algorithms to search for the optimal pruning rate combination in a subspace. Summary of the invention
[0008] Therefore, the technical problem to be solved by the present invention is to overcome the problem of incomplete filter similarity evaluation in the prior art and the problem that the existing pruning methods all limit the pruning rate combination space.
[0009] In order to solve the above technical problems, the present invention provides a filter pruning method, comprising:
[0010] Step S1: Initialize a pruning rate vector set, and use the pruning rate vector set as the current population;
[0011] Step S2: Pruning the initial neural network with reference to the pruning rate vector in the current population to obtain a pruning model; and calculating the fitness value of the pruning model corresponding to each pruning rate vector in the current population;
[0012] Step S3: Based on the fitness value of the pruning model corresponding to each pruning rate vector in the current population, the current population is selected, crossed and mutated, and the pruning rate vectors corresponding to the pruning models with the lowest fitness values in the mutated population are replaced to obtain an optimized population;
[0013] Step S4: Determine whether the optimized population meets the preset termination criteria. If so, execute step S5; if not, return to step S2 until the preset termination criteria are met.
[0014] Step S5: Select a pruning rate vector corresponding to the pruning model with the highest fitness value from the optimized population, and prune the filter in the neural network to be pruned.
[0015] In one embodiment of the present invention, the method for initializing the pruning rate vector set in step S1 is:
[0016] Random Generation pruning rate vectors, forming a subpopulation ;
[0017] According to the subpopulation generate pruning rate vectors, forming a subpopulation ;
[0018] The subpopulation and subpopulations Constructing the initial population , the initial population is the pruning rate vector A collection of .
[0019] In one embodiment of the present invention, the subpopulation and subpopulations Satisfy the formula:
[0020]
[0021] in, Represents subpopulation Individuals in The corresponding filter pruning rate vector, Indicates about The neural network The filter pruning rate of the layer and , , represents the number of convolutional layers in the neural network, Represents subpopulation Individuals in The corresponding filter pruning rate vector, Indicates about The neural network Filter pruning rate of the layer.
[0022] In one embodiment of the present invention, the calculation formula of the fitness value is:
[0023]
[0024] in, represents the fitness value, represents the classification accuracy of the pruned model, and They represent the computational amount Flops and parameter amount Params of the unpruned neural network respectively. and They represent the computational amount Flops and parameter amount Params retained by the neural network after pruning according to the pruning rate vector, Indicates dynamically adjustable first parameter, second parameter and third parameter.
[0025] In one embodiment of the present invention, the step S3 replaces the pruning rate vectors corresponding to the several pruning models with the lowest fitness values in the mutated population to obtain the optimized population by:
[0026] Select the pruning rate vectors corresponding to the two pruning models with the lowest fitness values in the mutated population, subtract the pruning rates in the pruning rate vectors corresponding to the two pruning models with the lowest fitness values from 100% to obtain two sets of reverse pruning rates, and generate two corresponding reverse pruning rate vectors based on the two sets of reverse pruning rates;
[0027] The two reverse pruning rate vectors are used to replace the pruning rate vectors corresponding to the two pruning models with the lowest fitness values to obtain the optimized population.
[0028] In one embodiment of the present invention, the method of pruning the initial neural network with reference to the pruning rate vector in the current population in step S2 includes: evaluating the similarity of filters by the average distance of feature maps, and deleting filters based on the similarity of the filters;
[0029] The formula for the average distance of the feature map is:
[0030]
[0031] in, By The first The image generated feature map, By The first The image generated feature map, represents the number of image samples, Indicates converting the feature map matrix into a vector. Represents the dimension after the feature map matrix is converted to a vector, and Respectively represent the network The first The image generated The feature map and The feature map vector after the feature map conversion.
[0032] In one embodiment of the present invention, the pruning model in step S2 satisfies the formula:
[0033]
[0034] in, represents the pruning model, represents the filter pruning rate vector, Represents the neural network The filter pruning rate of the layer, , represents the number of convolutional layers of the neural network, represents the weight parameters of the neural network, Represents the test loss value of the pruned neural network, Represents the training loss value of the pruned neural network.
[0035] In order to solve the above technical problems, the present invention provides a filter pruning system, comprising:
[0036] Initialization module: used to initialize the pruning rate vector set, and use the pruning rate vector set as the current population;
[0037] A calculation module: used to prune the initial neural network with reference to the pruning rate vector in the current population to obtain a pruning model; and calculate the fitness value of the pruning model corresponding to each pruning rate vector in the current population;
[0038] Population optimization module: used to select, crossover and mutate the current population based on the fitness value of the pruning model corresponding to each pruning rate vector in the current population, and replace the pruning rate vectors corresponding to several pruning models with the lowest fitness values in the mutated population to obtain an optimized population;
[0039] The judgment module is used to judge whether the optimized population meets the preset termination criteria. If so, the execution process of the selection module is executed; if not, the execution process of the calculation module is returned until the preset termination criteria are met.
[0040] Pruning module: used to select the pruning rate vector corresponding to the pruning model with the highest fitness value from the optimized population, and prune the filter in the neural network to be pruned.
[0041] To solve the above technical problems, the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above filter pruning method when executing the computer program.
[0042] In order to solve the above technical problem, the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the filter pruning method as described above are implemented.
[0043] The above technical solution of the present invention has the following advantages compared with the prior art:
[0044] The present invention performs a "reverse operation" during the population initialization process; after each iteration of the genetic algorithm, the present invention performs a "reverse operation" on a number of pruning rate vectors with the lowest fitness values in the population to obtain an optimized population. The reverse operation increases population diversity and can avoid premature algorithm maturation to a certain extent.
[0045] The present invention uses a reverse search genetic algorithm to optimize the optimal pruning rate combination problem of the filter. In the optimization process, no restriction is imposed on the pruning rate combination space (i.e., the pruning rate value range of the present invention is set to , without restrictions), so as to obtain the truly optimal pruning rate combination;
[0046] In the filter pruning strategy, the present invention uses the average distance of filter feature graphs of multiple samples to evaluate the similarity of filters in the filter similarity evaluation, thereby effectively avoiding the adverse effects of sample deviation on filter similarity;
[0047] The present invention can effectively prune the filter without affecting the accuracy of the neural network. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to make the contents of the present invention more clearly understood, the present invention is further described in detail below based on specific embodiments of the present invention in conjunction with the accompanying drawings.
[0049] Figure 1 is a flow chart of the method of the present invention;
[0050] Figure 2 is a schematic diagram of a genetic algorithm crossover operation in an embodiment of the present invention;
[0051] Figure 3 Schematic diagram of genetic algorithm mutation operation in an embodiment of the present invention. DETAILED DESCRIPTION
[0052] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0053] Embodiment 1
[0054] Reference Figure 1 As shown, the present invention provides a filter pruning method, comprising:
[0055] Step S1: Initialize a pruning rate vector set, and use the pruning rate vector set as the current population. Each pruning rate vector in the pruning rate vector set is equivalent to an individual in the population, and each element in each pruning rate vector (i.e., individual) is the pruning rate;
[0056] Step S2: Pruning the initial neural network with reference to the pruning rate vector in the current population to obtain a pruning model; and calculating the fitness value of the pruning model corresponding to each pruning rate vector in the current population;
[0057] Step S3: Based on the fitness value of the pruning model corresponding to each pruning rate vector in the current population, the current population is selected, crossed and mutated, and the pruning rate vectors corresponding to the pruning models with the lowest fitness values in the mutated population are replaced to obtain an optimized population;
[0058] Step S4: Determine whether the optimized population meets the preset termination criteria. If so, execute step S5; if not, return to step S2 until the preset termination criteria are met; wherein, determining whether the optimized population meets the preset termination criteria includes: determining whether the number of iterations corresponding to the optimized population reaches the preset number of iterations, or using the pruning rate vector corresponding to the pruning model with the highest fitness value in the optimized population to prune the neural network, and determining whether the detection accuracy of the pruned neural network reaches the preset accuracy;
[0059] Step S5: Select a pruning rate vector corresponding to the pruning model with the highest fitness value from the optimized population, and prune the filter in the neural network to be pruned.
[0060] The present invention improves the genetic algorithm by performing a "reverse operation" during the population initialization process, and after each iteration of the genetic algorithm, optimizing the pruning rate vectors with the lowest fitness value in the population (i.e., "reverse operation") to obtain an optimized population. The reverse operation increases population diversity and can avoid the "premature maturity" of the genetic algorithm to a certain extent. The present invention also uses a reverse search genetic algorithm to optimize the optimal pruning rate combination problem of the filter. During the optimization process, no restriction is imposed on the pruning rate combination space (i.e., the pruning rate value range of the present invention is set to , without restrictions), so as to obtain the truly optimal pruning rate combination.
[0061] The following is a detailed introduction to this embodiment:
[0062] Problem description: Given a convolutional neural network, assuming that each layer of the network has c channels, this embodiment describes the channel pruning (i.e., filter pruning) problem as follows:
[0063]
[0064] in, represents the pruning model, represents the filter pruning rate vector, Represents the neural network The filter pruning rate of the layer, , represents the number of convolutional layers of the neural network, represents the weight parameters of the neural network, Represents the test loss value of the pruned neural network, Represents the training loss value of the pruned neural network. This embodiment aims to search for the training loss from the original network model. Minimal Pruning Model ,After determining the pruning rate of each layer of filters, the sub-network test error is minimized by fine-tuning.
[0065] Furthermore, the method for initializing the pruning rate vector set in step S1 is:
[0066] Assume the population size is , first randomly generate pruning rate vectors (individuals), forming a subpopulation ; Then for the subpopulation of The individuals are reversed and regenerated pruning rate vectors (individuals), forming a subpopulation ; Subpopulation and subpopulations Constructing the initial population , the initial population is the pruning rate vector The reverse operation in step S1 can be understood as: subtracting the subpopulation from 100% The pruning rate corresponding to the pruning rate vector in the pruning rate vector is used to obtain the corresponding subpopulation The pruning rate corresponding to the pruning rate vector in .
[0067] Furthermore, in this embodiment, the subpopulation and subpopulations Satisfies the following formula:
[0068]
[0069] in, Represents subpopulation Individuals in The corresponding filter pruning rate vector, Indicates about The neural network The filter pruning rate of the layer and , , represents the number of convolutional layers in the neural network, Represents subpopulation Individuals in The corresponding filter pruning rate vector, Indicates about The neural network The filter pruning rate of the layer. It is not difficult to find the formula It reflects the principle of reverse operation.
[0070] Furthermore, in the design of the fitness function of the genetic algorithm, this embodiment adopts the model classification accuracy while introducing the model compression rate, aiming to achieve a balance between the compression rate and the classification accuracy. Specifically, the fitness calculation is defined as follows:
[0071]
[0072] in, represents the fitness value, Indicates the classification accuracy of the current pruned model, and They represent the computational amount Flops and parameter amount Params of the unpruned neural network respectively. and They represent the computational amount Flops and parameter amount Params retained by the neural network after pruning according to the pruning rate vector, Indicates dynamically adjustable first parameter, second parameter and third parameter.
[0073] Furthermore, the selection, crossover and mutation operations in the genetic algorithm used in this embodiment, the crossover operation can be found in Figure 2 First, two crossover points are randomly selected for two individuals according to a certain crossover probability ( Figure 2 a and b in the crossover point), and then exchange the genes of the two individuals between the crossover points ( Figure 2 Swap 0.53, 0.62, 0.10 with 0.80, 0.23, 0.31) to generate two new individuals. For mutation operation, please refer to Figure 3 , mutate two individuals randomly.
[0074] It is worth mentioning that at the end of each iteration (selection, crossover and mutation), in step S3 of this embodiment, several pruning rate vectors with the lowest fitness values in the mutated population are replaced (i.e., several pruning rate vectors with the lowest fitness values are reversed and then replaced) to obtain an optimized population. The reverse operation method is as follows:
[0075] Select the two pruning rate vectors with the lowest fitness values in the mutated population (i.e., the two worst individuals), and obtain two sets of reverse pruning rates by subtracting the pruning rates corresponding to the two pruning rate vectors with the lowest fitness values from 100%, and generate two corresponding reverse pruning rate vectors based on the two sets of reverse pruning rates (i.e., generate two better individuals);
[0076] The two pruning rate vectors with the lowest fitness values are replaced by two reverse pruning rate vectors to obtain the optimized population.
[0077] For example, suppose the two pruning rate vectors with the lowest fitness values in the mutated population are and , then after the reverse operation we get and .
[0078] Optimization target evaluation definition: This embodiment uses the Euclidean distance to measure the average similarity between c feature maps. In the evaluation of the pruning model, the filter to be retained is selected by calculating the evaluation similarity of the feature maps. Layer, this embodiment calculates the similarity matrix for all output feature maps, and deletes the filter corresponding to the feature map with the highest similarity according to the filter pruning rate in the current layer structure vector. The similarity is calculated as follows:
[0079]
[0080] in, By The first The image generated feature map, By The first The image generated feature map, represents the number of image samples, Indicates converting the feature map matrix into a vector. Represents the dimension after the feature map matrix is converted to a vector, and Respectively represent the network The first The image generated The feature map and The feature map vector after the feature map is converted. Since different input images have different features, in order to obtain more accurate similarity, this embodiment will The feature maps generated by the samples are superimposed and averaged at the same position to reduce sample bias. The smaller the value of, the higher the similarity between the two feature maps.
[0081] The experimental results are as follows:
[0082] This embodiment uses multiple models (Resnet56 / Resnet110 / VGG16) to test on multiple data sets (CIFAR-10 / CIFAR-100 / ILSVRC-2012). Please refer to Table 1, Table 2 and Table 3 for details. The test results show that the method of this embodiment is effective.
[0083] Table 1 Results of different convolutional network models on CIFAR-10
[0084]
[0085] Table 2 Results of different convolutional network models on CIFAR-100
[0086]
[0087] Table 3 Results and comparison of different convolutional network models in ILSVRC-2012
[0088]
[0089] Embodiment 2
[0090] This embodiment provides a filter pruning system, including:
[0091] Initialization module: used to initialize the pruning rate vector set, and use the pruning rate vector set as the current population;
[0092] A calculation module: used to prune the initial neural network with reference to the pruning rate vector in the current population to obtain a pruning model; and calculate the fitness value of the pruning model corresponding to each pruning rate vector in the current population;
[0093] Population optimization module: used to select, crossover and mutate the current population based on the fitness value of the pruning model corresponding to each pruning rate vector in the current population, and replace the pruning rate vectors corresponding to several pruning models with the lowest fitness values in the mutated population to obtain an optimized population;
[0094] The judgment module is used to judge whether the optimized population meets the preset termination criteria. If so, the execution process of the selection module is executed; if not, the execution process of the calculation module is returned until the preset termination criteria are met.
[0095] Pruning module: used to select the pruning rate vector corresponding to the pruning model with the highest fitness value from the optimized population, and prune the filter in the neural network to be pruned.
[0096] Embodiment 3
[0097] This embodiment provides an electronic device, including 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 steps of the filter pruning method described in Embodiment 1 are implemented.
[0098] Embodiment 4
[0099] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the filter pruning method described in the first embodiment are implemented.
[0100] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The schemes in the embodiments of the present application may be implemented in various computer languages, for example, object-oriented programming language Java and literal scripting language JavaScript, etc.
[0101] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0102] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0103] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0104] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0105] Obviously, the above embodiments are merely examples for clear explanation and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived from these are still within the protection scope of the invention.
Claims
1. A filter pruning method, characterized in that: include: Step S1: Initialize a pruning rate vector set, and use the pruning rate vector set as the current population; Step S2: Pruning the initial neural network with reference to the pruning rate vector in the current population to obtain a pruning model; and calculating the fitness value of the pruning model corresponding to each pruning rate vector in the current population; The method of pruning the initial neural network with reference to the pruning rate vector in the current population in step S2 includes: evaluating the similarity of filters by the average distance of feature graphs, and deleting filters based on the similarity of the filters; The formula for the average distance of the feature map is: ; in, By The first The image generated feature map, By The first The image generated feature map, represents the number of image samples, Indicates converting the feature map matrix into a vector. Represents the dimension after the feature map matrix is converted to a vector, and Respectively represent the network The first The image generated The feature map and The feature map vector after the feature map conversion; Step S3: Based on the fitness value of the pruning model corresponding to each pruning rate vector in the current population, the current population is selected, crossed and mutated, and the pruning rate vectors corresponding to the pruning models with the lowest fitness values in the mutated population are replaced to obtain an optimized population; The calculation formula of the fitness value is: ; in, represents the fitness value, represents the classification accuracy of the pruned model, and They represent the computational amount Flops and parameter amount Params of the unpruned neural network respectively. and They represent the computational amount Flops and parameter amount Params retained by the neural network after pruning according to the pruning rate vector, represents a dynamically adjustable first parameter, a second parameter, and a third parameter; In step S3, the pruning rate vectors corresponding to the pruning models with the lowest fitness values in the mutated population are replaced to obtain the optimized population: Select the pruning rate vectors corresponding to the two pruning models with the lowest fitness values in the mutated population, subtract the pruning rates in the pruning rate vectors corresponding to the two pruning models with the lowest fitness values from 100% to obtain two sets of reverse pruning rates, and generate two corresponding reverse pruning rate vectors based on the two sets of reverse pruning rates; The two reverse pruning rate vectors are used to replace the pruning rate vectors corresponding to the two pruning models with the lowest fitness values to obtain the optimized population; Step S4: Determine whether the optimized population meets the preset termination criteria. If so, execute step S5; if not, return to step S2 until the preset termination criteria are met. Step S5: Select a pruning rate vector corresponding to the pruning model with the highest fitness value from the optimized population, and prune the filter in the neural network to be pruned.
2. The filter pruning method according to claim 1, characterized in that: The method for initializing the pruning rate vector set in step S1 is: Random Generation pruning rate vectors, forming a subpopulation ; According to the subpopulation generate pruning rate vectors, forming a subpopulation ; The subpopulation and subpopulations Constructing the initial population , the initial population is the pruning rate vector A collection of .
3. The filter pruning method according to claim 2, characterized in that: The subpopulation and subpopulations Satisfy the formula: ; in, Represents subpopulation Individuals in The corresponding filter pruning rate vector, Indicates about The neural network The filter pruning rate of the layer and , , represents the number of convolutional layers in the neural network, Represents subpopulation Individuals in The corresponding filter pruning rate vector, Indicates about The neural network Filter pruning rate of the layer.
4. The filter pruning method according to claim 1, characterized in that: The pruning model in step S2 satisfies the formula: ; in, represents the pruning model, represents the filter pruning rate vector, Represents the neural network The filter pruning rate of the layer, , represents the number of convolutional layers of the neural network, represents the weight parameters of the neural network, Represents the test loss value of the pruned neural network, Represents the training loss value of the pruned neural network.
5. A filter pruning system, characterized in that: include: Initialization module: used to initialize the pruning rate vector set, and use the pruning rate vector set as the current population; A calculation module: used to prune the initial neural network with reference to the pruning rate vector in the current population to obtain a pruning model; and calculate the fitness value of the pruning model corresponding to each pruning rate vector in the current population; The process of pruning the initial neural network with reference to the pruning rate vector in the current population in the calculation module includes: evaluating the similarity of filters by the average distance of feature maps, and deleting filters based on the similarity of the filters; The formula for the average distance of the feature map is: ; in, By The first The image generated feature map, By The first The image generated feature map, represents the number of image samples, Indicates converting the feature map matrix into a vector. Represents the dimension after the feature map matrix is converted to a vector, and Respectively represent the network The first The image generated The feature map and The feature map vector after the feature map conversion; Population optimization module: used to select, crossover and mutate the current population based on the fitness value of the pruning model corresponding to each pruning rate vector in the current population, and replace the pruning rate vectors corresponding to several pruning models with the lowest fitness values in the mutated population to obtain an optimized population; The calculation formula of the fitness value is: ; in, represents the fitness value, represents the classification accuracy of the pruned model, and They represent the computational amount Flops and parameter amount Params of the unpruned neural network respectively. and They represent the computational amount Flops and parameter amount Params retained by the neural network after pruning according to the pruning rate vector, represents a dynamically adjustable first parameter, a second parameter, and a third parameter; The population optimization module replaces the pruning rate vectors corresponding to several pruning models with the lowest fitness values in the mutated population to obtain the optimized population in the following manner: Select the pruning rate vectors corresponding to the two pruning models with the lowest fitness values in the mutated population, subtract the pruning rates in the pruning rate vectors corresponding to the two pruning models with the lowest fitness values from 100% to obtain two sets of reverse pruning rates, and generate two corresponding reverse pruning rate vectors based on the two sets of reverse pruning rates; The two reverse pruning rate vectors are used to replace the pruning rate vectors corresponding to the two pruning models with the lowest fitness values to obtain the optimized population; The judgment module is used to judge whether the optimized population meets the preset termination criteria. If so, the execution process of the selection module is executed; if not, the execution process of the calculation module is returned until the preset termination criteria are met. Pruning module: used to select the pruning rate vector corresponding to the pruning model with the highest fitness value from the optimized population, and prune the filter in the neural network to be pruned.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the filter pruning method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the filter pruning method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Remote sensing image target detection method based on deep evolution pruning convolutional network
CN110532859A
Method and system for constructing light image classification network based on FPCC-GAN
CN112733925A