Convolutional neural network adaptive training method for image classification task

Through the adaptive adjustment of the structure and hyperparameters of the convolutional neural network through evolutionary algorithms and attention mechanisms, the problems of instability and long training of the convolutional neural network model are solved, the training efficiency and accuracy are improved, and the model adaptation is enhanced Sex and robustness.

CN119180314APending Publication Date: 2024-12-24DALIAN NEUSOFT UNIV OF INFORMATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311742087.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-18
Publication Date
2024-12-24

AI Technical Summary

Technical Problem

In the prior art, the convolutional neural network model has problems such as not being adaptively selected in the training process, resulting in unstable model training, skipping the optimal solution, excessive training time, and inability to converge.

Method used

Adaptive training method for convolutional neural networks for image classification tasks is adopted, and the model structure and hyperparameters are adjusted through evolutionary algorithms, combined with attention mechanisms, adaptively adjust the number of convolutional layers and channels, and optimize the learning rate to realize the model's self-direction Adapt training.

Benefits of technology

It reduces the difficulty of model parameter adjustment, reduces the cost of manual intervention and trial and error, improves training efficiency and accuracy, enhances the adaptability and robustness of the model, and shortens the exploration time of evolutionary algorithms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119180314A_ABST
    Figure CN119180314A_ABST
Patent Text Reader

Abstract

The invention discloses a convolutional neural network adaptive training method for an image classification task, and the method comprises the steps: obtaining a to-be-classified image data set, determining a basic convolutional neural network model, determining a substructure of the basic convolutional neural network model based on the to-be-classified image data set, and carrying out the adaptive training of the basic convolutional neural network model. And determining a hyper-parameter of the basic convolutional neural network model of the determined substructure based on the to-be-classified image data set, and classifying the to-be-classified image data set according to the basic convolutional neural network model of the determined substructure and hyper-parameter. The difficulty of parameter adjustment of the network model is reduced, the manual intervention and trial and error costs are reduced, and the training efficiency and accuracy are improved; considering the depth and width of the network model, and adjusting the structure of the network model; the structure and hyper-parameters of the model are adjusted by means of an evolutionary algorithm, so that the model has good adaptability and robustness, the time required by the evolutionary algorithm is shortened through an attention mechanism, and a better solution is obtained within effective time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of deep learning, and in particular to a convolutional neural network adaptive training method for image classification tasks. Background Art

[0002] With the development of deep learning technology, deep convolutional neural network models have shown good performance in the fields of object classification and instance segmentation, and have received widespread attention from scholars from all walks of life. Building a suitable network model for the target task requires researchers to have a solid foundation in deep learning and rich experience in model building. Therefore, some inexperienced non-deep learning researchers tend to use large-scale network models, but this may increase the amount of unnecessary parameters and calculations, wasting computing resources; in addition, it may also lead to overfitting problems and weaken the model capabilities.

[0003] After determining the network model structure, it is necessary to set appropriate hyperparameters for model training. The setting of hyperparameters will directly affect the model training results. Taking the learning rate as an example, if the learning rate is too large, it may cause the network model to have problems such as unstable training and skipping the optimal solution; if the learning rate is too small, it may cause problems such as long training time and failure to converge. The setting of hyperparameters also requires the experimenter to have rich experience in parameter adjustment.

[0004] By analyzing the existing technologies, the following existing technologies and their shortcomings are identified:

[0005] "Adaptive Optimization Training Method for Convolutional Neural Networks for Image Classification" proposes a parameter update method. This method first takes a subset from the training set, trains the model based on the subset and calculates the gradient and the unbiased second-order moment estimate of the gradient and gradient difference, and uses the unbiased second-order moment estimate of the gradient and gradient difference to construct the parameter update expression. This method only considers the adjustment of parameters during the training process, but ignores the adaptive adjustment of the complexity of the network model and hyperparameters during the training process.

[0006] "An Image Classification Method Based on Layer-Adaptive Convolutional Neural Network" introduces a method for adaptively adjusting the number of layers of a network model. This method first builds a basic network with 3 or more convolutional blocks, and then splices layer-adaptive modules on the basis of the network model to achieve the purpose of sharing low-level features while making high-level features independent of each other. This method takes into account the model's adaptability to different categories of data, but for specific categories of data, the model structure is relatively fixed, and the adaptive adjustment of training hyperparameters is ignored.

[0007] "A deep convolutional neural network architecture search method and system based on particle swarm algorithm" encodes the network model structure into particles, defines the classification accuracy of the model as the fitness value, and searches for the optimal convolutional neural network structure by updating the individual historical optimal solution and the population historical optimal solution. This method can achieve adaptive exploration of the optimal network structure, but due to the huge solution space, it may take a long time to explore.

[0008] "Large-Scale Evolution of Image Classifiers" proposes a network model structure design method based on evolutionary algorithms. This method defines the model as an individual in a population and explores the optimal solution to the problem through repeated evaluation, selection, and evolution. Although this method is an adaptive algorithm, it takes a long time to find the optimal solution when the problem solution space is large.

[0009] In summary, when training the convolutional neural network model in the prior art, the structure and parameters are not adaptively selected, resulting in problems such as unstable training, skipping the optimal solution, too long training time, and failure to converge in the network model. Summary of the invention

[0010] The present invention provides a convolutional neural network adaptive training method for image classification tasks to overcome the above technical problems.

[0011] A convolutional neural network adaptive training method for image classification tasks, including:

[0012] S1. Obtain the image dataset to be classified and determine the basic convolutional neural network model.

[0013] S2. Determine the substructure of the basic convolutional neural network model based on the image dataset to be classified.

[0014] S3. Determine the hyperparameters of the basic convolutional neural network model with the determined substructure based on the image dataset to be classified, and classify the image dataset to be classified according to the basic convolutional neural network model with the determined substructure and hyperparameters.

[0015] Preferably, said S2 includes,

[0016] S2.1 encodes different substructures of the basic convolutional neural network model as individuals, wherein each substructure contains a different number of convolutional layers and a convolutional layer contains a different number of channels, and defines a state indicator vector according to the number of convolutional layers and channels of the substructure, wherein the state indicator vector is used to indicate whether a convolutional layer or a channel should be retained or removed, and defines the state indicator vector as an individual chromosome, wherein the convolutional layers and channels are represented as genes in the chromosome, wherein the number of convolutional layers and channels is randomly set respectively;

[0017] S2.2 divides the image dataset to be classified into a training set and a test set, defines a fitness evaluation function, tests different substructures of the basic convolutional neural network model based on the test set, and calculates the value of the fitness evaluation function.

[0018] S2.3 takes all individuals as the current generation, and generates the next generation based on the current generation, wherein generating the next generation based on the current generation includes selecting individuals whose fitness evaluation function values ​​satisfy a first threshold from new individuals based on an individual selection mechanism, and storing the individuals satisfying the first threshold in the next generation; for individuals whose fitness evaluation function values ​​do not satisfy the first threshold but satisfy the second threshold, performing gene mutation on genes in chromosomes through an evolutionary algorithm, and using the mutated chromosomes as new individuals, and storing the new individuals in the next generation; and reinitializing individuals whose fitness evaluation function values ​​do not satisfy the second threshold, and storing the reinitialized individuals in the next generation.

[0019] S2.4 calculates the values ​​of the fitness evaluation functions of the individuals in the next generation respectively, calculates the state indicator vector according to the values ​​of the fitness evaluation functions of the individuals, and determines whether the current state indicator vector is the optimal state indicator vector. If so, the optimal state indicator vector is recorded as α*, and S2.6 is executed; otherwise, S2.5 is executed;

[0020] S2.5 returns to S2.3 and regenerates the next generation until the optimal state indicator vector is obtained and recorded as α*.

[0021] S2.6 evaluates the importance of each channel in each convolutional layer based on the channel attention mechanism, and represents the evaluation result as γ;

[0022] S2.7 calculates the Euclidean distance between γ and α*, adjusts γ according to the Euclidean distance, and determines whether the optimal evaluation result γ* is obtained according to the set third threshold value. If yes, the optimal evaluation result is recorded as γ*, and S2.8 is executed; otherwise, returns to execute S2.6;

[0023] S2.8 determines the number of convolution layers and channels according to the optimal state indication vector α* and the optimal evaluation result γ*, and constructs a basic convolutional neural network model according to the determined number of convolution layers and channels.

[0024] Preferably, the S3 includes

[0025] S3.1 encodes the basic convolutional neural network model into individuals in the population. The model structure of each individual is the same, but the learning rate is different.

[0026] S3.2 initializes the population and initializes the individual learning rate according to η=η*(1+λ), where η is the basic learning rate and λ is a random number in the range of (-0.01, 0.01).

[0027] S3.3 defines a fitness evaluation function, wherein the fitness evaluation function is to calculate the accuracy of an individual and use the accuracy of the individual as its fitness value, wherein the accuracy of the individual is calculated based on the image data set to be classified,

[0028] S3.4 defines an evolution mechanism, which is used to simulate crossover and mutation operations. The simulated crossover and mutation operations include a learning rate of a part of individuals, which is obtained by calculating the average of the learning rates of two individuals whose fitness values ​​meet a threshold; a learning rate of a part of individuals is obtained by performing random perturbations on the basis of individuals whose fitness values ​​meet a threshold; a learning rate of a part of individuals is obtained by random initialization, wherein each part of individuals is obtained by random selection.

[0029] S3.5 defines a selection mechanism, and selects individuals according to the selection mechanism. The selection mechanism selects 5% of individuals for each generation according to the value of the fitness evaluation function, selects 6%-20% of individuals to generate new individuals through evolution, and reinitializes the remaining individuals.

[0030] In each generation of the S3.6 population, each individual is first trained, and then the fitness evaluation function value of the individual is calculated; individuals are selected according to the selection mechanism, and the population is evolved according to the evolution mechanism until the termination condition is reached. The hyperparameters that reach the termination condition are used as the hyperparameters of the basic convolutional neural network model.

[0031] Preferably, the individual selection mechanism is an elite selection mechanism.

[0032] Preferably, the selection mechanism is a tournament selection mechanism.

[0033] The present invention provides a convolutional neural network adaptive training method for image classification tasks. Starting from the two aspects of model structure and training hyperparameters, the adaptive training of the model is completed, that is, the network model structure is adaptively adjusted first, and then the network model training parameters are adaptively adjusted, which reduces the difficulty of adjusting the network model parameters, reduces the cost of manual intervention and trial and error, and improves the training efficiency and accuracy. The present invention adjusts the network model structure from the two aspects of the depth and width of the network model; adjusts the structure and hyperparameters of the model with the help of an evolutionary algorithm, so that the model has good adaptability and robustness, and introduces an attention mechanism to help shorten the exploration time required by the evolutionary algorithm and obtain a better solution within an effective time. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0035] Figure 1 is a flow chart of the method of the present invention;

[0036] Figure 2 It is a schematic diagram of the adaptive adjustment of the network model of the present invention;

[0037] Figure 3 It is a schematic diagram of training hyperparameter adjustment of the present invention;

[0038] Figure 4 is a flow chart of the evolutionary algorithm of the present invention;

[0039] Figure 5 Schematic diagram of the channel attention mechanism of the present invention;

[0040] Figure 6 It is a schematic diagram of the combination of the channel attention mechanism and the evolutionary algorithm of the present invention. DETAILED DESCRIPTION

[0041] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0042] Figure 1 It is a flow chart of the method of the present invention, such as Figure 1 As shown, the method of this embodiment may include:

[0043] S1. Obtain the image dataset to be classified and determine the basic convolutional neural network model.

[0044] S2. Determine the substructure of the basic convolutional neural network model based on the image dataset to be classified.

[0045] S3. Determine the hyperparameters of the basic convolutional neural network model with the determined substructure based on the image dataset to be classified, and classify the image dataset to be classified according to the basic convolutional neural network model with the determined substructure and hyperparameters.

[0046] Based on the above scheme, the present invention starts from the two aspects of model structure and training hyperparameters to complete the adaptive training of the model, that is, first adaptively adjust the network model structure, and then adaptively adjust the network model training parameters, which reduces the difficulty of adjusting the network model parameters, reduces the cost of manual intervention and trial and error, and improves the training efficiency and accuracy; the present invention adjusts the network model structure from the two aspects of the depth and width of the network model; adjusts the structure and hyperparameters of the model with the help of evolutionary algorithms, so that the model has good adaptability and robustness, and introduces an attention mechanism to help shorten the exploration time required for the evolutionary algorithm and obtain a better solution within an effective time.

[0047] Specifically, this embodiment provides the details of the convolutional neural network adaptive training method, including:

[0048] S1. Obtain the image dataset to be classified and determine the basic convolutional neural network model. The image classification dataset can be a public dataset such as CIFAR-10, CIFAR-100, or a private dataset built by yourself. The basic convolutional neural network model can be a large-scale network model, such as ResNet-101, ResNet-164, etc.

[0049] S2. Determine the substructure of the basic convolutional neural network model based on the image data set to be classified. The present invention realizes adaptive exploration of model structure and hyperparameters based on evolutionary algorithm. Evolutionary algorithm (EA) does not refer to a specific algorithm, but a general term for a class of algorithms. Evolutionary algorithm simulates the process of biological evolution in nature and is a random search technology based on natural selection. Because of its good parallelism and intelligence, it is widely used in combinatorial optimization problems.

[0050] In the evolutionary algorithm, a population consisting of multiple individuals is first initialized, where each individual has a unique chromosome, representing an initial solution to the target problem. Then the optimal solution to the target problem is obtained through continuous iteration of the population. Each iteration of the population is called a generation. In each generation, the fitness of these individuals is calculated according to a pre-defined fitness function, and the quality of the individuals is evaluated. After that, these individuals are evolved through evolutionary operations to obtain a new batch of individuals, which are called offspring individuals, and the individuals of the previous generation become parent individuals. Evolutionary operations can promote individuals to explore the solution space and gradually move the entire population towards the optimal solution. The fitness evaluation and iterative evolution of the updated population continue until the termination condition is reached. The optimal individual of the last generation is regarded as the optimal solution to the target problem.

[0051] The S2 comprises,

[0052] S2.1 encodes different substructures of the basic convolutional neural network model as individuals, wherein each substructure contains a different number of convolutional layers and a convolutional layer contains a different number of channels, and defines a state indicator vector according to the number of convolutional layers and channels of the substructure, wherein the state indicator vector is used to indicate whether a convolutional layer or a channel should be retained or removed, and defines the state indicator vector as an individual chromosome, wherein the convolutional layers and channels are represented as genes in the chromosome, wherein the number of convolutional layers and channels is randomly set respectively;

[0053] Specifically, S2.1 solves the problem of coding. The present invention encodes network models with different substructures as individuals. Other different substructures may include 10 convolutional layers, each convolutional layer includes 3 channels, and state indication vectors are defined for components of different granularities to indicate whether the component should be retained or removed. The state indication vector is defined as a chromosome, where there are two granularities: one is the exploration of the number of convolutional layers (which determines the depth of the model), and the other is the exploration of the number of channels contained in a layer of convolution (which determines the width of the model). Take ResNet-101 as an example (the basic network model is ResNet-101) for explanation. Different substructures of ResNet-101 are encoded as individuals. When adaptively exploring the retention or removal of residual blocks, a state indication vector α={α i ∈{0.1},i=1,2,...,n}, where α i Indicates the state of the ith residual block. The value 1 indicates that the residual block is retained, and the value 0 indicates that the residual block is removed. n represents the number of residual blocks. By exploring α, the optimal solution α* can be obtained, thereby determining the depth of the network model. In addition, we also define a state indication vector β = {β i ∈{0,1},i=1,2,...,m}, the optimal solution β* can be obtained by exploring β, where m represents the number of channels, thereby determining the width of the network model.

[0054] S2.2 divides the image dataset to be classified into a training set and a test set, defines a fitness evaluation function, tests different substructures of the basic convolutional neural network model based on the test set, and calculates the value of the fitness evaluation function.

[0055] Specifically, S2.2 is used to define the fitness evaluation function. In the target classification problem, the network model performance is usually evaluated by the classification accuracy. Therefore, the present invention defines the model test accuracy as the evaluation function of individual fitness. Accuracy is a commonly used evaluation index in the target classification problem, which is used to express the ratio of the number of correctly classified samples to the total number of samples. The understanding of the accuracy needs to be based on the understanding of the confusion matrix. The confusion matrix is ​​a form of accuracy evaluation commonly used in supervised learning. For an n-classification problem, the confusion matrix can be represented by an n×n matrix. The rows and columns of the table represent the true category and predicted category of the sample, respectively. Suppose there is a three-classification problem about orchids, chrysanthemums, and lotus flowers. At this time, its confusion matrix should be a 3×3 matrix, as shown in the following table.

[0056] Table 1 Confusion matrix for flower 3 classification problem

[0057]

[0058] where x ij (1≤i≤3,1≤j≤3) indicates the number of samples whose true category is i and whose predicted category is j. The accuracy is shown below.

[0059]

[0060] Accuracy indicates the correct rate.

[0061] S2.3 takes all individuals as the current generation, and generates the next generation based on the current generation, wherein generating the next generation based on the current generation includes selecting individuals whose fitness evaluation function values ​​satisfy a first threshold from new individuals based on an individual selection mechanism, and storing the individuals satisfying the first threshold in the next generation; for individuals whose fitness evaluation function values ​​do not satisfy the first threshold but satisfy the second threshold, performing gene mutation on genes in chromosomes through an evolutionary algorithm, and using the mutated chromosomes as new individuals, and storing the new individuals in the next generation; and reinitializing individuals whose fitness evaluation function values ​​do not satisfy the second threshold, and storing the reinitialized individuals in the next generation.

[0062] Among them, in the evolutionary algorithm, new individuals are usually generated by means of operations such as chromosome crossover and gene mutation. In the present invention, gene mutation is selected to generate new individuals. In order to ensure that the population can find a better individual in a short time, this embodiment uses the parent individual with higher fitness as a template for gene mutation, that is, selects individuals whose fitness values ​​meet the threshold from the population as models for gene mutation. Since the chromosome adopts a binary encoding method, the value of the gene is either 0 or 1. The gene mutation of the chromosome is to randomly select genes at several positions according to the length of the chromosome, and change the gene with the original value of 1 to 0; and change the gene with the original value of 0 to 1. In order to ensure the diversity of individuals and prevent individuals from falling into partial optimal solutions, in the process of population evolution, a part of individuals will be reinitialized in each generation to help other individuals break out of limitations and explore other possibilities in the solution space.

[0063] S2.4 calculates the values ​​of the fitness evaluation functions of the individuals in the next generation respectively, calculates the state indicator vector according to the values ​​of the fitness evaluation functions of the individuals, and determines whether the current state indicator vector is the optimal state indicator vector. If so, the optimal state indicator vector is recorded as α*, and S2.6 is executed; otherwise, S2.5 is executed;

[0064] S2.5 returns to S2.3 and regenerates the next generation until the optimal state indicator vector is obtained and recorded as α*.

[0065] Among them, in terms of the selection mechanism, because we hope to retain individuals with higher fitness and abandon individuals with low fitness, we choose the classic elite selection mechanism in the genetic algorithm. The fitness of each individual is evaluated by the fitness evaluation function to determine the quality of the individual. In the population, some individuals with the highest fitness can retain the original chromosomes and directly enter the next generation; for individuals with higher fitness, they can undergo random gene mutations based on themselves, and the individuals after gene mutation enter the next generation; for individuals with poor fitness, they are directly eliminated from the population, and then the same number of individuals are reinitialized to maintain the number of individuals in each generation population unchanged.

[0066] The elite selection mechanism of evolutionary algorithms is a method for evaluating and selecting each individual in a population. The core idea is to select the best individuals in each generation and directly copy them to the next generation to increase the transferability of the optimal solution in the population. This selection mechanism helps prevent excellent individuals from being destroyed during replication, crossover or mutation, thereby enhancing the stability and convergence of the algorithm.

[0067] The gene mutation operation of the evolutionary algorithm simulates the situation of gene mutation in the biological world. In this problem, the gene is the element in the state indicator vector, and the random gene mutation is to randomly select some genes (elements in some state indicator vectors) and change their values ​​from the original 1 to 0, or from the original 0 to 1.

[0068] S2.6 evaluates the importance of each channel in each convolutional layer based on the channel attention mechanism, and represents the evaluation result as γ;

[0069] S2.7 calculates the Euclidean distance between γ and α*, adjusts γ according to the Euclidean distance, and determines whether the optimal evaluation result γ* is obtained according to the set third threshold value. If yes, the optimal evaluation result is recorded as γ*, and S2.8 is executed; otherwise, returns to execute S2.6;

[0070] S2.8 determines the number of convolution layers and channels according to the optimal state indication vector α* and the optimal evaluation result γ*, and constructs a basic convolutional neural network model according to the determined number of convolution layers and channels.

[0071] Among them, when exploring the model width, the solution space is large, and the time and computing resources required to find the optimal solution to the target problem using only the evolutionary algorithm will be unbearable. In order to reduce the number of iterations required for the evolutionary algorithm to explore the optimal solution to the problem, the present invention introduces an attention mechanism. By combining the attention mechanism with the evolutionary algorithm, the optimal solution to the problem is obtained in a shorter time. The present invention uses a channel attention mechanism to calibrate the attention that the network model should pay to each channel by setting weights for the feature information extracted from each channel in the convolutional layer. The weight can be regarded as an evaluation of the importance of each channel. The present invention first uses global average pooling to fuse the feature information extracted from all channels in a layer, and then obtains the interdependence between the channels through a learnable fully connected mapping, and uses a bottle-neck structure to reduce parameters. Finally, softmax() is used as the activation function to map the output of the fully connected layer to (0,1), thereby obtaining an evaluation value of the importance of each channel of the set of channels to be pruned.

[0072] Among them, on the one hand, the importance evaluation of each channel is obtained through the attention mechanism, and the evaluation result is recorded as γ; on the other hand, the state indicator vector α* is obtained through the evolutionary algorithm. γ is adjusted by minimizing the Euclidean distance between γ and α*, where adjusting γ is to re-obtain the importance evaluation results of each channel according to the attention mechanism. First, the network model is trained for a certain epoch, and then the optimal state indicator vector α* of the residual block is explored through the evolutionary algorithm to determine the depth of the network model. Then, the optimal state indicator vector β* of the channel is found through the comprehensive application of the evolutionary algorithm and the attention mechanism to determine the width of the network model.

[0073] S3. Determine the hyperparameters of the basic convolutional neural network model with the determined substructure based on the image dataset to be classified, and classify the image dataset to be classified according to the basic convolutional neural network model with the determined substructure and hyperparameters.

[0074] The S3 includes

[0075] S3.1 encodes the basic convolutional neural network model into individuals in the population. The model structure of each individual is the same, but the learning rate is different.

[0076] S3.2 initializes the population and initializes the individual learning rate according to η=η*(1+λ), where η is the basic learning rate and λ is a random number in the range of (-0.01, 0.01).

[0077] S3.3 defines a fitness evaluation function, which is used to calculate the accuracy of an individual. In this problem, we hope that the accuracy of each individual is as high as possible, and the evolution direction of the population is also changed to evolve in the direction of higher accuracy. Therefore, the accuracy of an individual is defined as a fitness evaluation function, where the accuracy of an individual is calculated based on the image dataset to be classified.

[0078] S3.4 defines an evolution mechanism, which is used to simulate crossover and mutation operations. The simulated crossover and mutation operations include a learning rate of a part of individuals, which is obtained by calculating the average of the learning rates of two individuals whose fitness values ​​meet a threshold; a learning rate of a part of individuals is obtained by performing random perturbations on the basis of individuals whose fitness values ​​meet a threshold; a learning rate of a part of individuals is obtained by random initialization, wherein each part of individuals is obtained by random selection.

[0079] S3.5 defines a selection mechanism, and individuals are selected according to the selection mechanism, wherein the selection mechanism selects 5% of individuals for each generation according to the value of the fitness evaluation function to be saved, selects 6%-20% of individuals to generate new individuals through evolution, and reinitializes the remaining individuals, thereby ensuring that the total number of individuals between generations remains unchanged.

[0080] In each generation of the S3.6 population, each individual is first trained, and then its fitness is evaluated using the fitness evaluation function; individuals are selected according to the selection mechanism; the population is evolved according to the evolution mechanism until the termination condition is reached, and the hyperparameters that reach the termination condition are used as the hyperparameters of the basic convolutional neural network model.

[0081] Figure 2 It is a schematic diagram of the adaptive adjustment of the network model;

[0082] First, the substructure of the basic convolutional neural network model is encoded as an individual, and different individuals have different state indicator vectors α, which are used to indicate whether each convolution layer in the substructure is retained; second, the operations of fitness evaluation, elite selection, and individual evolution are iteratively performed until the iteration is terminated. The individual with the highest fitness evaluation in the last generation corresponds to the optimal state indicator vector α*; the model depth is adjusted according to α*, and the convolution layer with a median value of 1 in α* is retained to obtain a network model with a certain depth; third, the network model with a certain depth is fine-tuned for a certain epoch, and then the substructure of the network model with a certain depth is encoded as an individual, and different individuals have different state indicator vectors β, which are used to indicate whether each channel in each convolution layer in the substructure is retained; fourth, the operations of fitness evaluation, elite selection, and individual evolution are iteratively performed until the iteration is terminated. The individual with the highest fitness evaluation in the last generation corresponds to the optimal state indicator vector β*; finally, the model width is adjusted according to β*, and the channels with a median value of 1 in β* are retained to obtain a network model with a certain width.

[0083] Figure 3 It is a diagram of training hyperparameter adjustment;

[0084] First, the model is encoded as individuals, and the chromosomes of the individuals are the learning rates, which are different for different individuals. The process of fitness evaluation, evolution, and selection is repeated until the iteration is terminated. The learning rate carried by the individual with the highest fitness in the last generation is the optimal learning rate for the training of the network model.

[0085] Figure 4 This is the flow chart of evolutionary algorithm;

[0086] First, initialize the population, which contains multiple individuals with different chromosomes; second, evaluate the fitness of each individual through the predefined fitness evaluation function; third, select individuals with higher fitness to enter the next generation directly according to the predefined elite selection mechanism, and generate new individuals with lower fitness to enter the next generation after evolution, so as to ensure that the total number of individuals in each generation remains unchanged. Repeat the process of fitness evaluation, selection, and evolution until the termination condition is reached. The chromosome carried by the individual with the highest fitness in the last generation is the optimal solution to the original problem.

[0087] Figure 5 Schematic diagram of the channel attention mechanism.

[0088] The present invention refers to the channel attention mechanism proposed in SENet. First, the feature information extracted from all channels in a layer is fused using global average pooling; then the interdependence between channels is obtained through a learnable fully connected mapping, and the bottle-neck structure is used to reduce parameters. Unlike SENet, this embodiment uses the softmax function as the activation function to map the output of the fully connected layer to (0,1), thereby obtaining an evaluation value of the importance of each channel in the set of channels to be pruned.

[0089] Figure 6 Schematic diagram of the combination of channel attention mechanism and evolutionary algorithm.

[0090] On the one hand, the importance of each channel is evaluated with the help of the attention mechanism, and on the other hand, the evolutionary algorithm is used to obtain a better state indicator vector to represent the genetic algorithm's preliminary judgment on the importance of each channel in the pruned channel set. Then the Euclidean distance between the importance evaluation of the attention mechanism and the importance evaluation of the evolutionary algorithm is calculated, and the Euclidean distance is used as the loss function. The gradient descent algorithm is used to adjust the parameters of the fully connected layer in the channel attention mechanism, and then the final judgment of the importance of each channel is obtained.

[0091] Overall beneficial effects:

[0092] The present invention provides a convolutional neural network adaptive training method for image classification tasks. Starting from the two aspects of model structure and training hyperparameters, the adaptive training of the model is completed, that is, the network model structure is adaptively adjusted first, and then the network model training parameters are adaptively adjusted, which reduces the difficulty of adjusting the network model parameters, reduces the cost of manual intervention and trial and error, and improves the training efficiency and accuracy. The present invention adjusts the network model structure from the two aspects of the depth and width of the network model; adjusts the structure and hyperparameters of the model with the help of an evolutionary algorithm, so that the model has good adaptability and robustness, and introduces an attention mechanism to help shorten the exploration time required by the evolutionary algorithm and obtain a better solution within an effective time.

[0093] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A convolutional neural network adaptive training method for image classification tasks, characterized in that: include, S1. Obtain the image dataset to be classified and determine the basic convolutional neural network model. S2. Determine the substructure of the basic convolutional neural network model based on the image dataset to be classified. S3. Determine the hyperparameters of the basic convolutional neural network model with the determined substructure based on the image dataset to be classified, and classify the image dataset to be classified according to the basic convolutional neural network model with the determined substructure and hyperparameters.

2. The method for adaptive training of a convolutional neural network for image classification tasks according to claim 1, characterized in that: The S2 comprises, S2.1 encodes different substructures of the basic convolutional neural network model as individuals, wherein each substructure contains a different number of convolutional layers and a convolutional layer contains a different number of channels, and defines a state indicator vector according to the number of convolutional layers and channels of the substructure, wherein the state indicator vector is used to indicate whether a convolutional layer or a channel should be retained or removed, and defines the state indicator vector as an individual chromosome, wherein the convolutional layers and channels are represented as genes in the chromosome, wherein the number of convolutional layers and channels is randomly set respectively; S2.2 divides the image dataset to be classified into a training set and a test set, defines a fitness evaluation function, tests different substructures of the basic convolutional neural network model based on the test set, and calculates the value of the fitness evaluation function. S2.3 takes all individuals as the current generation, and generates the next generation based on the current generation, wherein generating the next generation based on the current generation includes selecting individuals whose fitness evaluation function values ​​satisfy a first threshold from new individuals based on an individual selection mechanism, and storing the individuals satisfying the first threshold in the next generation; for individuals whose fitness evaluation function values ​​do not satisfy the first threshold but satisfy the second threshold, performing gene mutation on genes in chromosomes through an evolutionary algorithm, and using the mutated chromosomes as new individuals, and storing the new individuals in the next generation; and reinitializing individuals whose fitness evaluation function values ​​do not satisfy the second threshold, and storing the reinitialized individuals in the next generation. S2.4 calculates the values ​​of the fitness evaluation functions of the individuals in the next generation respectively, calculates the state indicator vector according to the values ​​of the fitness evaluation functions of the individuals, and determines whether the current state indicator vector is the optimal state indicator vector. If so, the optimal state indicator vector is recorded as α*, and S2.6 is executed; otherwise, S2.5 is executed; S2.5 returns to S2.3 and regenerates the next generation until the optimal state indicator vector is obtained and recorded as α*. S2.6 evaluates the importance of each channel in each convolutional layer based on the channel attention mechanism, and represents the evaluation result as γ; S2.7 calculates the Euclidean distance between γ and α*, adjusts γ according to the Euclidean distance, and determines whether the optimal evaluation result γ* is obtained according to the set third threshold value. If yes, the optimal evaluation result is recorded as γ*, and S2.8 is executed; otherwise, returns to execute S2.6; S2.8 determines the number of convolution layers and channels according to the optimal state indication vector α* and the optimal evaluation result γ*, and constructs a basic convolutional neural network model according to the determined number of convolution layers and channels.

3. The method for adaptive training of convolutional neural networks for image classification tasks according to claim 1, characterized in that: The S3 includes S3.1 encodes the basic convolutional neural network model into individuals in the population. The model structure of each individual is the same, but the learning rate is different. S3.2 initializes the population and initializes the individual learning rate according to η=η*(1+λ), where η is the basic learning rate and λ is a random number in the range of (-0.01, 0.01). S3.3 defines a fitness evaluation function, wherein the fitness evaluation function is to calculate the accuracy of an individual and use the accuracy of the individual as its fitness value, wherein the accuracy of the individual is calculated based on the image data set to be classified, S3.4 defines an evolution mechanism, which is used to simulate crossover and mutation operations. The simulated crossover and mutation operations include a learning rate of a part of individuals, which is obtained by calculating the average of the learning rates of two individuals whose fitness values ​​meet a threshold; a learning rate of a part of individuals is obtained by performing random perturbations on the basis of individuals whose fitness values ​​meet a threshold; a learning rate of a part of individuals is obtained by random initialization, wherein each part of individuals is obtained by random selection. S3.5 defines a selection mechanism, and selects individuals according to the selection mechanism. The selection mechanism selects 5% of individuals for each generation according to the value of the fitness evaluation function, selects 6%-20% of individuals to generate new individuals through evolution, and reinitializes the remaining individuals. In each generation of the S3.6 population, each individual is first trained, and then the fitness evaluation function value of the individual is calculated; individuals are selected according to the selection mechanism, and the population is evolved according to the evolution mechanism until the termination condition is reached. The hyperparameters that reach the termination condition are used as the hyperparameters of the basic convolutional neural network model.

4. The method for adaptive training of a convolutional neural network for image classification tasks according to claim 2, characterized in that: The individual selection mechanism is an elite selection mechanism.

5. The method for adaptive training of convolutional neural networks for image classification tasks according to claim 3, characterized in that: The selection mechanism is a tournament selection mechanism.