A face recognition optimization method based on improved genetic algorithm
Through improved genetic algorithms, the hyperparameters of convolutional neural networks are globally tuned, which solves the problem of local optimal solutions in the hyperparameter optimization process of convolutional neural networks, and improves the accuracy and search speed of face recognition.
Patent Information
- Application Number
- CN202111249512.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-26
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2041-10-26
AI Technical Summary
In the existing face recognition technology, the hyperparameter optimization process of convolutional neural networks is prone to fall into local optimal solutions, and the calculation complexity is high, resulting in insufficient recognition accuracy.
The hyperparameters of the convolutional neural network are globally tuned by improved genetic algorithms. Through adaptive adjustment of dynamic cross-probability and variation probability, the connection weights of the convolutional layer filter and the fully connected layer are optimized to avoid local optimal solutions and Improve recognition accuracy.
It effectively avoids local optimal solutions, improves the accuracy of face recognition, and speeds up the hyperparameter optimization search, significantly improving recognition performance.
Smart Images

Figure CN113963410B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of face recognition, and in particular to research on a face recognition method. Background Art
[0002] In recent years, with the rapid development of artificial intelligence, face image information processing and recognition technology has been updated day by day, among which face recognition has also received considerable attention. However, there are still many problems in the field of face recognition that have not been solved and need to be further studied. With the development of deep learning, the requirements for labeled data sets are getting higher and higher, which leads to more and more hyperparameters that need to be optimized in network models. For example, the most commonly used recognition model, convolutional neural network, has a large number of hyperparameters that need to be optimized.
[0003] Currently, the more popular parameter tuning methods all have a series of problems. For example, cross-validation mainly divides the original data samples into k groups randomly, and uses one group as the test set each time, and the other k-1 groups as the training set. Finally, the average of the accuracy of the k classification models is used to evaluate the performance of the model. This algorithm requires repeated training and testing, and the amount of calculation is large. For the grid search algorithm, this method mainly finds the optimal parameters of the recognition model by exhaustively enumerating all combinations. The biggest advantage is that it can be processed in parallel, but when the grid density is large, the search accuracy is high and the computational overhead is large, and the optimal solution may be missed.
[0004] Both of the above methods have the disadvantages of high computational complexity and time-consuming search. In recent years, people have been inspired by the evolution of nature and applied swarm intelligence optimization algorithms to study the optimal parameters of classifiers. For example, genetic algorithms can effectively solve the problem that parameters are prone to falling into local optimal solutions. In addition, there are particle swarm optimization algorithms, ant colony algorithms, and differential evolution algorithms. Summary of the invention
[0005] In view of the shortcomings of the prior art, the purpose of the present invention is to provide a face recognition method that combines a genetic algorithm and a convolutional neural network. The improved genetic algorithm is used to optimize the hyperparameters of the convolutional neural network, which solves the problem that the traditional parameter optimization process may fall into the local optimal solution, while improving the accuracy of face recognition.
[0006] A face recognition optimization method based on an improved genetic algorithm comprises the following steps:
[0007] Step 1, construct a face sample dataset through public face data on the Internet, and preprocess the training dataset and test dataset in the face sample dataset;
[0008] Step 2: Use an improved genetic algorithm to globally tune the hyperparameters of the convolutional neural network model. By continuously optimizing the connection weights of the convolutional layer filters and the fully connected layer, the optimal hyperparameters of the convolutional neural network model are determined, and a trained convolutional neural network model is obtained.
[0009] In step 2, after the population is initialized, the performance of the neural network is evaluated and the selection probability is assigned, a crossover is performed to generate a crossover offspring that shares the properties of the parent network, and then the parent network is selected to mutate to generate a mutant offspring, and the crossover offspring and the mutant offspring are added to the next generation population for replacement optimization to achieve iterative training;
[0010] Step 3: Input the sample test set into the convolutional neural network model trained in step 2 to complete face recognition.
[0011] Furthermore, step 1 is specifically divided into the following steps:
[0012] Step 1.1, divide the face sample dataset into a training dataset and a test dataset according to the ratio;
[0013] Step 1.2: Perform PCA feature extraction on the training data set and the test data set respectively, and normalize the data after dimensionality reduction.
[0014] Furthermore, step 2 is specifically divided into the following steps:
[0015] Step 2.1 Initialization: Create an initial population. Each chromosome in the population represents a network. The convolutional layer in each network is considered as a whole as an element in the chromosome, and the fully connected layer in each network is considered as a whole as another element in the chromosome. That is, each chromosome element contains all the values of the filter in the convolutional layer, or contains all the connection weights of a fully connected layer;
[0016] Step 2.2 Evaluation: Input the face image data in the training data set to each network in the population, evaluate the performance of each network, use the accuracy of each network as the fitness value of the population individual, and assign a fitness value to each network;
[0017] Step 2.3 Selection: Assign a selection probability to each network. The selection operation adopts the roulette method. The higher the fitness of each network, the greater the possibility of its selection.
[0018] Step 2.4 Crossover: Repeat the selection operation twice, select two networks as parents, and generate a new crossover offspring through crossover. The crossover offspring shares some properties of the parents.
[0019] Step 2.5 Mutation: Perform a selection operation, select a network as the parent, and generate a new mutant child through mutation. Some attributes of the mutant child are the same as those of the parent.
[0020] Step 2.6 Replacement: The new offspring will be added to the next generation population, replacing the individuals with the lowest fitness;
[0021] Determine whether the maximum number of iterations has been reached. If not, return to step 2.2. If so, select the individual with the best fitness in the population as the trained convolutional neural network.
[0022] Furthermore, the initialization operation in step 2.1 refers to creating an initial population and setting parameters including population size, maximum number of iterations, maximum crossover probability, minimum crossover probability, maximum mutation probability, and minimum mutation probability; the networks in the population have the same structure, all convolutional layers, pooling layers, and fully connected layers have the same dimensions, and filters and connection weights are randomly assigned.
[0023] Furthermore, the evaluation operation in step 2.2 refers to inputting the training data set images into all networks in the population for training, calculating the loss function value between the predicted output and the sample label, and obtaining the recognition accuracy of each network, and using the recognition accuracy as the fitness value of each network.
[0024] Furthermore, the selection operation in step 2.3 refers to the use of a roulette wheel method. The higher the fitness of the network, the more likely it is to be selected as the parent or father of reproduction; i represents the probability of the i-th network being selected, f i represents the fitness value of the ith network, N is the population size, then the probability of the ith network being selected is:
[0025]
[0026] In the mutation process, the selection operation will select a network as the parent, and the parent will generate the child. First, a random number and P are generated from a uniform distribution on [0,1]. i Compare, if less than P i , then the i-th network will be selected; in the crossover process, the selection operation will select two networks as parents, and a child will be generated from the parents, so the above selection process will be performed twice.
[0027] Furthermore, the crossover operation in step 2.4 refers to the use of an adaptive crossover probability. When the fitness of the network is high, it corresponds to a lower crossover probability, protecting the current network from entering the next generation; when the fitness of the network is low, it corresponds to a higher crossover probability, causing the current network to be eliminated;
[0028] Use Pc represents the crossover probability, P cmax represents the maximum crossover probability, P cmin represents the minimum crossover probability, f represents the network fitness, f max represents the maximum fitness of the population, f avg represents the average fitness of the population, f' represents the fitness of the parent to be crossed with a larger fitness, then the crossover probability formula is:
[0029]
[0030] In the crossover operation, two parent networks will produce a new child; a random number with a crossover probability P is generated from a uniform distribution on [0,1] c Compare, if the random number is less than P c , then the parent network performs a crossover operation; first, an exact copy of the parent network is copied, and one of the parents is randomly selected. For the chromosome elements containing the convolutional layer, the corresponding filter is copied to the offspring; for the chromosome elements containing the fully connected layer, one of the parents is still randomly selected, and the weights of all neurons are copied to the offspring.
[0031] Furthermore, the mutation operation in step 2.5 refers to the use of an adaptive mutation probability. When the fitness of the network is high, it corresponds to a lower mutation probability, protecting the current network from entering the next generation; when the fitness of the network is low, it corresponds to a higher mutation probability, causing the current network to be eliminated;
[0032] Use P m represents the mutation probability, P mmax represents the maximum mutation probability, P mmin represents the minimum mutation probability, then the mutation probability formula is:
[0033]
[0034] In the mutation operation, the parent network will generate a new child; a random number and mutation probability P are generated from a uniform distribution on [0,1] m Compare, if the random number is less than P m , then the parent network undergoes mutation operation; first, an exact copy of the parent network is copied, and for the chromosome elements containing the convolutional layer, each value in the filter is replaced by a Gaussian noise with the value as the mean and a standard deviation of 0.5; for the chromosome elements containing the fully connected layer, a random number from the initial distribution is added to the weight of each neuron.
[0035] Furthermore, the replacement operation in step 2.6 ensures that the population size N remains unchanged.
[0036] Compared with the prior art, the present invention has the following beneficial effects:
[0037] (1) An improved genetic algorithm is used to globally tune the hyperparameters of the convolutional neural network model, which avoids the situation in which the convolutional neural network model parameters may fall into the local optimal solution in the traditional parameter optimization method, speeds up the search capability, and improves the accuracy of face recognition.
[0038] (2) By improving the genetic algorithm and adopting dynamic crossover and mutation probabilities, individuals with lower fitness in the population are given greater crossover and mutation probabilities, while individuals with higher fitness are given smaller crossover and mutation probabilities, thereby prompting the entire population to evolve towards the optimal solution and accelerating the speed of hyperparameter optimization. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a flow chart of the face recognition optimization method based on the improved genetic algorithm described in the embodiment of the present invention.
[0040] Figure 2 It is a flow chart of the genetic algorithm described in the embodiment of the present invention.
[0041] Figure 3 Schematic diagram of the SchafferF6 function described in an embodiment of the present invention.
[0042] Figure 4 This is a comparison chart of recognition accuracy rates described in an embodiment of the present invention. DETAILED DESCRIPTION
[0043] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings.
[0044] The face recognition optimization method based on the improved genetic algorithm includes the following steps:
[0045] Step 1: Build data samples by obtaining the LFW dataset publicly available online, divide the data samples into data sets and training sets in a ratio of 7:3, and perform preprocessing. The LFW dataset is a relatively authoritative dataset in the field of face recognition, with a total of 13,233 face images and 5,749 people.
[0046] (1) Perform preprocessing operations on the image obtained in the first step, including noise removal, normalization operations, etc. The purpose of preprocessing is to make the subsequent work simple and efficient.
[0047] (2) Feature extraction. In this step, feature extraction is performed on the preprocessed image to obtain important and highly representative information in the image. The commonly used method is dimensionality reduction operation, and the present invention uses PCA principal component analysis.
[0048] Step 2: Use the improved genetic algorithm to globally tune the hyperparameters of the convolutional neural network model. By continuously optimizing the convolutional layer filters and the connection weights of the fully connected layer, the optimal hyperparameters of the convolutional neural network model are determined, and a trained convolutional neural network model is obtained. The specific steps are as follows:
[0049] (1) Initialization: Create an initial population and set parameters such as population size, maximum number of iterations, maximum crossover probability, minimum crossover probability, maximum mutation probability, and minimum mutation probability. Each chromosome in the population represents a network, and the convolutional layer in each network is considered as a whole as an element in the chromosome, and the fully connected layer in each network is considered as a whole as another element in the chromosome. That is, each chromosome element contains all the values of the filters in the convolutional layer, or contains all the connection weights of a fully connected layer. The networks in the population have the same structure, and all convolutional layers, pooling layers, and fully connected layers have the same dimensions, but their filters and connection weights are randomly assigned.
[0050] (2) Evaluation: Input the face image data in the training sample dataset into each network in the population for training, calculate the loss function value between the predicted output and the sample label, and obtain the recognition accuracy of each network. Evaluate the performance of each network, use the accuracy of each network as the fitness value of the individual in the population, and assign a fitness value to each network.
[0051] (3) Selection: Assign a selection probability to each network. The selection operation adopts the roulette method. The higher the fitness of the network, the more likely it is to be selected as the parent or father of reproduction. i represents the probability of the i-th network being selected, f i represents the fitness value of the ith network, N is the population size, then the probability of the ith network being selected is:
[0052]
[0053] In the mutation process, the selection operation will select a network as the parent, and the parent will generate the child. First, a random number and P are generated from a uniform distribution on [0,1]. i Compare, if less than P i , then the i-th network will be selected. In the crossover process, the selection operation will select two networks as parents, and a child will be generated from the parents, so the above selection process will be performed twice.
[0054] (4) Crossover: Repeat the selection operation twice, select two networks as parents, and generate a new offspring through crossover. The offspring will share some properties of the parents. Generate a random number and crossover probability P from a uniform distribution on [0,1].c Compare, if the random number is less than P c , then the parent network undergoes a crossover operation. First, an exact copy of the parent network is made, and one of the parents is randomly selected. For the chromosome elements containing the convolutional layer, the corresponding filter is copied to the offspring. For the chromosome elements containing the fully connected layer, one of the parents is still randomly selected, and the weights of all neurons are copied to the offspring.
[0055] (5) Mutation: Perform a selection operation, select a network as the parent, and generate a new child through mutation. Some of the properties of the child are the same as the parent. Generate a random number and mutation probability P from a uniform distribution on [0,1]. m Compare, if the random number is less than P m , then the parent network is mutated. First, an exact copy of the parent network is copied. For the chromosome elements containing the convolutional layer, each value in the filter is replaced by a Gaussian noise with the mean value and a standard deviation of 0.5. For the chromosome elements containing the fully connected layer, a random number from the initial distribution is added to the weight of each neuron.
[0056] In order to solve the problem that the traditional genetic algorithm may fall into the local optimal solution and speed up the search ability, the crossover probability and mutation probability of the genetic algorithm are improved, and P c represents the crossover probability, P cmax represents the maximum crossover probability, P cmin represents the minimum crossover probability, f represents the network fitness, P m represents the mutation probability, P mmax represents the maximum mutation probability, P mmin represents the minimum mutation probability, f max represents the maximum fitness of the population, f avg represents the average fitness of the population, f' represents the fitness of the one with the larger fitness of the two parties to be crossed, k1, k2, k3, k4 are constants, all between 0 and 1. The crossover probability and mutation probability of the traditional genetic algorithm are as follows:
[0057]
[0058]
[0059] However, when the individual fitness is close to or equal to the maximum fitness of the population, there will be a crossover probability P c and mutation probability P mThe situation close to zero makes the individuals in the early stage of evolution basically unchanged, increasing the possibility of falling into the local optimal solution. This is mainly because in the early stage of evolution, individuals with higher fitness may be the local optimal solution or the global optimal solution of the target problem, which increases the possibility of population evolution falling into the local optimal solution. In view of the above defects, the following improvements have been made to the crossover probability and mutation probability:
[0060]
[0061]
[0062] The improved dynamic crossover probability and mutation probability have the ability to adapt. When the individual fitness is high, it corresponds to a lower crossover probability and mutation probability, protecting the current individual from entering the next generation; when the individual fitness is low, it corresponds to a higher crossover and mutation probability, causing the current individual to be eliminated. When the individual fitness is close to the maximum fitness, the crossover probability and mutation probability will not tend to 0, and will be adjusted according to the network fitness, so that the parameters will not be in a stagnant state during tuning.
[0063] By improving the crossover probability and mutation probability of the genetic algorithm, the convergence accuracy of the genetic algorithm is greatly improved and the convergence speed is accelerated. The improved genetic algorithm maintains the diversity of the population while also ensuring the convergence of the genetic algorithm. In view of the fact that convolutional neural networks have a large number of hyperparameters and weights that need to be optimized, the improved genetic algorithm is used to optimize the hyperparameters of the convolutional neural network, which solves the problem of falling into the local optimal solution in the traditional parameter optimization method and increases the speed of search.
[0064] (6) Replacement: The new offspring will be added to the next generation population, replacing the individual with the lowest fitness. Determine whether the maximum number of iterations has been reached. If not, return to step (2). If satisfied, select the individual with the best fitness in the population as the trained convolutional neural network.
[0065] Step 3: For the trained convolutional neural network model obtained in step 2, input the sample test set into the model to complete face recognition.
[0066] The present invention improves the crossover probability and mutation probability of the genetic algorithm and uses the improved genetic algorithm to optimize the hyperparameters of the convolutional neural network model. It solves the problem that the traditional convolutional neural network model has high computational complexity during hyperparameter tuning and is prone to falling into local optimal solutions. It accelerates the convergence speed and effectively improves the accuracy of face recognition.
[0067] Through experimental verification, the SchafferF6 function was selected for testing, and its simulation was compared and analyzed:
[0068]
[0069] SchafferF6 function Figure 3 As shown. This function has infinite maximum points within the range of the independent variable, of which only one (0, 0) is the global maximum point, and the maximum value is 1. The simulation results are shown below:
[0070] Comparison results between basic genetic algorithm and improved genetic algorithm
[0071]
[0072] From the above analysis, we can see that:
[0073] For the simple genetic algorithm, after 500 genetic iterations, the global maximum point was not found once; after using the improved genetic algorithm, the global maximum point (0,0) was found 24 times after 500 iterations, with an average number of iterations of 384.3; from the above table, it can be found that the use of the improved strategy can greatly improve the success rate of finding the optimal solution, and at the same time speed up the optimization speed of the genetic algorithm.
[0074] The improved genetic algorithm is used to optimize the accuracy of CNN face recognition results. The results of CNN and GA-CNN are as follows: Figure 4 As shown in the figure. The first part is the accuracy of CNN recognition, and the second part is the optimization result using GA_CNN. The upper figure in each part is the recognition accuracy, and the lower figure is the loss. By comparison, when the genetic algorithm is not used to optimize the convolutional neural network, the recognition accuracy is 81.3%. The proposed GA_CNN has a better recognition effect, and the best recognition rate is 95.5%.
[0075] The above description is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiment. Any equivalent modifications or changes made by ordinary technicians in this field based on the contents disclosed by the present invention should be included in the protection scope recorded in the claims.
Claims
1. A face recognition optimization method based on an improved genetic algorithm, characterized in that: The method comprises the following steps: Step 1: construct a face sample dataset through public face data on the Internet, and preprocess the training dataset and test dataset in the face sample dataset; Step 2: Use an improved genetic algorithm to globally tune the hyperparameters of the convolutional neural network model. By continuously optimizing the connection weights of the convolutional layer filters and the fully connected layer, the optimal hyperparameters of the convolutional neural network model are determined, and a trained convolutional neural network model is obtained. In step 2, after the population is initialized, the performance of the neural network is evaluated and the selection probability is assigned, a crossover is performed to generate a crossover offspring that shares the properties of the parent network, and then the parent network is selected to mutate to generate a mutant offspring, and the crossover offspring and the mutant offspring are added to the next generation population for replacement optimization to achieve iterative training; Step 2 is divided into the following steps: Step 2.1 Initialization: Create an initial population. Each chromosome in the population represents a network. The convolutional layer in each network is considered as a whole as an element in the chromosome, and the fully connected layer in each network is considered as a whole as another element in the chromosome; that is, each chromosome element contains all the values of the filter in the convolutional layer, or contains all the connection weights of a fully connected layer; Step 2.2 Evaluation: Input the face image data in the training data set to each network in the population, evaluate the performance of each network, use the accuracy of each network as the fitness value of the population individual, and assign a fitness value to each network; Step 2.3 Selection: Assign a selection probability to each network. The selection operation adopts the roulette method. The higher the fitness of each network, the greater the possibility of its selection. Step 2.4 Crossover: Repeat the selection operation twice, select two networks as parents, and generate a new crossover offspring through crossover. The crossover offspring shares some properties of the parents. Step 2.5 Mutation: Perform a selection operation, select a network as the parent, and generate a new mutant child through mutation. Some attributes of the mutant child are the same as those of the parent. Step 2.6 Replacement: The new offspring will be added to the next generation population, replacing the individuals with the lowest fitness; Determine whether the maximum number of iterations has been reached. If not, return to step 2.
2. If so, select the individual with the best fitness in the population as the trained convolutional neural network. Step 3: Input the sample test set into the convolutional neural network model trained in step 2 to complete face recognition.
2. The face recognition optimization method based on improved genetic algorithm according to claim 1, characterized in that: Step 1 is divided into the following steps: Step 1.1, divide the face sample dataset into a training dataset and a test dataset according to the ratio; Step 1.2: Perform PCA feature extraction on the training data set and the test data set respectively, and normalize the data after dimensionality reduction.
3. The face recognition optimization method based on improved genetic algorithm according to claim 1, characterized in that: The initialization operation in step 2.1 refers to creating an initial population and setting parameters including population size, maximum number of iterations, maximum crossover probability, minimum crossover probability, maximum mutation probability, and minimum mutation probability; the networks in the population have the same structure, all convolutional layers, pooling layers, and fully connected layers have the same dimensions, and filters and connection weights are randomly assigned.
4. The face recognition optimization method based on improved genetic algorithm according to claim 1, characterized in that: The evaluation operation in step 2.2 refers to inputting the training data set images into all networks in the population for training, calculating the loss function value between the predicted output and the sample label, and obtaining the recognition accuracy of each network, and using the recognition accuracy as the fitness value of each network.
5. The face recognition optimization method based on improved genetic algorithm according to claim 1, characterized in that: The selection operation in step 2.3 refers to the roulette wheel method. The higher the fitness of the network, the more likely it is to be selected as the parent or father of reproduction; i represents the probability of the i-th network being selected, f i represents the fitness value of the ith network, N is the population size, then the probability of the ith network being selected is: In the mutation process, the selection operation will select a network as the parent, and the parent will generate the child. First, a random number and P are generated from a uniform distribution on [0,1]. i Compare, if less than P i , then the i-th network will be selected; in the crossover process, the selection operation will select two networks as parents, and a child will be generated from the parents, so the above selection process will be performed twice.
6. The face recognition optimization method based on improved genetic algorithm according to claim 1, characterized in that: The crossover operation in step 2.4 refers to the use of adaptive crossover probability. When the fitness of the network is high, it corresponds to a lower crossover probability, protecting the current network from entering the next generation; when the fitness of the network is low, it corresponds to a higher crossover probability, causing the current network to be eliminated; Use P c represents the crossover probability, P cmax represents the maximum crossover probability, P cmin represents the minimum crossover probability, f represents the network fitness, f max represents the maximum fitness of the population, f avg represents the average fitness of the population, f' represents the fitness of the parent to be crossed with a larger fitness, then the crossover probability formula is: In the crossover operation, two parent networks will produce a new child; a random number with a crossover probability P is generated from a uniform distribution on [0,1] c Compare, if the random number is less than P c , then the parent network performs a crossover operation; first, an exact copy of the parent network is copied, and one of the parents is randomly selected. For the chromosome elements containing the convolutional layer, the corresponding filter is copied to the offspring; for the chromosome elements containing the fully connected layer, one of the parents is still randomly selected, and the weights of all neurons are copied to the offspring.
7. The face recognition optimization method based on improved genetic algorithm according to claim 1, characterized in that: The mutation operation in step 2.5 refers to the use of adaptive mutation probability. When the fitness of the network is high, it corresponds to a lower mutation probability, protecting the current network from entering the next generation; when the fitness of the network is low, it corresponds to a higher mutation probability, causing the current network to be eliminated; Use P m represents the mutation probability, P mmax represents the maximum mutation probability, P mmin represents the minimum mutation probability, then the mutation probability formula is: In the mutation operation, the parent network will generate a new child; a random number and mutation probability P are generated from a uniform distribution on [0,1] m Compare, if the random number is less than P m , then the parent network undergoes mutation operation; first, an exact copy of the parent network is copied, and for the chromosome elements containing the convolutional layer, each value in the filter is replaced by a Gaussian noise with the value as the mean and a standard deviation of 0.5; for the chromosome elements containing the fully connected layer, a random number from the initial distribution is added to the weight of each neuron.
8. The face recognition optimization method based on improved genetic algorithm according to claim 1, characterized in that: The replacement operation in step 2.6 ensures that the population size N remains unchanged.
