Training method and device of network model and computer readable storage medium
By performing multiple iterations of training and cross-correction mutation operations on the network model set, the problem of time-consuming and laborious neural network structure design is solved, and the search efficiency of the network model and the accuracy of image processing are improved.
Patent Information
- Application Number
- CN202111447393.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2041-11-30
AI Technical Summary
In existing technologies, designing neural network structures is time-consuming and laborious, and it is difficult to find the most suitable network structure, resulting in poor network model performance that cannot meet the accuracy requirements of image processing.
By iteratively training multiple network models in the network model set and using cross-correction and mutation operations, the network model set is updated to avoid local optima and improve the search efficiency and accuracy of the network model.
It enables more efficient searching for better-performing network models, improves the accuracy of image processing, and avoids getting trapped in local optima during the search process.
Smart Images

Figure CN114219072B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, in particular to a network model training method, a network model training device and a computer readable storage medium. BACKGROUND
[0002] In the field of image processing, a trained network model is usually used for image processing. For example, a network model is used for image recognition and image segmentation tasks. Therefore, the accuracy of the network model for image processing is particularly important.
[0003] In the field of deep learning, researchers need to manually design the network structure of a specific network model, such as a neural network structure, for different tasks. The architecture of a convolutional neural network includes the size and number of convolution kernels, the size and number of pooling or downsampling, the number of network layers, and the hyperparameters of cross-layer connections. As the number of network layers increases, the number of possible network structures also increases exponentially. Researchers often have to rely on experience and repeated trials to design a neural network structure that is suitable for a specific task and has good performance. This process is very time-consuming and laborious, and it is not always possible to find the best network structure for the task.
[0004] In related technologies, a neural network architecture search method is used to search for a network architecture. However, the performance of the network model searched in this way is poor and cannot meet the accuracy requirements of the network model for image processing. SUMMARY
[0005] The technical problem solved by the present application is to provide a network model training method, a network model training device and a computer readable storage medium, which can avoid getting stuck in a local optimal solution during the search for a network structure, thereby searching for a network model with better performance, and searching for one or more network models to improve the search efficiency of the network model.
[0006] To solve the above problems, one technical solution adopted by the present application is to provide a network model training method. The network model is used for image processing. The training method comprises: using training samples to perform multiple iteration training on multiple network models in a network model set until a training stop condition is met; the i-th iteration training in the multiple iteration training comprises: using training samples to perform basic training on the multiple network models in the network model set to obtain multiple trained network models; wherein i is an integer greater than 1; cross-correcting at least two first target network models to obtain a corresponding number of second target network models; the first target network model is a network model in the multiple trained network models; and updating the network model set using the corresponding number of second target network models.
[0007] The network model set is updated by using the corresponding number of second target network models, including: using each second target network model to replace the corresponding first target network model in the network model set.
[0008] The network model includes a plurality of structure blocks, and each structure block includes nodes connected in a target connection mode.
[0009] Before the at least two first target network models are cross-corrected to obtain the corresponding number of second target network models, the method further includes: determining the fitness of each network model in the plurality of trained network models; and determining the at least two first target network models from the plurality of trained network models based on the determined fitness.
[0010] The at least two first target network models are determined from the plurality of trained network models based on the determined fitness, including: determining a trained network model with a fitness less than a set threshold as a first target network model; and / or sorting all network models in the plurality of trained network models according to the size of the fitness, and determining a network model at a target sequence position as a first target network model.
[0011] The at least two first target network models are cross-corrected to obtain the corresponding number of second target network models, including: performing a cross operation on each two first target network models to update the connection structure of each first target network model; and performing a mutation operation on the updated first target network model to update the connection structure of the first target network model again to obtain a second target network model.
[0012] Before the cross operation is performed on each two first target network models, the method further includes: determining the fitness of each network model in the plurality of trained network models; determining the maximum fitness and the average fitness of all fitness; determining the larger fitness of the fitness of each two first target network models as a target fitness; determining a cross rate by using the target fitness, the maximum fitness, and the average fitness; and performing the cross operation on each two first target network models, including: performing the cross operation on each two first target network models according to the cross rate.
[0013] The connection structure of the first target network model is updated again to obtain a second target network model, including: determining the fitness of each network model in the plurality of trained network models; determining the maximum fitness and the average fitness of all the fitnesses; determining the mutation rate based on the first fitness, the maximum fitness and the average fitness of the updated first target network model; performing mutation operation on the updated first target network model according to the mutation rate, and updating the connection structure of the first target network model again to obtain the second target network model.
[0014] The connection structure of the first target network model is updated again to obtain a second target network model, including: determining the fitness of each network model in the plurality of trained network models; determining the maximum fitness and the average fitness of all the fitnesses; determining the mutation rate based on the first fitness, the maximum fitness and the average fitness of the updated first target network model; performing mutation operation on the updated first target network model according to the mutation rate, and updating the connection structure of the first target network model again to obtain the second target network model.
[0015] The connection structure of the first target network model is updated again to obtain a second target network model, including: determining the fitness of each network model in the plurality of trained network models; determining the maximum fitness and the average fitness of all the fitnesses; determining the mutation rate based on the first fitness, the maximum fitness and the average fitness of the updated first target network model; performing mutation operation on the updated first target network model according to the mutation rate, and updating the connection structure of the first target network model again to obtain the second target network model.
[0016] The connection structure of the first target network model is updated again to obtain a second target network model, including: determining the fitness of each network model in the plurality of trained network models; determining the maximum fitness and the average fitness of all the fitnesses; determining the mutation rate based on the first fitness, the maximum fitness and the average fitness of the updated first target network model; performing mutation operation on the updated first target network model according to the mutation rate, and updating the connection structure of the first target network model again to obtain the second target network model.
[0017] The method further includes:
[0018] After the i-th iteration training, the connection structure of the trained network model is converted into a topological structure diagram; and the topological structure diagram is displayed.
[0019] To solve the above problems, another technical solution adopted by the present application is to provide a network model training device, which comprises a processor and a memory coupled with the processor; wherein the memory is used to store a computer program, and the processor is used to execute the computer program to realize the method provided in the above technical solution.
[0020] To solve the above problems, another technical solution adopted by the present application is to provide a computer readable storage medium for storing a computer program, which, when executed by a processor, is used to realize the method provided in the above technical solution.
[0021] The beneficial effects of the present application are: different from the prior art, the network model training method provided by the present application is used for image processing, and the training method comprises: using training samples to perform multiple iteration training on multiple network models in a network model set until a training stop condition is met; the i-th iteration training in the multiple iteration comprises: using training samples to perform basic training on multiple network models in the network model set to obtain multiple trained network models; wherein i is an integer greater than 1; cross correction is performed on at least two first target network models to obtain a corresponding number of second target network models; the first target network model is a network model in the multiple trained network models; and the network model set is updated using the corresponding number of second target network models. Through the above manner, in each iteration training, the network models are cross corrected between each other, so that the network models can change more and learn the feature information of the remaining network models, which can avoid falling into a local optimal solution in the process of searching the network structure, and further search for a network model with better performance, and one or more network models can be searched, the search efficiency of the network model is improved, and further the accuracy of processing the image based on the trained network model is improved. BRIEF DESCRIPTION OF DRAWINGS
[0022] Figure 1 is a flowchart of the first embodiment of the network model training method provided by the present application;
[0023] Figure 2 is a flowchart of the second embodiment of the network model training method provided by the present application;
[0024] Figure 3 is a structural diagram of a structure block provided by the present application;
[0025] Figure 4 is a flowchart of the third embodiment of the network model training method provided by the present application;
[0026] Figure 5 is a flowchart of an embodiment before step 44 provided by the present application;
[0027] Figure 6 is a flowchart of an embodiment of step 45 provided in the present application;
[0028] Figure 7 is a flowchart of an embodiment of step 453 provided in the present application;
[0029] Figure 8 is a flowchart of a fourth embodiment of the training method of the network model provided in the present application;
[0030] Figure 9 is a structural diagram of an embodiment of the training device provided in the present application;
[0031] Figure 10 is a structural diagram of an embodiment of the computer readable storage medium provided in the present application. DETAILED DESCRIPTION
[0032] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. It can be understood that the specific embodiments described herein are only used to explain the present application, rather than limit the present application. In addition, it should be noted that, for the convenience of description, only the parts related to the present application are shown in the drawings, rather than all the structures. Based on the embodiments in the present application, all the other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0033] The terms "first", "second", and the like in the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to the process, method, product or device.
[0034] In this document, the term "embodiment" means that the specific features, structures or characteristics described in connection with the embodiment can be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor is it independent or alternative to other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0035] Reference Figure 1 , Figure 1 is a flowchart of a first embodiment of the training method of the network model provided in the present application. The training method comprises:
[0036] Step 11: iteratively train the plurality of network models in the set of network models using the training samples until a training stop condition is met.
[0037] The number of iterations can be set in advance, such as 20, 50, or 100.
[0038] The training samples can be image samples or text samples. Each network model in the set of network models is trained using the training samples, and the network parameters of the network model are updated through the training.
[0039] In this embodiment, the network model can be a convolutional neural network structure, a recurrent neural network structure, or an adversarial neural network structure.
[0040] In some embodiments, the structure of the network model can be a linear structure or a nonlinear structure. The linear structure means that the nodes in the network model are connected in sequence. The nonlinear structure means that the nodes are randomly connected.
[0041] Step 12: at each iteration training, the plurality of network models in the set of network models is trained using the training samples to obtain a plurality of trained network models.
[0042] For example, at the i-th iteration training, the plurality of network models in the set of network models is trained using the training samples to obtain a plurality of trained network models. The i is an integer greater than 1.
[0043] The basic training means that the training samples are input into each network model in the set of network models for training. That is, the training samples are input into the network model, and the network model outputs the training results, and the network parameters in the network model are adjusted based on the training results.
[0044] In some embodiments, at each basic training, it is determined whether the training of the network model meets a convergence condition. If it meets, the training of the network model is ended. If it does not meet, step 13 is performed.
[0045] In other embodiments, when the number of iterations is reached, the training of the network model is ended.
[0046] In other embodiments, when the number of iterations is reached, it is determined whether the training of the network model meets a convergence condition. If it meets, the training of the network model is ended. If it does not meet, the number of iterations can be increased, and step 13 is performed again.
[0047] Step 13: cross-correcting at least two first target network models to obtain a corresponding number of second target network models.
[0048] The first target network model is a network model in the plurality of trained network models.
[0049] After each basis training, each network model in the network model set obtains a corresponding confidence, and the at least two first target network models can be determined according to the confidence.
[0050] For example, the first target network model with a confidence less than a preset confidence.
[0051] The at least two determined first target network models are combined, two network models are taken as a group, and the network models in the group are cross-corrected. For example, the network structure is cross-replaced, and after the replacement, a self-variation operation is performed to update the network structure again. Then, the second target network model after correction is obtained.
[0052] Step 14: updating the network model set by using the corresponding number of second target network models.
[0053] The updated network model set can be trained again by using the training sample.
[0054] In an application scenario, the network model set includes a network model A, a network model B, a network model C, a network model D, a network model E, a network model F, a network model G, a network model H, a network model I, and a network model J.
[0055] After the training, the network model E, the network model F, the network model G, the network model H, the network model I and the network model J are determined as the first target network model. Then, two network models are randomly selected from the network model E, the network model F, the network model G, the network model H, the network model I and the network model J, and combined to obtain six groups. For example, the first group includes the network model E and the network model F, the second group includes the network model F and the network model G, the third group includes the network model G and the network model H, the fourth group includes the network model H and the network model I, the fifth group includes the network model I and the network model J, and the sixth group includes the network model E and the network model J. Then, the network models in each group are cross-corrected to obtain the corrected network models. For example, the first group after correction includes the network model E1 and the network model F1, the second group after correction includes the network model F2 and the network model G1, the third group after correction includes the network model G2 and the network model H1, the fourth group after correction includes the network model H2 and the network model I1, the fifth group after correction includes the network model I2 and the network model J1, and the sixth group after correction includes the network model E2 and the network model J2. At this time, any network model can be selected from each group to replace the first target network model, and the network model set is updated. For example, the network model E1, the network model F2, the network model G2, the network model H2, the network model I2 and the network model J2 are selected to replace the first target network model, and the updated network model set is the network model A, the network model B, the network model C, the network model D, the network model E1, the network model F2, the network model G2, the network model H2, the network model I2 and the network model J2.
[0056] In the next training, the network models in the updated network model set are trained.
[0057] The network model trained in the above manner can be used for image processing tasks, such as target detection, target recognition, image classification, action recognition, etc.
[0058] In the embodiment, the multiple network models in the network model set are iteratively trained by using the training samples until the training stop condition is met; the i-th iteration training in the multiple iterations comprises: training the multiple network models in the network model set by using the training samples to obtain multiple trained network models; wherein i is an integer greater than 1; at least two first target network models are cross-corrected to obtain a corresponding number of second target network models; the first target network model is a network model in the multiple trained network models; the network model set is updated by using the corresponding number of second target network models, the network models are cross-corrected, the network models can change more and learn the feature information of the remaining network models, the network model can be searched to a better performance, one or more network models can be searched, the search efficiency of the network model is improved, and the accuracy of processing the image based on the trained network model is improved.
[0059] Referring to Figure 2 , Figure 2 is a flowchart of a second embodiment of a network model training method provided by the present application. The training method comprises:
[0060] Step 21: iteratively training the multiple network models in the network model set by using the training samples until the training stop condition is met.
[0061] In some embodiments, the network model comprises multiple structure blocks, each structure block comprising nodes connected in a target connection mode, wherein the target connection mode comprises a connection mode other than series connection. The target connection mode can be obtained by random binary coding.
[0062] In combination with Figure 3 , the following is explained:
[0063] Figure 3 is a structural diagram of a structure block provided by the present application. The structure block comprises node a, node b, node c, node d and node e.
[0064] Wherein, node a is connected to node b and node d. Node b is connected to node d. Node d is connected to node e. Node c is not connected to any node.
[0065] In other embodiments, the connection relationship between the nodes in the structural block is obtained by binary coding. First, the number of nodes in the structural block is determined, and then the connection probability of each node with other nodes is set. Among them, the connection probability is randomly set, and when the connection probability is greater than the preset connection probability, it is considered that the node is connected with the target node. When the connection probability is less than or equal to the preset connection probability, it is considered that the node is not connected with the target node. According to the connection probability, the connection relationship between the nodes can be determined, and then the connection relationship is coded in binary, for example, the connection between two nodes is represented by 1, and no connection is represented by 0. At this point, the connection structure between the nodes in a structural block is recorded by binary coding. Then, the binary code is parsed, and the nodes in the structural block are connected according to the recorded connection relationship to obtain the node connection structure in the structural block.
[0066] It should be noted that at least one node in the structural block has a unique input, which is the output of the previous structural block, and at least one node has a unique output, which is one of the outputs of the structural block.
[0067] Each structural block in the network model can be constructed according to the above method.
[0068] In other embodiments, a network model with a nonlinear structure can be constructed artificially.
[0069] In some embodiments, the network model is constructed based on a convolutional neural network, and each structural block corresponds to a functional layer, such as an input layer, a hidden layer, and an output layer, wherein the hidden layer includes a convolutional layer, a pooling layer, and a fully connected layer.
[0070] The input layer is used to process multi-dimensional data. Commonly, the input layer of a one-dimensional convolutional neural network receives a one-dimensional or two-dimensional array, wherein the one-dimensional array is usually a time or frequency sample; the two-dimensional array can include multiple channels; the input layer of a two-dimensional convolutional neural network receives a two-dimensional or three-dimensional array; and the input layer of a three-dimensional convolutional neural network receives a four-dimensional array.
[0071] The convolutional layer is used for feature extraction of input data.
[0072] The pooling layer is used for feature selection and information filtering of the output feature map after the convolutional layer performs feature extraction.
[0073] The fully connected layer is used to expand the feature map into a vector and pass it through an activation function.
[0074] For image classification problems, the output layer outputs classification labels using a logistic function or a softmax function. In object recognition problems, the output layer can be designed to output the center coordinates, size, and classification of an object. In image semantic segmentation, the output layer directly outputs the classification results of each pixel.
[0075] Step 22: In each iteration of training, the plurality of network models in the network model set are trained based on the training sample to obtain a plurality of trained network models.
[0076] Step 23: Determine the fitness of each network model in the plurality of trained network models.
[0077] The fitness is used to represent the performance index of the network model, such as accuracy. The fitness is inversely proportional to the loss value, and the higher the fitness, the better the performance of the network model.
[0078] Step 24: Based on the determined fitness, at least two first target network models are determined from the plurality of trained network models.
[0079] In an application scenario, a threshold value can be set to determine the first target network model, such as determining the network model whose fitness is less than the threshold value as the first target network model.
[0080] In another application scenario, all network models in the plurality of trained network models are sorted according to the size of the fitness, and the network model at the target sequence position is determined as the first target network model. For example, all network models in the network model set can be sorted according to the fitness from large to small; and the first target network model with a sequence number greater than a preset sequence number is determined. Alternatively, all network models in the network model set can be sorted according to the fitness from small to large; and the first target network model with a sequence number less than a preset sequence number is determined. For example, the network model set includes network model A, network model B, network model C, network model D, network model E, network model F, network model G, network model H, network model I, and network model J. After training, the network models are sorted according to the fitness from large to small, network model A is 1, network model B is 2, network model C is 3, network model D is 4, network model E is 5, network model F is 6, network model G is 7, network model H is 8, network model I is 9, and network model J is 10. The preset sequence number is 6, and network model G, network model H, network model I, and network model J are the selected first target network models.
[0081] In an application scenario, a setting threshold can be set to determine the first target network model, for example, the network model whose fitness is less than the setting threshold is determined first. Then, all the selected network models are sorted according to the fitness, and the network model at the target sequence position is determined as the first target network model. For example, the first three network models are selected from the ten network models whose fitness is less than the setting threshold as the first target network model.
[0082] Step 25: cross-correcting the at least two first target network models to obtain a corresponding number of second target network models.
[0083] Step 26: replacing the corresponding first target network model in the network model set with each second target network model.
[0084] For example, the corresponding first target network model in the network model set is replaced with each second target network model, so as to complete the updating of the network model.
[0085] In this embodiment, by cross-correcting the network models whose fitness does not meet the requirement, the network models can change more and learn the feature information of the remaining network models, so as to change the connection structure of the network model, and then determine the optimal network model structure through training, so as to avoid falling into a local optimal solution in the process of searching the network structure, and then search for a network model with better performance, and one or more network models can be searched, so as to improve the search efficiency of the network model.
[0086] Referring to Figure 4 , Figure 4 is a flowchart of a second embodiment of the network model training method provided by the present application. The training method comprises:
[0087] Step 41: performing multiple iteration training on the multiple network models in the network model set by using the training sample until the training stop condition is met.
[0088] Each network model is a randomly constructed network model with a nonlinear structure.
[0089] Step 42: performing basic training on the multiple network models in the network model set by using the training sample to obtain multiple trained network models during each iteration training.
[0090] Step 43: determining at least two first target network models from the multiple trained network models.
[0091] Steps 41-43 have the same or similar technical solutions as any of the above embodiments, which will not be repeated here.
[0092] Step 44: cross every two first target network models to update the connection structure of each first target network model.
[0093] The two first target network models that need to be crossed can be determined according to the technical solutions of the above embodiments, which will not be described here.
[0094] In some embodiments, referring to Figure 5 Before step 44, the following process is performed:
[0095] Step 51: determine the fitness of each network model in the plurality of trained network models; and determine the maximum fitness and the average fitness of all fitnesses.
[0096] After each network model is trained, the corresponding fitness can be calculated.
[0097] Step 52: determine the greater fitness of each two first target network models as the target fitness.
[0098] Step 53: determine the crossover rate using the target fitness, the maximum fitness and the average fitness.
[0099] For example, when the target fitness is greater than or equal to the average fitness, a first fitness difference value is obtained by subtracting the target fitness from the maximum fitness, and a second fitness difference value is obtained by subtracting the average fitness from the maximum fitness, a first ratio is obtained by dividing the first fitness difference value by the second fitness difference value, and the first ratio is taken as the crossover rate.
[0100] When the target fitness is less than the average fitness, a preset crossover rate is directly obtained. The preset crossover rate is greater than the first ratio.
[0101] In an application scenario, the crossover rate can be represented by the following formula:
[0102]
[0103] Where P represents the crossover rate, f represents the maximum fitness, f' represents the target fitness, f represents the average fitness, and k represents the preset crossover rate. c max avg c
[0104] After the crossover rate is determined, step 44 can be performed according to the crossover rate to cross every two first target network models.
[0105] The crossover rate refers to the probability of crossing of two first target network models. The higher the value of the crossover rate, the greater the probability of crossing operation.
[0106] In the cross operation, it can be single-point cross, two-point cross or random cross. Single-point cross is to randomly set a starting point of cross, and the part from the starting point to the end of the code is crossed. Two-point cross is to randomly set a starting point and an ending point. Multi-point cross randomly sets multiple starting points and ending points. A cross method is randomly selected to cross the two first target network models.
[0107] Step 45: performing mutation operation on the updated first target network model, updating the connection structure of the first target network model again to obtain a second target network model.
[0108] Referring to Figure 6 , step 45 can be the following flow:
[0109] Step 451: determining the fitness of each network model in the plurality of trained network models; and determining the maximum fitness and the average fitness of all fitnesses.
[0110] Step 442: determining the mutation rate by using the first fitness, the maximum fitness and the average fitness of the updated first target network model.
[0111] For example, when the first fitness is greater than or equal to the average fitness, a third fitness difference value is obtained by subtracting the first fitness from the maximum fitness, a fourth fitness difference value is obtained by subtracting the average fitness from the maximum fitness, a second ratio is obtained by dividing the third fitness difference value by the fourth fitness difference value, and the second ratio is taken as the mutation rate.
[0112] When the first fitness is less than the average fitness, a preset mutation rate is directly obtained. The preset mutation rate is greater than the second ratio.
[0113] In an application scenario, the mutation rate can be represented by the following formula:
[0114]
[0115] Wherein, P m represents the mutation rate, f max represents the maximum fitness, f represents the first fitness, f avg represents the average fitness, and k m represents the preset mutation rate.
[0116] Wherein, if the first target network model has not been subjected to cross operation, the first fitness corresponds to the fitness before the update.
[0117] Step 453: performing mutation operation on the updated first target network model according to the mutation rate, updating the connection structure of the first target network model again to obtain a second target network model.
[0118] In the above process, the automatic adjustment of the crossover rate and the mutation rate according to the fitness of the network model can avoid the search process of the network structure from falling into a local optimal solution, and further search a network model with better performance.
[0119] Referring to Figure 7 , step 453 can be the following flow:
[0120] Step 4531: Determine the second fitness of the first target network model after the mutation operation.
[0121] Step 4532: If the second fitness is greater than the first fitness, determine the first target network model after the mutation operation as the second target network model.
[0122] If the second fitness is greater than the first fitness, it indicates that the performance of the first target network model after mutation is improved, and the first target network model after mutation is determined as the second target network model.
[0123] Step 4533: If the second fitness is less than or equal to the first fitness, determine the annealing probability of the first target network model after the mutation operation.
[0124] If the second fitness is greater than the first fitness, it indicates that the performance of the first target network model after mutation is weakened, and it is necessary to further determine whether the first target network model after mutation needs to be determined as the second target network model.
[0125] Wherein, the annealing probability of the first target network model after the mutation operation can be determined by determining the first difference value between the second fitness and the first fitness; and the second difference value between the maximum fitness and the average fitness; the annealing probability is obtained by using the first difference value and the second difference value.
[0126] Wherein, the following formula is used to represent:
[0127]
[0128] Wherein, P(dE) represents the annealing probability, dE represents the first difference value, k represents a constant, and T represents the second difference value.
[0129] Step 4534: Determine whether the first target network model after the mutation operation is determined as the second target network model based on the annealing probability.
[0130] Specifically, if the annealing probability is greater than the preset annealing probability, the first target network model after the mutation operation is determined as the second target network model.
[0131] If the annealing probability is less than or equal to the preset annealing probability, the first target network model before the mutation operation is determined as the second target network model.
[0132] Through the setting of the annealing probability, the training of the network model can jump out of the local optimal solution, and the network structure of the network model is further increased, more network structures can be searched, the search range of the network parameters of the network model in the training process is increased, and the network model can converge to the global optimal solution.
[0133] Step 46: replacing the first target network model with the second target network model to update the network model set.
[0134] A second target network model is randomly selected to replace the first target network model to update the network model set.
[0135] In this embodiment, through the setting of the annealing probability, the training of the network model can jump out of the local optimal solution, and the network structure of the network model is further increased, more network structures can be searched, the search range of the network parameters of the network model in the training process is increased, and the network model can converge to the global optimal solution.
[0136] In other embodiments, refer to Figure 8 After each iteration training, the following process can be performed:
[0137] Step 81: converting the connection structure of the trained network model into a topological structure diagram after each iteration training.
[0138] Step 82: displaying the topological structure diagram.
[0139] In some embodiments, the topological structure diagrams corresponding to all network models can be displayed to enable the user to intuitively understand the change of the network structure in the training process of the network model.
[0140] In some embodiments, the topological structure diagrams can be selectively displayed according to the fitness. For example, the topological structure diagram corresponding to the network model with a fitness greater than a preset fitness is displayed to enable the user to intuitively understand the change of the network structure in the training process of the network model.
[0141] In an application scenario, the present application can have the following process:
[0142] First, the training sample, the number of iterations, the network model with a plurality of nonlinear structures randomly generated, the network model set composed of the network model, the number of optimal network models reserved after each iteration, the preset crossover rate, the crossover mode, and the preset mutation rate are determined.
[0143] Then, at the iteration number 0, each network model in the network model set is trained using the BP algorithm, and after the end of the current iteration training, the loss value and fitness of each network model are calculated. The fitness can be an index that the network model needs to achieve for a specific task, such as accuracy.
[0144] The network model can be a convolutional neural network structure. The structure can include M normal structure blocks, each structure block has N nodes, each node includes an input and an output port, and each node has three to four network layers. M and N are positive integers.
[0145] The three network layers are convolutional layers, batch normalization layers, and activation layers, and the fourth is a dropout layer. The order of the network layers in the node is random, and the connection mode between the network layers is sequentially connected according to the arrangement order. The size and number of the convolutional kernels in each node are the same. The output of each node can be used as the input of other nodes to establish a one-way connection. Each node can have multiple inputs and outputs. The output of the upper structure block can be used as the input of any node in the lower structure block, and the output of any node in the structure block can be used as one of the outputs of the structure block. The output of the structure block is the sum of the outputs of one or more nodes in the structure block. The input of at least one node in the structure block is unique and must be the output of the upper structure block, and the output of at least one node is unique and must be one of the outputs of the structure block. The connection between two nodes is represented by 1, and no connection is represented by 0.
[0146] According to this method of encoding, the non-linear connection mode of the nodes in a structure block is represented by a binary number. Each network consists of M such binary numbers to form a complete code. The network structure of each network model is randomly initialized as a string of binary numbers, and then compiled into a specific convolutional neural network structure through the network structure encoding method.
[0147] The network model in the network model set is used as the individual of each iteration.
[0148] For each generation of population t = 1, 2, 3, …, T, selection, crossover, mutation and other evolutionary operations are performed in turn:
[0149] The t-1 generation optimal m individuals are reserved to the t generation according to the fitness, and the remaining N-m individuals are selected from the t-1 generation gene pool by the tournament selection method. Each time a pair of parents is selected, a total of N-m pairs of parents are selected. If the fitness is greater than the preset fitness, it is reserved, and the rest participate in subsequent crossover correction.
[0150] Each selected pair of parents has a probability P cThe crossover operation is performed, and the crossover mode is randomly selected to obtain two offspring individuals. Each individual obtained by the crossover is subjected to the mutation operation at a mutation rate, and then one individual is randomly selected as an individual of the t-th generation population.
[0151] The crossover mode can be single-point crossover, two-point crossover, or random crossover. Single-point crossover is to randomly set a starting point of the crossover, and the part from the starting point to the end of the code is subjected to the crossover. Two-point crossover is to randomly set a starting point and an ending point. Multi-point crossover randomly sets multiple starting points and ending points. The number and position of the starting points and the ending points of the crossover are also set as random values.
[0152] The individual with high fitness is given a lower crossover rate and mutation rate, which is beneficial to the preservation of good genes; and the individual with low fitness is given a higher crossover rate and mutation rate, which is beneficial to the change of poor genes. Specifically, the formula is as follows:
[0153]
[0154]
[0155] wherein f max represents the maximum fitness of the individuals in the population, i.e., the maximum fitness in the above embodiment, f avg represents the average fitness of the population, i.e., the average fitness in the above embodiment, and f' is the fitness value of the individual with higher fitness among the two individuals to be crossed, i.e., the target fitness in the above embodiment. At the same time, whether the individual is mutated is improved using the simulated annealing algorithm. Let the fitness of the individual before mutation be f1, the fitness after mutation be f2, and the energy difference be dE = f2-f1, i.e., the first difference value in the above embodiment, and the temperature T = f max -f avg , i.e., the second difference value in the above embodiment. According to the simulated annealing algorithm, if f2 > f1, the individual after mutation is supported to become an individual of the next generation population; and if f2≤f1, whether to accept the mutation is determined according to the annealing probability , wherein k is a constant.
[0156] After training, the loss value and the fitness of each individual in the t-th generation population are calculated.
[0157] The binary code of each individual is output, and the corresponding network structure is output in the form of a topology diagram.
[0158] Each iteration training is performed in the above manner, and the preset number of iterations is executed to obtain a plurality of network models of nonlinear structures trained finally.
[0159] In the iteration process, the network model needing cross correction can be re-determined by changing the preset fitness in each iteration. The preset fitness can be adaptively increased according to the number of iterations.
[0160] At this time, the user can select a corresponding network model for subsequent application according to actual needs. For example, one of the network models is selected for image recognition.
[0161] Referring to Figure 9 , Figure 9 is a structural schematic diagram of an embodiment of a training device for a network model provided by the present application. The training device 90 comprises a processor 91 and a memory 92 coupled with the processor 91; the memory 92 is used to store a computer program, and the processor 91 is used to execute the computer program to implement the following method:
[0162] The multiple network models in the network model set are trained multiple times by using the training samples; the i th iteration training in the multiple iterations comprises: the multiple network models in the network model set are trained by using the training samples to obtain multiple trained network models; wherein 2≤i≤n, n represents the number of iteration training; at least two first target network models are determined from the multiple trained network models; the at least two first target network models are cross corrected to obtain a corresponding number of second target network models; the first target network models are replaced by using the second target network models to update the network model set.
[0163] It can be understood that the processor 91 is also used to execute the computer program to implement the method of any of the above embodiments. For details, refer to any of the above embodiments, which will not be repeated here.
[0164] Referring to Figure 10 , Figure 10 is a structural schematic diagram of an embodiment of a computer readable storage medium provided by the present application. The computer readable storage medium 100 is used to store a computer program 101, and the computer program 101, when executed by a processor, is used to implement the following method:
[0165] The multiple network models in the network model set are trained multiple times by using the training samples; the i th iteration training in the multiple iterations comprises: the multiple network models in the network model set are trained by using the training samples to obtain multiple trained network models; wherein 2≤i≤n, n represents the number of iteration training; at least two first target network models are determined from the multiple trained network models; the at least two first target network models are cross corrected to obtain a corresponding number of second target network models; the first target network models are replaced by using the second target network models to update the network model set.
[0166] It can be understood that the computer program 101, when executed by the processor, is also used to implement the method of any of the above embodiments. For details, refer to any of the above embodiments, which will not be repeated here.
[0167] To sum up, the training method of the network model provided in the present application comprises: performing multiple iteration training on multiple network models in the network model set by using training samples; the i-th iteration training in the multiple iteration training comprises: performing basic training on the multiple network models in the network model set by using the training samples to obtain multiple trained network models; wherein 2≤i≤n, n represents the number of iteration training; at least two first target network models are determined from the multiple trained network models; the at least two first target network models are cross-corrected to obtain a corresponding number of second target network models; the first target network models are replaced by using the second target network models to update the network model set. In the above manner, on the one hand, the network model of the nonlinear structure is trained, which can reduce the problem of gradient disappearance in the training process, and on the other hand, through cross-correction between network models, the network model can change more and learn the feature information of the remaining network models, which can avoid the network model from falling into a local optimal solution in the training process, and further improve the network performance of the trained network model.
[0168] Further, a more complex connection mode is introduced between network layers, the diversity of the network structure of the network model is increased, and the ability to search for a global optimal network model is enhanced to avoid falling into a local optimal solution. In addition, a visual output is performed to avoid black-boxing of the search process.
[0169] Therefore, according to the training method of any of the above embodiments of the present application, the final network model searched has better performance.
[0170] In the several embodiments provided in the present application, it should be understood that the disclosed method and device can be implemented in other ways. For example, the device embodiments described above are only schematic. The division of the modules or units is only a logical function division, and there can be another division manner in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0171] The units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, i.e. they can be located in one place, or distributed on a plurality of network units. According to actual needs, part or all of the units can be selected to achieve the purpose of the present embodiment scheme.
[0172] In addition, each function unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit.
[0173] The integrated unit in the other embodiments described above, if realized in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such an understanding, the technical solutions of the present application, essentially or in other words, the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0174] The above description is only the embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent flow transformation, or direct or indirect application in other related technical fields, is also included in the patent protection scope of the present application.
Claims
1. A method for training a network model, characterized in that, The network model is used for image processing, and the training method includes: The training samples are used to iterate and train multiple network models in the network model set until the training stopping condition is met. The i-th iteration of training in the multiple iterations includes: The training samples are used to perform basic training on multiple network models in the network model set to obtain multiple trained network models; wherein, i is an integer greater than 1; Each pair of first target network models is cross-operated to update the connection structure of each first target network model; the first target network model is a network model among the plurality of trained network models. The updated first target network model is mutated, and the connection structure of the first target network model is updated again to obtain the second target network model. The network model set is updated using the corresponding number of second target network models.
2. The method according to claim 1, characterized in that, The step of updating the network model set using the corresponding number of second target network models includes: The first target network model in the set of network models is replaced by each of the second target network models.
3. The method according to claim 1, characterized in that, The network model includes multiple structural blocks, each of which includes nodes connected according to a target connection method, wherein the target connection method includes connection methods other than serial connection.
4. The method according to claim 1, characterized in that, Before performing the cross operation on every two first target network models and updating the connection structure of each first target network model, the method further includes: Determine the fitness of each of the multiple trained network models; Based on the determined fitness values, at least two of the first target network models are determined from the plurality of trained network models.
5. The method according to claim 4, characterized in that, The determination of at least two first target network models from the plurality of trained network models based on the determined fitness values includes: The trained network model with a fitness value less than a set threshold is identified as the first target network model; and / or, According to the fitness value, all network models among the plurality of trained network models are sorted, and the network model sorted at the target sequence position is determined as the first target network model.
6. The method according to claim 1, characterized in that, Before performing the cross operation on every two first target network models, the following is included: Determine the fitness of each of the plurality of trained network models; and determine the maximum fitness among all fitness values and the average fitness among all fitness values. The larger fitness among the fitness of each pair of first-target network models is determined as the target fitness; The crossover rate is determined using the target fitness, the maximum fitness, and the average fitness. The step of performing a cross operation on every two first target network models includes: The first target network models are cross-operated according to the stated cross-operation rate.
7. The method according to claim 1, characterized in that, The step of performing a mutation operation on the updated first target network model to update the connection structure of the first target network model again, thereby obtaining the second target network model, includes: Determine the fitness of each of the plurality of trained network models; and determine the maximum fitness among all fitness values and the average fitness among all fitness values. The mutation rate is determined using the first fitness, the maximum fitness, and the average fitness of the updated first target network model; The updated first target network model is mutated according to the mutation rate, and the connection structure of the first target network model is updated again to obtain the second target network model.
8. The method according to claim 7, characterized in that, The step of performing a mutation operation on the updated first target network model according to the mutation rate, and then updating the connection structure of the first target network model again to obtain the second target network model includes: Determine the second fitness of the first target network model after the mutation operation; If the second fitness is greater than the first fitness, the first target network model after the mutation operation is determined as the second target network model; If the second fitness is less than or equal to the first fitness, then determine the annealing probability of the first target network model after the mutation operation; Based on the annealing probability, determine whether to identify the first target network model after the mutation operation as the second target network model.
9. The method according to claim 8, characterized in that, The determination of the annealing probability of the first target network model after the mutation operation includes: Determine a first difference between the second fitness and the first fitness; and a second difference between the maximum fitness and the average fitness; The annealing probability is obtained using the first difference and the second difference. The step of determining whether to identify the first target network model after mutation as the second target network model based on the annealing probability includes: If the annealing probability is greater than the preset annealing probability, then the first target network model after the mutation operation is determined as the second target network model; If the annealing probability is less than or equal to the preset annealing probability, then the first target network model before the mutation operation is determined as the second target network model.
10. The method according to claim 1, characterized in that, The step of replacing the first target network model with the second target network model to update the network model set includes: Randomly select a second target network model to replace the first target network model, and update the network model set.
11. The method according to claim 1, characterized in that, The method further includes: After the i-th iteration of training, the connection structure of the trained network model is transformed into a topology graph. The topology diagram is shown.
12. A training device for a network model, characterized in that, The training device includes a processor and a memory coupled to the processor; The memory is used to store a computer program, and the processor is used to execute the computer program to implement the method as described in any one of claims 1-11.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program, which, when executed by a processor, is used to implement the method as described in any one of claims 1-11.
Citation Information
Patent Citations
Urban water supply scheduling method and system based on BP neural network
CN110400234A
Early gastric cancer image recognition method based on evolutionary neural network model compression
CN112580639A