A method for selecting a convolutional neural network feature map based on a genetic algorithm
By optimizing the feature map selection of convolutional neural networks using a genetic algorithm, the problems of high computational complexity, high redundancy, and unclear selection criteria are solved, thereby improving the model's recognition speed and generalization ability, and providing clear selection criteria and high interpretability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUIZHOU INST OF TECH
- Filing Date
- 2023-06-30
- Publication Date
- 2026-05-15
AI Technical Summary
Existing technologies for selecting feature maps in convolutional neural networks suffer from problems such as high computational complexity, high redundancy, unclear selection criteria, poor interpretability, and insufficient model generalization ability.
A genetic algorithm-based approach is adopted, which traverses the population through binary encoded data to select and evaluate feature maps. By leveraging global search and parallel computing capabilities, combined with crossover and mutation operations, the feature map combination is optimized, redundancy is reduced, and model performance and speed are improved.
It improves the accuracy and interpretability of feature map selection, reduces computational cost, enhances model recognition speed and generalization ability, provides clear selection criteria, and improves model reliability and applicability.
Abstract
Description
Technical Field
[0001] This invention relates to the field of genetic algorithm technology, and in particular to a method for selecting feature maps of convolutional neural networks based on genetic algorithms. Background Technology
[0002] The concept of Convolutional Neural Networks (CNN) search has existed for a long time. In 1989, Miller et al. proposed the neuroevolution method to evolve the weights of artificial neural networks, which has had a profound impact on the current CNN search method and has received widespread attention from academia and industry. Neural network architecture search samples a CNN structure in the search space through a search strategy, then evaluates the model performance using a specific performance evaluation strategy, and then feeds the evaluated value back to the search strategy.
[0003] 1) Feature maps in convolutional neural networks typically have high dimensionality; for example, in image recognition tasks, feature maps may have dozens or even hundreds of channels. This results in high computational complexity and slow speed when processing feature maps in the model.
[0004] 2) In convolutional neural networks, feature maps of different channels may have high redundancy, meaning they may contain similar information, which affects model performance.
[0005] 3) The importance of feature maps is uneven. Feature maps from different channels may have different importance in the model. Some feature maps contribute significantly to model performance, while others contribute less. Therefore, how to select feature maps based on their respective contributions becomes a problem that needs to be solved.
[0006] These factors make selecting the optimal feature map in a convolutional neural network complex and difficult, thus necessitating the design of a genetic algorithm-based method to address this issue.
[0007] Existing technologies mainly employ the following two methods to address the problem of feature map selection in convolutional neural networks:
[0008] 1) Human experience-based method: Manually select feature maps based on professional knowledge and experience; for example, designers can select feature maps with high discriminative power and robustness based on the characteristics of the feature maps, such as the number of channels, position, and size; this method is simple and easy to implement, but it relies on human experience and may overlook some important feature maps.
[0009] 2) Automated selection method: The model is optimized by evaluating and selecting feature maps using automated algorithms or techniques. For example, methods based on sparsity, importance evaluation, gradient information, etc. can be used to select feature maps. This method has a certain degree of automation, but may be limited by the selection of evaluation criteria and methods for feature maps, and may have problems such as selection bias and overfitting.
[0010] However, existing technologies still have some shortcomings, including but not limited to the following:
[0011] 1) Unclear selection criteria: In the process of feature map selection, the evaluation and selection criteria may be unclear or difficult to determine, which may result in the selected feature map not being optimal;
[0012] 2) Poor interpretability: Some methods lack interpretability in the feature map selection process, making it difficult to understand and explain the contribution and role of the selected feature maps to the model performance, thus limiting the reliability and applicability of the method;
[0013] 3) Insufficient model generalization ability: The selection of feature maps may lead to high redundancy between feature maps, thereby reducing the model's generalization ability and potentially resulting in poor prediction performance for unknown data.
[0014] Therefore, existing technologies still have some shortcomings in solving the problem of feature map selection in convolutional neural networks, and further improvement and optimization are needed. The method of this invention aims to solve these shortcomings and provide a more efficient, accurate and interpretable method for feature map selection in convolutional neural networks. Summary of the Invention
[0015] The purpose of this invention is to at least solve one of the technical problems existing in the prior art, and to provide a method for selecting feature maps of convolutional neural networks based on genetic algorithms, so as to solve the problems mentioned in the background art.
[0016] To achieve the above objectives, this invention provides the following technical solution: Taking classification networks as the research object, the operation steps of other types of networks (such as segmentation networks, regression networks, object detection networks, etc.) are similar; for an N (N>2) layer classification network, the first N-1 layers are convolutional layers used for feature extraction, and the Nth layer (i.e., the last layer) is a fully connected layer used to output the classification result; each convolutional layer includes multiple feature maps (usually 64, 128, 512, 1024), each feature map being a feature description of the classified object. The purpose of this invention is to reduce the number of feature maps as much as possible without reducing accuracy, thereby reducing computational load and improving classification speed; each convolutional layer may also include operations such as pooling, non-linear activation, and attention extraction. Since these operations do not affect the selection of feature maps, they are not discussed here.
[0017] For a well-designed classification network, it is first trained on a given classification dataset, which is divided into two parts: a training set and a test set. The network is trained according to the conventional training method. When the accuracy on the test set no longer increases for 5 consecutive times, the training can be stopped and the trained model parameters are saved, thus obtaining a trained network srcNet.
[0018] After the classification network srcNet is trained, feature map selection can be performed. First, a new network gaNet is defined, and the structure of srcNet is copied to gaNet. Then, starting from the first convolutional layer of the gaNet network, the parameters of the convolutional layer are modified. The parameter of the number of output feature maps is set to the variable ga_num. The parameter of the number of input feature maps of the second convolutional layer is also reset to the variable ga_num. The other parameters of the network remain unchanged.
[0019] In the initialization step of the genetic algorithm, a random set of initial binary codes, i.e., multiple strings of numbers consisting of 0s and 1s, is generated as the genetic algorithm's population. Each row of binary data in the population represents an individual. The number of binary numbers in each individual is the value of the parameter "number of output feature maps in the first convolutional layer of the original network srcNet," where 0 represents not selecting that feature map and 1 represents selecting it. The number of individuals in the population is set by the user. A larger value usually results in fewer feature maps being selected, thus improving the final classification and recognition speed, but also increasing the selection time. Generally, it is set to 30 or 50.
[0020] For each individual in the population, the binary data BD corresponding to the individual is passed into the gaNet network. Then, the number of 1s in the binary encoded data BD is counted, and the value of the count is assigned to the variable ga_num in step (3).
[0021] The binary encoded data BD is traversed. First, the first number with a value of 1 is found. Let's say the index of this number is i. This indicates that the i-th feature map of the first convolutional layer in the srcNet network has been selected. Then, the parameters of this feature map are copied to the first feature map of the first convolutional layer in the gaNet network. Next, the second number with a value of 1 is found. Let's say the index of this number is j. This indicates that the j-th feature map of the first convolutional layer in the srcNet network has been selected. Then, the parameters of this feature map are copied to the second feature map of the first convolutional layer in the gaNet network. This process is repeated until the initialization of the first convolutional layer in the gaNet network is complete.
[0022] For the second convolutional layer in the gaNet network, a normal distribution initialization method is used;
[0023] For the remaining convolutional layers and the last fully connected layer in the gaNet network, their initialization parameters are copied from the srcNet network;
[0024] For the gaNet network that has been initialized, train it using the conventional training method. If the accuracy on the test set does not increase for 5 consecutive times, stop the training and record the best accuracy value of the training as the fitness value of the corresponding individual in S5.
[0025] For the second convolutional layer in the gaNet network, since the input parameters have been changed, its initial values cannot be copied from the srcNet network, so a normal distribution initialization method is used.
[0026] The initialization parameters for the remaining convolutional layers and the last fully connected layer in the gaNet network are copied from the srcNet network.
[0027] For the gaNet network that has been initialized, train it using the conventional training method. If the accuracy on the test set does not increase for 5 consecutive times, stop the training and record the best accuracy value of the training as the fitness value of the corresponding individual in the above steps.
[0028] For each individual in the population, repeat the above steps to obtain the fitness value for each individual in the population.
[0029] For the fitness values of all individuals in the population, standardize them so that the sum of the fitness values equals 1; then generate a random number r, which takes the value between 0 and 1; traverse each individual in the population and accumulate the sum of the fitness values until the accumulated value is greater than r; stop traversing and select the individual whose accumulated value is greater than r as the parent.
[0030] Generate crossover offspring: By performing a crossover operation on the binary encoded data (i.e., genes) of two parents, two new offspring individuals are generated; this invention patent adopts a uniform crossover method, that is, for each gene, it is selected to inherit from one parent with a certain probability, and to inherit from the other parent with the same probability, thus generating two offspring.
[0031] Mutation operation: Mutation operation is performed on the generated offspring individuals to introduce randomness and increase the diversity of the population; mutation operation can generate individuals with new characteristics by randomly transforming certain genes on the chromosome, such as flipping, replacing, or inserting them.
[0032] For each newly generated individual, repeat the above steps to obtain the fitness value for each newly generated individual.
[0033] Population Update: Offspring individuals generated through selection, crossover, and mutation operations are merged with individuals in the current population to form a new generation of population; here, based on the population size setting, individuals with higher fitness are selected and retained to maintain the elitism of the population.
[0034] Repeat the above steps. When an individual in the population has a fitness value greater than the precision value of the original classification network srcNet, and the number of 0s in the binary code of that individual meets the user's requirements, that is, the number of discarded feature maps meets the user's requirements, the iteration can be stopped. The gaNet network corresponding to that individual is the network after feature map selection from the first convolutional layer of the original classification network srcNet.
[0035] Using the gaNet network obtained in the above steps as the initial network srcNet, repeat the corresponding steps until feature maps of all convolutional layers are selected. The resulting network is the final network.
[0036] Compared with the prior art, the beneficial effects of the present invention are:
[0037] (1) The convolutional neural network feature map selection method based on genetic algorithm traverses the binary encoded data BD. The number of individuals in the population is set by the user. The larger the value, the fewer feature maps are selected in the end, which can improve the final classification and recognition speed. Each individual in the population is traversed, and the sum of fitness values is accumulated until the accumulated value is greater than r. The traversal stops, and the individual with the accumulated value greater than r is selected as the parent. The computation is simplified when processing feature maps in the model, and the computation speed and efficiency are improved. The redundancy of feature maps in different channels is reduced, and the similar information that may be contained in them is extracted to improve the model performance.
[0038] (2) The convolutional neural network feature map selection method based on genetic algorithm can stop iterating when the fitness value of an individual in the population is greater than the accuracy value of the original classification network srcNet, and the number of 0s in the binary code of the individual meets the user's requirements, that is, when the number of discarded feature maps meets the user's requirements. The advantages of genetic algorithm, namely the ability of global search and parallel computing, can be used to evaluate and select different feature maps. According to the setting of population size, individuals with higher fitness are selected to be retained, thereby maintaining the elitism of the population, which makes it easier to select the optimal combination of feature maps and improve the speed and accuracy of the model. At the same time, genetic algorithm can also consider the importance of different feature maps, thereby making trade-offs when selecting feature maps, reducing the redundancy between feature maps and improving the generalization ability of the model.
[0039] (3) The convolutional neural network feature map selection method based on genetic algorithm uses binary data in each row of the population as individuals in the population. The number of binary numbers of each individual is the value of the parameter of the number of output feature maps of the first convolutional layer in the original network srcNet. 0 means not selecting the feature map and 1 means selecting the feature map. The selection criteria are clear. In the feature map selection process, the evaluation and selection criteria are clear, which facilitates selection and helps to improve the accuracy of selecting the optimal feature map. The method has high interpretability in the feature map selection process, which helps to understand and explain the contribution and role of the selected feature map to the model performance, and expands and improves the reliability and applicability of the method. Detailed Implementation
[0040] This section will describe specific embodiments of the present invention in detail, but it should not be construed as limiting the scope of protection of the present invention.
[0041] This invention provides a technical solution: a method for selecting feature maps in convolutional neural networks based on genetic algorithms. The selection method uses classification networks as the research object; the operation steps for other types of networks (such as segmentation networks, regression networks, object detection networks, etc.) are similar. For a classification network with N (N>2) layers, the first N-1 layers are convolutional layers for feature extraction, and the Nth layer (the last layer) is a fully connected layer for outputting the classification result. Each convolutional layer includes multiple feature maps. The selection method specifically includes the following steps: For a designed classification network, it is first trained on a given classification dataset, which is divided into two parts: a training set and a test set. Training is performed using conventional methods. Training stops when the accuracy on the test set no longer increases after 5 consecutive iterations, and the trained model parameters are saved, resulting in a trained network, srcNet. Each convolutional layer may also include operations such as pooling, non-linear activation, and attention extraction. After the classification network srcNet is trained, feature map selection can be performed. The selection process begins by defining a new network, gaNet, and copying the structure of srcNet to gaNet. Starting with the first convolutional layer of gaNet, the parameters of this layer are modified. The number of output feature maps is set to the variable ga_num, and the number of input feature maps for the second convolutional layer is also reset to ga_num, while other network parameters remain unchanged. A random initial binary encoding, consisting of multiple strings of 0s and 1s, is generated as the population for the genetic algorithm. Each row of binary data in the population represents an individual, and the number of binary numbers for each individual is equal to the number of output feature maps in the first convolutional layer of the original srcNet network (0 represents not selecting the feature map, and 1 represents selecting it). For each individual in the population, the corresponding binary data BD is input into the gaNet network. The number of 1s in the binary encoding data BD is then counted, and this count is assigned to the variable ga_num in S3.
[0042] Furthermore, the binary encoded data BD is traversed. First, the first number with a value of 1 is found. Let's assume this number corresponds to index i, indicating that the i-th feature map of the first convolutional layer in the srcNet network has been selected. The parameters of this feature map are then copied to the first feature map of the first convolutional layer in the gaNet network. Next, the second number with a value of 1 is found. Let's assume this number corresponds to index j, indicating that the j-th feature map of the first convolutional layer in the srcNet network has been selected. The parameters of this feature map are then copied to the second feature map of the first convolutional layer in the gaNet network. This process is repeated until the initialization of the first convolutional layer in the gaNet network is complete. For the second convolutional layer in the gaNet network, a normal distribution initialization method is used. For the remaining convolutional layers and the last fully connected layer in the gaNet network, their initialization parameters are copied from the srcNet network. The initialized gaNet network is then trained using conventional training methods. Training stops when the accuracy on the test set does not increase for five consecutive iterations. The training process involves recording the best accuracy value from each training iteration, which is then used as the fitness value for the corresponding individual in S5. A random initial binary code, consisting of multiple strings of 0s and 1s, is generated to form the population for the genetic algorithm. Each row of binary data in the population represents an individual, and the number of binary numbers for each individual is the value of the parameter representing the number of output feature maps from the first convolutional layer of the original srcNet network. 0 represents not selecting the feature map, and 1 represents selecting it. For the second convolutional layer in the gaNet network, since the input parameters have changed, its initialization value cannot be copied from the srcNet network, so a normal distribution initialization method is used. For the remaining convolutional layers and the last fully connected layer in the gaNet network, their initialization parameters are copied from the srcNet network. The initialized gaNet network is then trained using conventional methods. When the accuracy on the test set does not increase for five consecutive iterations, the training is stopped, and the best accuracy value from this iteration is recorded as the fitness value for the corresponding individual in S5.
[0043] Furthermore, for each individual in the population, the above steps are repeated to obtain the fitness value corresponding to each individual. The fitness values of all individuals in the population are standardized so that the sum of the fitness values equals 1. Then, a random number r is generated, ranging from 0 to 1. Each individual in the population is traversed, and the sum of the fitness values is accumulated until the accumulated value is greater than r. The traversal stops, and the individual with the accumulated value greater than r is selected as the parent. Crossover offspring are generated: by performing a crossover operation on the binary encoded data (i.e., genes) of the two parents, two new offspring individuals are generated. Mutation operation: a mutation operation is performed on the generated offspring individuals to introduce randomness and increase the diversity of the population. The mutation operation can randomly transform certain genes on the chromosome to generate individuals with new characteristics. For the newly generated individuals… Repeat the above steps to obtain the fitness value for each newly generated individual; update the population: merge the offspring individuals generated through selection, crossover, and mutation operations with the individuals in the current population to form a new generation of population; repeat the mutation operation and population update steps, and stop iterating when the fitness value of an individual in the population is greater than the precision value of the original classification network srcNet, and the number of 0s in the binary code of that individual meets the user's requirements, that is, the number of discarded feature maps meets the user's requirements; the gaNet network corresponding to that individual is the network after feature map selection of the first convolutional layer of the original classification network srcNet; the obtained gaNet network is used as the initial network srcNet, and the above steps are repeated until feature maps are selected from all convolutional layers, and the resulting network is the final network.
[0044] The embodiments of the present invention have been described in detail above. However, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of the present invention.
Claims
1. A method for selecting feature maps of convolutional neural networks based on genetic algorithms, characterized in that: The selection method takes classification networks as the research object. For a classification network with N>2 layers, the first N-1 layers are convolutional layers for feature extraction, and the Nth layer, which is the last layer, is a fully connected layer for outputting the classification result. Each convolutional layer includes multiple feature maps. The selection method specifically includes the following steps: S1. For a well-designed classification network, it is first trained on a given classification dataset, which is divided into two parts: a training set and a test set. Training is performed using conventional methods. Training stops when the accuracy on the test set meets the preset stopping condition, and the trained model parameters are saved to obtain a trained network, srcNet. S2. After the classification network srcNet is trained, feature maps can be selected. First, a new network gaNet is defined, and the structure of srcNet is copied to gaNet. Then, starting from the first convolutional layer of the gaNet network, modify the parameters of this convolutional layer by setting the number of output feature maps to the variable ga_num. Similarly, reset the value of the number of input feature maps of the second convolutional layer to the variable ga_num, while keeping the other parameters of the network unchanged. S3. Randomly generate an initial set of binary codes, that is, multiple sets of number strings composed of 0 and 1, as the population of the genetic algorithm; Each row of binary data in the population represents an individual in that population. The number of binary numbers for each individual is the value of the parameter "number of output feature maps in the first convolutional layer of the original network srcNet". 0 means that the feature map is not selected, and 1 means that the feature map is selected. S4. For each individual in the population, input the binary data BD corresponding to the individual into the gaNet network, then count the number of 1s in the binary encoded data BD, and then assign the value of the count to the variable ga_num in S3. S5. Traverse the binary encoded data BD. First, find the first number with a value of 1. Assuming the index of this number is i, it means that the i-th feature map of the first convolutional layer in the srcNet network has been selected. Then, copy the parameters of this feature map to the first feature map of the first convolutional layer in the gaNet network. Then find the second number with a value of 1. Let the index of this number be j. This means that the j-th feature map of the first convolutional layer in the srcNet network has been selected. Then copy the parameters of this feature map to the second feature map of the first convolutional layer in the gaNet network. Continue this process to complete the initialization of the first convolutional layer in the gaNet network. For the second convolutional layer in the gaNet network, a normal distribution initialization method is used; For the remaining convolutional layers and the last fully connected layer in the gaNet network, their initialization parameters are copied from the srcNet network; For the gaNet network that has been initialized, train it using the conventional training method. If the accuracy on the test set does not increase for 5 consecutive times, stop the training and record the best accuracy value of the training as the fitness value of the corresponding individual in S5. S6. For each individual in the population, repeat S5 to obtain the fitness value corresponding to each individual in the population. Standardize the fitness values of all individuals in the population so that the sum of the fitness values equals 1. Then generate a random number r, with a value between 0 and 1; iterate through each individual in the population, accumulate the sum of fitness values until the accumulated value is greater than r, stop iterating, and select the individual with the accumulated value greater than r as the parent; S7. Generate crossover offspring: By performing a crossover operation on the binary encoded data of two parent generations, i.e., genes, two new offspring individuals are generated. S8. Mutation operation: Mutate the generated offspring individuals to introduce randomness and increase the diversity of the population. Mutation operations can generate individuals with new characteristics by randomly transforming certain genes on a chromosome; For each newly generated individual, repeat steps S5 and S6 to obtain the fitness value for each newly generated individual. S9. Population Update: Offspring individuals generated through selection, crossover, and mutation operations are merged with individuals in the current population to form a new generation of population. S10. Repeat S8-S9. When the fitness value of an individual in the population is greater than the accuracy value of the original classification network srcNet, and the number of 0s in the binary code of that individual meets the user's requirements, that is, when the number of discarded feature maps meets the user's requirements, the iteration can be stopped. The gaNet network corresponding to this individual is the network obtained by selecting the feature map from the first convolutional layer of the original classification network srcNet. S11. Using the gaNet network obtained in S10 as the initial network srcNet, repeat S3-S10 until feature maps of all convolutional layers are selected. The resulting network is the final network.
2. The method for selecting feature maps of a convolutional neural network based on a genetic algorithm according to claim 1, characterized in that: In S1, each convolutional layer also includes pooling, non-linear activation, and attention extraction operations.
3. The method for selecting feature maps of a convolutional neural network based on a genetic algorithm according to claim 2, characterized in that: In S5, a set of initial binary codes is randomly generated, which are multiple sets of number strings composed of 0 and 1, as the population of the genetic algorithm; the binary data of each row in the population is the individual of the population, and the number of binary numbers of each individual is the value of the parameter of the number of output feature maps of the first convolutional layer in the original network srcNet, where 0 means not selecting the feature map and 1 means selecting the feature map.
4. The method for selecting feature maps of a convolutional neural network based on a genetic algorithm according to claim 3, characterized in that: In S5, for the second convolutional layer in the gaNet network, since the input parameters have been changed, its initial values cannot be copied from the srcNet network, so a normal distribution initialization method is adopted.
5. The method for selecting feature maps of a convolutional neural network based on a genetic algorithm according to claim 4, characterized in that: In S5, the initialization parameters for the remaining convolutional layers and the last fully connected layer in the gaNet network are copied from the srcNet network.
6. The method for selecting feature maps of a convolutional neural network based on a genetic algorithm according to claim 5, characterized in that: In step S5, the gaNet network that has been initialized is trained using conventional training methods. If the accuracy on the test set does not increase for 5 consecutive times, the training is stopped, and the best accuracy value of the training is recorded as the fitness value of the corresponding individual in S5.