A neural network training method, device, electronic device and storage medium
By using a bidirectional coupled network structure and multiple channel number configuration schemes during the training of neural networks, the problem of how to find a suitable channel number configuration scheme to balance the accuracy and operation speed of neural networks is solved, and higher accuracy and efficiency are achieved.
Patent Information
- Application Number
- CN202010882930.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-28
- Publication Date
- 2025-06-06
- Estimated Expiration
- 2040-08-28
AI Technical Summary
During the training of neural networks, how to find a suitable number of channels configuration scheme to balance the accuracy and running speed of neural networks?
By acquiring the training image set and the preset multiple network channel configuration schemes, the bidirectional coupled network structure formed by the processing channel participating in the processing under each configuration scheme is determined. Then, the bidirectional coupled network structure under each configuration scheme is trained based on the training image set to ensure that the network parameters of the processing channel are updated the same number of times, thereby improving the accuracy of the network parameter values.
It improves the accuracy of the neural network when selecting a network channel configuration scheme with the accuracy and operating speed that meets the requirements, and ensures the accuracy of the network parameter values of the neural network.
Smart Images

Figure CN111985645B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer application technology, and in particular to a neural network training method, device, electronic device and storage medium. Background Art
[0002] With the development of artificial intelligence, neural networks are gradually applied to various fields, such as image classification, image segmentation, target tracking and detection, etc. Taking image classification as an example, a neural network can be pre-trained to obtain a neural network that can recognize the categories corresponding to the target objects contained in the image.
[0003] A neural network may specifically include multiple convolutional layers, each of which includes multiple channels. The number of channels directly affects the number of parameters to be trained in the neural network. The more parameters to be trained, the higher the accuracy of the neural network, but the lower the running speed.
[0004] Therefore, when training a neural network, how to obtain a suitable channel number configuration scheme is an urgent problem to be solved. Summary of the invention
[0005] The disclosed embodiments at least provide a training scheme for a neural network.
[0006] In a first aspect, an embodiment of the present disclosure provides a neural network training method, comprising:
[0007] A training image set and a plurality of pre-set network channel number configuration schemes are obtained; based on each network channel number configuration scheme, a bidirectional coupling network structure consisting of processing channels involved in processing of a neural network to be trained under the network channel number configuration scheme is determined; the bidirectional coupling network structure comprises a pair of network structures consisting of a network structure having a forward channel sequence and a network structure having a reverse channel sequence, and the forward channel sequence and the reverse channel sequence of the same convolutional layer of the neural network to be trained contain the same number of processing channels; based on the training image set, a network of the bidirectional coupling network structure corresponding to the neural network to be trained under each network channel number configuration scheme is trained to obtain a trained neural network.
[0008] In the disclosed embodiment, firstly, based on a plurality of pre-set network channel number configuration schemes, a bidirectional coupling network structure consisting of processing channels involved in processing of the neural network to be trained under each network channel number configuration scheme is determined, so that when the network parameters of the processing channels involved in processing corresponding to each network channel number configuration scheme are trained and updated, if the neural network to be trained is trained respectively according to the network structure of the forward channel sequence and the network structure of the reverse channel sequence corresponding to the network channel number configuration scheme, the network parameters of the processing channels included in the neural network to be trained can be updated the same number of times, so that the accuracy of the network parameter values of the neural network obtained is higher, that is, the accuracy of the neural network in selecting the network channel number configuration scheme that meets the requirements of accuracy and running speed is improved.
[0009] In one embodiment, after obtaining the trained neural network, the training method further includes:
[0010] Based on a pre-acquired verification image set and network parameter values of processing channels involved in processing of the trained neural network under each of a plurality of predetermined candidate network channel number configuration schemes, determine the accuracy of the network of the bidirectional coupling network structure corresponding to the trained neural network under the candidate network channel number configuration scheme; based on the running speed and accuracy of the network of the bidirectional coupling network structure corresponding to the trained neural network under each of the candidate network channel number configuration schemes, determine a target network channel number configuration scheme that meets preset conditions; determine a target neural network to be trained based on the processing channels involved in processing included in the neural network to be trained under the target network channel number configuration scheme; and train the target neural network to be trained using the training image set to obtain a target neural network.
[0011] In the disclosed embodiment, after obtaining a trained neural network, a target network channel number configuration scheme that meets the requirements of accuracy and running speed can be quickly selected based on the trained neural network. It is further proposed to retrain the target neural network to be trained determined based on the target network channel number configuration scheme based on a training image set, so as to obtain a target neural network with higher accuracy.
[0012] In a possible implementation, the target neural network is a classification network. After obtaining the target neural network, the training method further includes:
[0013] Acquire a target image; input the target image into the target neural network, and the target neural network outputs the object category in the target image.
[0014] In the disclosed embodiment, the target neural network is trained based on a target network channel number configuration scheme whose running speed and accuracy meet preset conditions. When the target image is classified based on the target neural network, the classification speed and accuracy can also meet the preset conditions.
[0015] In a possible implementation, the multiple network channel number configuration schemes include multiple pairs of complementary network channel number configuration schemes; wherein the sum of the number of processing channels included in each pair of the complementary network channel number configuration schemes in the same convolutional layer is equal to the total number of channels included in the convolutional layer.
[0016] In the disclosed embodiment, when the pre-set multiple network channel number configuration schemes include multiple pairs of complementary network channel number configuration schemes, the network parameters of the channels in each convolutional layer of the neural network to be trained can be trained the same number of times, thereby further improving the accuracy of the trained neural network when evaluating the accuracy corresponding to each candidate network channel number configuration scheme.
[0017] In a possible implementation, the training image set includes a plurality of groups of training images, and the training of the network of the bidirectional coupling network structure corresponding to each network channel number configuration scheme of the neural network to be trained based on the training image set to obtain a trained neural network includes:
[0018] For the current network channel number configuration scheme, a group of training images are input into the network of the bidirectional coupling network structure corresponding to the current network channel number configuration scheme for training the neural network to be trained, and the loss value of the network of the bidirectional coupling network structure corresponding to the neural network to be trained under the current network channel number configuration scheme is obtained; based on the loss value, the current network parameter values of the processing channels in which the neural network to be trained participates in the processing under the current network channel number configuration scheme are adjusted to obtain the adjusted network parameter values; the next network channel number configuration scheme is selected as the current network channel number configuration scheme, and the step of inputting a group of training images into the network of the bidirectional coupling network structure corresponding to the neural network to be trained under the current network channel number configuration scheme is returned to, until the adjusted network parameter values corresponding to the processing channels in which the neural network to be trained participates in the processing under the last network channel number configuration scheme are obtained, and a trained neural network is obtained.
[0019] In the disclosed embodiment, by training the network of the bidirectional coupling network structure corresponding to the neural network to be trained under different network channel number configuration schemes, and updating the network parameter values of the processing channel according to the loss value obtained in each training, the network parameter values of each processing channel included in the neural network to be trained can be updated multiple times in this way, thereby obtaining a neural network for accurately evaluating the accuracy of the network structure corresponding to various candidate network channel number configuration schemes.
[0020] In a possible implementation manner, inputting a set of training images into a network of a bidirectionally coupled network structure corresponding to the current network channel number configuration scheme for training the neural network to be trained, and obtaining a loss value of the network of a bidirectionally coupled network structure corresponding to the neural network to be trained under the current network channel number configuration scheme, comprises:
[0021] A group of training images are input into the network with a network structure having a forward channel sequence corresponding to the neural network to be trained under the current network channel number configuration scheme to obtain a first loss value corresponding to the neural network to be trained, and the group of training images are input into the network with a network structure having a reverse channel sequence corresponding to the neural network to be trained under the current network channel number configuration scheme to obtain a second loss value corresponding to the neural network to be trained; and an average value of the first loss value and the second loss value is used as the loss value of the network with a bidirectional coupling network structure corresponding to the neural network to be trained under the current network channel number configuration scheme.
[0022] In a possible implementation manner, the multiple candidate network channel number configuration schemes are determined in the following manner:
[0023] Based on the loss value of the network of the bidirectional coupled network structure corresponding to each of the multiple network channel number configuration schemes of the neural network to be trained, the multiple candidate network channel number configuration schemes are determined; based on the running speed and accuracy of the network of the bidirectional coupled network structure corresponding to each of the candidate network channel number configuration schemes of the trained neural network, a target network channel number configuration scheme that meets preset conditions is determined, including: selecting a network with a running speed greater than or equal to a set speed threshold and the highest accuracy from the networks of the bidirectional network structure corresponding to the trained neural network under the multiple candidate network channel number configuration schemes; and using the candidate network channel number configuration scheme corresponding to the screened network as the target network channel number configuration scheme.
[0024] In the embodiments of the present disclosure, on the one hand, multiple candidate network channel number configuration schemes with smaller corresponding loss values can be obtained, thereby facilitating the selection of a target network channel number configuration scheme with higher accuracy from multiple candidate network channel number configuration schemes; on the other hand, when selecting the target network channel number configuration scheme, the operating speed and accuracy are comprehensively considered, thereby obtaining a target network channel number configuration scheme that takes both operating speed and accuracy into consideration.
[0025] In a possible implementation, determining the multiple candidate network channel number configuration schemes based on the loss value of the network of the bidirectional coupling network structure corresponding to each network channel number configuration scheme of the neural network to be trained in the multiple network channel number configuration schemes includes:
[0026] After sorting the loss values of the network of the bidirectional coupled network structure corresponding to the neural network to be trained under each network channel number configuration scheme in ascending order, obtain the network channel number configuration scheme corresponding to the loss value of the set number before sorting; based on the loss value of the set number before sorting, determine the probability value of the different numbers of processing channels contained in each convolution layer in the target neural network to be trained; based on multiple groups of random arrays generated in advance and the probability values of the different numbers of processing channels, determine the primary network channel number configuration scheme; each group of random arrays contains random numbers for each convolution layer; based on the primary network channel number configuration scheme and the genetic algorithm, determine the multiple candidate network channel number configuration schemes.
[0027] In the disclosed embodiment, when using a genetic algorithm, a primary network channel number configuration scheme suitable as a first-generation parent node of the genetic algorithm is selected based on the loss value of the network of the bidirectionally coupled network structure corresponding to the neural network to be trained under each network channel number configuration scheme, thereby improving the accuracy of determining candidate network channel number configuration schemes based on the genetic algorithm.
[0028] In a possible implementation, the determining of the primary network channel number configuration scheme based on the pre-generated multiple random arrays and the probability values of the different numbers of processing channels includes:
[0029] For each convolution layer corresponding to any random array, the number of processing channels included in the convolution layer is determined based on the random number corresponding to the convolution layer in the random array and the probability value of the different numbers of processing channels included in the convolution layer; based on the obtained number of processing channels included in each convolution layer, the primary network channel number configuration scheme corresponding to the random array is determined.
[0030] In a possible implementation manner, the determining the multiple candidate network channel number configuration schemes based on the primary network channel number configuration scheme and a genetic algorithm includes:
[0031] The primary network channel number configuration scheme is used as the parent node of the genetic algorithm, and the accuracy corresponding to each parent node is determined based on the network parameter values of the processing channels contained in the trained neural network under each parent node, and the network of the bidirectional coupling network structure composed of the processing channels contained under the parent node; based on the accuracy corresponding to each parent node, the primary network channel number configuration scheme as the next generation parent node of the genetic algorithm is determined, until a preset number of cycles is reached, and each generation of primary network channel number configuration schemes is used as the multiple candidate network channel number configuration schemes.
[0032] In a possible implementation, selecting a network having a running speed greater than or equal to a set speed threshold and the highest accuracy from the networks of the bidirectionally coupled network structure corresponding to the multiple candidate network channel number configuration schemes from the trained neural network includes:
[0033] Based on the running speed of the network of the bidirectional coupled network structure corresponding to the trained neural network under each candidate network channel number configuration scheme, a network whose running speed is greater than or equal to the set speed threshold is determined; from the determined networks, the network with the highest accuracy is selected as the screened network.
[0034] In the disclosed embodiment, based on the running speed of the network of the bidirectional coupled network structure corresponding to the trained neural network under each candidate network channel number configuration scheme, the network whose running speed is greater than or equal to the set speed threshold can be screened out. In this way, the range of candidate network channel number configuration schemes can be narrowed, so as to facilitate the rapid determination of the target network channel number configuration scheme.
[0035] In a second aspect, an embodiment of the present disclosure provides a neural network training device, comprising:
[0036] An acquisition module is used to acquire a training image set and a plurality of pre-set network channel number configuration schemes; a determination module is used to determine, based on each network channel number configuration scheme, a bidirectional coupling network structure composed of processing channels involved in processing of a neural network to be trained under the network channel number configuration scheme; the bidirectional coupling network structure includes a pair of network structures composed of a network structure with a forward channel sequence and a network structure with a reverse channel sequence, and the forward channel sequence and the reverse channel sequence of the same convolutional layer of the neural network to be trained contain the same number of processing channels; a training module is used to train the network of the bidirectional coupling network structure corresponding to the neural network to be trained under each network channel number configuration scheme based on the training image set to obtain a trained neural network.
[0037] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the training method described in the first aspect are performed.
[0038] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the training method described in the first aspect are executed.
[0039] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0041] Figure 1 A flowchart of a neural network training method provided by an embodiment of the present disclosure is shown;
[0042] Figure 2a A schematic diagram showing a one-way augmented network structure provided by an embodiment of the present disclosure is shown;
[0043] Figure 2b A schematic diagram showing the number of processing channels included in different network channel number configuration schemes for setting a convolutional layer in the case of a unidirectional convolutional network structure provided by an embodiment of the present disclosure;
[0044] Figure 3a A schematic diagram of a bidirectional coupling network structure provided by an embodiment of the present disclosure is shown;
[0045] Figure 3b A schematic diagram showing a method of setting the number of processing channels of a convolutional layer under different network channel number configuration schemes in the case of a bidirectional coupling network structure provided by an embodiment of the present disclosure;
[0046] Figure 4A flowchart of another neural network training method provided by an embodiment of the present disclosure is shown;
[0047] Figure 5 A schematic diagram showing, in the case of a bidirectional coupling network structure provided by an embodiment of the present disclosure, setting the number of processing channels of a convolutional layer under a complementary network channel number configuration scheme;
[0048] Figure 6 A flowchart of a specific training method for a neural network provided by an embodiment of the present disclosure is shown;
[0049] Figure 7 A flow chart of a method for determining the loss value of a network of a bidirectionally coupled network structure corresponding to a neural network to be trained under a current network channel number configuration scheme provided by an embodiment of the present disclosure is shown;
[0050] Figure 8 A flow chart of a method for determining multiple candidate network channel number configuration schemes provided by an embodiment of the present disclosure is shown;
[0051] Fig. 9 A schematic diagram of the structure of a neural network training device provided by an embodiment of the present disclosure is shown;
[0052] Fig.10 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0054] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0055] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0056] In recent years, neural networks have been gradually applied to various fields, such as image classification and image segmentation. For neural networks containing multiple convolutional layers, the network channel number configuration scheme of the neural network, that is, the number of processing channels involved in image feature processing contained in each convolutional layer, will directly affect the accuracy and running speed of the neural network. Therefore, it is more important to quickly determine the network channel number configuration scheme that meets the requirements of accuracy and running speed.
[0057] Generally, a neural network can be trained to evaluate the network accuracy and running speed of the network structure corresponding to various network channel number configuration schemes, and the network channel number configuration scheme that meets the requirements of both accuracy and speed can be selected through the neural network. How to provide a training method to improve the accuracy of the neural network in selecting the network channel number configuration scheme that meets the requirements of accuracy and running speed is a technical problem to be solved by the disclosure.
[0058] To this end, an embodiment of the present disclosure provides a neural network training method. First, based on a plurality of pre-set network channel number configuration schemes, a bidirectional coupling network structure consisting of processing channels involved in processing of the neural network to be trained under each network channel number configuration scheme is determined. In this way, when the network parameters of the processing channels involved in processing corresponding to each network channel number configuration scheme are trained and updated, if the neural network to be trained is trained respectively according to the network structure of the forward channel sequence and the network structure of the reverse channel sequence corresponding to the network channel number configuration scheme, the network parameters of the processing channels included in the neural network to be trained can be updated the same number of times, so that the accuracy of the network parameter values of the neural network obtained is higher, that is, the accuracy of the neural network in selecting a network channel number configuration scheme that meets the requirements of accuracy and running speed is improved.
[0059] To facilitate understanding of this embodiment, a neural network training method disclosed in the embodiment of the present disclosure is first introduced in detail. The execution subject of the neural network training method provided in the embodiment of the present disclosure is generally a computer device with certain computing capabilities, and the computer device includes, for example, a terminal device or a server or other processing device. In some possible implementations, the neural network training method can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0060] See also Figure 1 As shown, it is a flowchart of the training method of the neural network provided by the embodiment of the present disclosure, and the training method includes the following S101-S103:
[0061] S101, obtaining a training image set and a plurality of pre-set network channel number configuration schemes.
[0062] Exemplarily, the training image set may include a large number of images used for training. For example, different images may be selected for different application scenarios. For example, when training a neural network for plant classification, the training image set may include a large number of images of plants and corresponding category identifiers.
[0063] Exemplarily, the neural network to be trained may include multiple convolutional layers, each convolutional layer may include multiple numbers of channels, and a variety of different channel number configuration schemes may be set in advance for the number of processing channels involved in the processing contained in each convolutional layer, wherein the processing channels involved in the processing participate in the processing of image features during the training process, and the network parameter values will be updated during the training process.
[0064] Exemplarily, the neural network to be trained includes three convolutional layers, each of which may include 6 channels. For example, a network channel number configuration scheme (2,3,4) indicates that the first convolutional layer includes 2 processing channels, the second convolutional layer includes 3 processing channels, and the third convolutional layer includes 4 processing channels.
[0065] S102, based on each network channel number configuration scheme, determine the bidirectional coupling network structure composed of processing channels involved in the processing of the neural network to be trained under the network channel number configuration scheme; wherein the bidirectional coupling network structure includes a pair of network structures composed of a network structure with a forward channel sequence and a network structure with a reverse channel sequence, and the forward channel sequence and the reverse channel sequence of the same convolutional layer of the neural network to be trained contain the same number of processing channels.
[0066] Before explaining the bidirectional coupling network structure, we first introduce a unidirectional augmented network structure. For the network channel number configuration scheme A, the first convolution layer contains 3 processing channels, the second convolution layer contains 2 processing channels, and the third convolution layer contains 4 processing channels. During training, the corresponding Figure 2aIn the network structure shown, the first convolution layer includes 3 processing channels, including the 1st processing channel, the 2nd processing channel and the 3rd processing channel from left to right, the second convolution layer includes 2 processing channels, including the 1st processing channel and the 2nd processing channel from left to right, and the third convolution layer includes 4 processing channels, including the 1st processing channel to the 4th processing channel from left to right. When the neural network to be trained is trained on the network structure corresponding to the network channel number configuration scheme A, the network parameters of each processing channel in the network channel number configuration scheme A will be updated once. When the next network channel number configuration scheme is changed, if in addition to the processing channels included in the network channel number configuration scheme A, other newly added processing channels are included, then the number of updates of the network parameters of the processing channels included in the network channel number configuration scheme A will be more than the newly added processing channels, that is, when the neural network to be trained is trained through different network channel number configuration schemes based on the unidirectional augmentation network structure, there is a problem of uneven number of network parameter updates for different processing channels.
[0067] For example, Figure 2b As shown in the figure, the processing channels included in the same convolutional layer of the neural network to be trained under 6 different network channel number configuration schemes are shown. For example, Figure 2a In the figure, the processing channels included in the second convolution layer under the six network channel number configuration schemes are as follows: for the first network channel number configuration scheme, the convolution layer includes 1 processing channel, for the second network channel number configuration scheme, the convolution layer includes 2 processing channels, ..., for the sixth network channel number configuration scheme, the convolution layer includes 6 processing channels. In this way, when the network of the one-way augmented network structure corresponding to the six network channel number configuration schemes is trained based on the training image set, from left to right, the number of times the network parameters of the first processing channel are updated is greater than the number of times the network parameters of the second processing channel are updated, the number of times the network parameters of the second processing channel are updated is greater than the number of times the network parameters of the third processing channel are updated, ..., the number of times the network parameters of the fifth processing channel are updated is greater than the number of times the network parameters of the sixth processing channel are updated. It can be seen that when the neural network to be trained is trained based on the one-way augmented network structure, there is a problem of unbalanced number of updates of the network parameters of the processing channels. The evaluator obtained in this way has low accuracy when evaluating different network channel number configuration schemes.
[0068] In the embodiment of the present disclosure, a bidirectional coupling network structure is introduced to solve the above problems. Figure 2aThe network channel number configuration scheme is that the first convolution layer of the neural network to be trained contains 3 processing channels, the second convolution layer contains 2 processing channels, and the third convolution layer contains 4 processing channels. The bidirectional coupling network structure corresponding to the network channel number configuration scheme is Figure 3a In the figure, (a) and (b) are composed, where (a) represents the network structure with a forward channel sequence, and (b) represents the network structure with a reverse channel sequence. The network structure with the forward channel sequence and the network structure with the reverse channel sequence contain the same number of processing channels in the same convolutional layer.
[0069] S103, based on the training image set, a network of a bidirectional coupling network structure corresponding to the neural network to be trained under each network channel number configuration scheme is trained to obtain a trained neural network.
[0070] In the process of training the network of the bidirectional coupling network structure corresponding to each network channel number configuration scheme of the neural network to be trained based on the training image set, the network structure with the forward channel sequence and the network structure with the reverse channel sequence corresponding to the network channel number configuration scheme can be trained respectively based on the network channel number configuration scheme, which can reduce the problem of uneven network parameter update times of each processing channel during the training process, so that the accuracy of the network parameter values of the obtained neural network is higher, that is, the accuracy of the neural network in selecting the network channel number configuration scheme that meets the requirements of accuracy and running speed is improved.
[0071] For example, Figure 3b As shown in FIG. 1 , the forward channel sequence and the reverse channel sequence of one convolution layer of the neural network to be trained under 6 different network channel number configuration schemes are shown. The forward channel sequence of the convolution layer under the first network channel number configuration scheme includes the first processing channel, and the reverse channel sequence under the first network channel number configuration scheme includes the sixth processing channel; the forward channel sequence of the convolution layer under the second network channel number configuration scheme includes the first processing channel and the second processing channel, and the reverse channel sequence under the second network channel number configuration scheme includes the fifth processing channel and the sixth processing channel; …; the convolution layer under the first network channel number configuration scheme includes the first processing channel and the second processing channel, and the reverse channel sequence under the second network channel number configuration scheme includes the fifth processing channel and the sixth processing channel; The forward channel sequence under the six network channel number configuration schemes includes the 1st processing channel to the 6th processing channel, and the reverse channel sequence under the 6th network channel number configuration scheme includes the 6th processing channel to the 1st processing channel. In this way, when the convolution layer is trained based on the network with the corresponding bidirectional coupling network structure under each of the six network channel number configuration schemes, the training image set can be trained respectively according to the network with the network structure of the forward channel sequence and the network with the reverse channel sequence, so that the number of updates of the network parameters of each processing channel is the same. For example, for Figure 3bIn the case of the above, when the network with the bidirectional coupling network structure corresponding to each of the six network channel number configuration schemes is trained based on the training image set, the network parameters of each processing channel in the convolutional layer are updated the same number of times, for example, they can all be updated 7 times.
[0072] According to the above method, after training the network of the bidirectional coupled network structure corresponding to the neural network to be trained under each network channel number configuration scheme, the final network parameter value of the processing channel contained in each convolution layer in the neural network to be trained can be obtained, that is, the trained neural network is obtained. The trained neural network can evaluate the accuracy and running speed of the network structure corresponding to various candidate network channel number configuration schemes through the network parameter values corresponding to the included processing channels, thereby selecting the target network channel number configuration scheme that meets the preset conditions.
[0073] In the disclosed embodiment, firstly, based on a plurality of pre-set network channel number configuration schemes, a bidirectional coupling network structure consisting of processing channels involved in processing of the neural network to be trained under each network channel number configuration scheme is determined, so that when the network parameters of the processing channels involved in processing corresponding to each network channel number configuration scheme are trained and updated, if the neural network to be trained is trained respectively according to the network structure of the forward channel sequence and the network structure of the reverse channel sequence corresponding to the network channel number configuration scheme, the network parameters of the processing channels included in the neural network to be trained can be updated the same number of times, so that the accuracy of the network parameter values of the neural network obtained is higher, that is, the accuracy of the neural network in selecting the network channel number configuration scheme that meets the requirements of accuracy and running speed is improved.
[0074] The above S101 to S103 will be described in detail below in conjunction with specific embodiments.
[0075] With respect to the above S103, after obtaining the pre-trained neural network, as Figure 4 As shown, the training method provided by the embodiment of the present disclosure also includes the following S201 to S204:
[0076] S201, based on a pre-acquired verification image set and network parameter values of processing channels involved in processing of the trained neural network under each of a plurality of predetermined candidate network channel number configuration schemes, determine the accuracy of the network of the bidirectional coupling network structure corresponding to the trained neural network under the candidate network channel number configuration scheme.
[0077] Exemplarily, the validation image set is similar to the training image set mentioned above, and can be used to determine the network accuracy of the network structure of the trained neural network under each candidate network channel number configuration.
[0078] Exemplarily, the predetermined multiple candidate network channel number configuration schemes may be a plurality of pre-set candidate network channel number configuration schemes, or may be a plurality of candidate network channel number configuration schemes determined based on a genetic algorithm. The plurality of candidate network channel number configuration schemes may be the same as or different from the plurality of pre-set network channel number configuration schemes mentioned above for training a neural network, and the specific determination process will be described later.
[0079] For each candidate network channel number configuration scheme, the bidirectional coupling network structure corresponding to the candidate network channel number configuration scheme can be determined in the above manner. For example, for the case where the candidate network channel number configuration scheme is (3, 2, 4), the corresponding bidirectional coupling network structure is as follows: Figure 3a As shown, the verification image set can be input into the trained neural network in the network of the bidirectional coupling network structure corresponding to the candidate network channel number configuration scheme for verification, and the accuracy of the network of the bidirectional coupling network structure corresponding to the trained neural network under the candidate network channel number configuration scheme can be obtained.
[0080] S202, determining a target network channel number configuration scheme that meets preset conditions based on the running speed and accuracy of the network of the bidirectional coupling network structure corresponding to the trained neural network under each candidate network channel number configuration scheme.
[0081] After multiple candidate network channel number configuration schemes are determined, the running speed of the network of the bidirectional coupled network structure corresponding to each candidate network channel number configuration scheme of the trained neural network can be determined according to the ideal running speed corresponding to each candidate network channel number configuration scheme stored in advance, or the training image set can be input into the trained neural network and tested in the network of the bidirectional coupled network structure corresponding to each candidate network channel number configuration scheme to obtain the actual running speed.
[0082] After obtaining the running speed and accuracy corresponding to each candidate network channel number configuration scheme, the target network channel number configuration scheme that meets the requirements for both running speed and accuracy can be screened out. For example, the candidate network channel number configuration schemes whose running speed does not meet the requirements can be filtered out in advance, and then based on the verification image set and the trained neural network, the candidate network channel number configuration scheme with the highest corresponding accuracy can be selected to obtain the target network channel number configuration scheme.
[0083] S203, determining a target neural network to be trained according to the processing channels involved in the processing of the neural network to be trained under the target network channel number configuration scheme.
[0084] For example, if the target network channel number configuration scheme obtained above is (3, 2, 4), it can be obtained that the target neural network to be trained is a network structure in which the first convolution layer contains 3 processing channels, the second convolution layer contains 2 processing channels, and the third convolution layer contains 4 processing channels.
[0085] S204, training the target neural network to be trained using the training image set to obtain the target neural network.
[0086] The network parameter values of the processing channels included in the target neural network to be trained can be the initialized network parameter values. The target neural network to be trained can be further re-trained based on the training image set. Because only the network parameter values of the processing channels included in the target network channel number configuration scheme are trained during the re-training process, a target neural network with higher accuracy can be obtained.
[0087] In the disclosed embodiment, after obtaining a trained neural network, a target network channel number configuration scheme that meets the requirements of accuracy and running speed can be quickly selected based on the trained neural network. It is further proposed to retrain the target neural network to be trained determined based on the target network channel number configuration scheme based on a training image set, so as to obtain a target neural network with higher accuracy.
[0088] In one implementation, the target neural network mentioned in the above manner is a classification network. After obtaining the target neural network, the training method provided by the embodiment of the present disclosure further includes:
[0089] (1) Acquire the target image;
[0090] (2) The target image is input into the target neural network, and the target neural network outputs the object category in the target image.
[0091] Here we only give one application scenario of the target neural network. In addition, when it is applied in different fields, the target neural network for application in different fields can be obtained by replacing the corresponding training image set and verification image set and repeating the above S101 to S103 and S201 to S204. We will not elaborate on this here.
[0092] In the disclosed embodiment, the target neural network is trained based on a target network channel number configuration scheme whose running speed and accuracy meet preset conditions. When the target image is classified based on the target neural network, the classification speed and accuracy can also meet the preset conditions.
[0093] With respect to the aforementioned pre-set multiple network channel number configuration schemes, illustratively, the multiple network channel number configuration schemes include multiple pairs of complementary network channel number configuration schemes;
[0094] The sum of the number of processing channels contained in each pair of complementary network channel number configuration schemes in the same convolutional layer is equal to the total number of channels contained in the convolutional layer.
[0095] For example, the multiple network channel number configuration schemes include 50 types, which can include 25 pairs of complementary network channel number configuration schemes. For example, the first and second types constitute a pair of complementary network channel number configuration schemes, the third and fourth types constitute a pair of complementary network channel number configuration schemes, ..., the 49th and the 50th types constitute a pair of complementary network channel number configuration schemes, and the two complementary network channel number configuration schemes have the same number of processing channels for the same convolutional layer.
[0096] Exemplarily, for example, for the complementary first and second network channel number configuration schemes, if the neural network to be trained contains 3 layers, the total number of channels contained in each convolutional layer is 6, if the number of processing channels of the first convolutional layer is 2 under the first network channel number configuration scheme, then the number of processing channels of the first convolutional layer is 4 under the second network channel number configuration scheme, and the situation of other convolutional layers is similar. In this way, when the neural network to be trained is trained based on each network channel number configuration scheme, the network parameters of the channels contained in each layer of the neural network to be trained can be updated, and the number of updates is the same, so that the neural network to be trained can be trained with higher accuracy.
[0097] For example, to illustrate the above situation, Figure 5 As shown, if each convolution layer of the neural network to be trained contains 6 channels, for example, for the second convolution layer, the first network channel number configuration scheme is the case where the convolution layer contains 1 processing channel, and the second network channel number configuration scheme is a network channel number configuration scheme complementary to the first network channel number configuration scheme, which is the case where the convolution layer contains 5 processing channels. When training based on the bidirectional coupling network structure, it can be seen that the network parameters of each processing channel in the convolution layer are updated twice, and the situations of other convolution layers are similar. It can be seen that when the pre-set multiple network channel number configuration schemes include multiple pairs of complementary network channel number configuration schemes, the network parameters of the channels in each convolution layer of the neural network to be trained can be trained the same number of times, thereby further improving the accuracy of the trained neural network when evaluating the accuracy corresponding to each candidate network channel number configuration scheme.
[0098] In one embodiment, the training image set includes multiple groups of training images. For the above S103, when the network of the bidirectional coupling network structure corresponding to the neural network to be trained under each network channel number configuration scheme is trained based on the training image set to obtain a trained neural network, such as Figure 6 As shown, the following S301 to S303 may be included:
[0099] S301, for the current network channel number configuration scheme, input a set of training images into a network of a bidirectionally coupled network structure corresponding to the neural network to be trained under the current network channel number configuration scheme, and obtain a loss value of the network of a bidirectionally coupled network structure corresponding to the neural network to be trained under the current network channel number configuration scheme;
[0100] S302, adjusting the current network parameter values of the processing channels involved in the processing of the neural network to be trained under the current network channel number configuration scheme based on the loss value to obtain adjusted network parameter values;
[0101] S303, determining whether the currently obtained adjusted network parameter value is the adjusted network parameter value corresponding to the processing channel participating in the processing under the last network channel number configuration scheme; if not, returning to S301; if so, obtaining a trained neural network.
[0102] For example, the training image set is divided into multiple groups of training images, each group of training images corresponds to a training bidirectionally coupled network structure corresponding to a network channel number configuration scheme. When the network of the bidirectionally coupled network structure corresponding to each of the multiple pre-set network channel number configuration schemes is trained in turn, it can be started from the first network channel number configuration scheme, and one of the groups of training images is input into the network of the bidirectionally coupled network structure corresponding to the neural network to be trained under the current network channel number configuration scheme for training, so as to obtain the loss value of the network of the bidirectionally coupled network structure corresponding to the neural network to be trained under the current network channel number configuration scheme.
[0103] Specifically, with respect to the above S301, when a set of training images is input into a network of a bidirectionally coupled network structure corresponding to the neural network to be trained under the current network channel number configuration scheme, and a loss value of a network of a bidirectionally coupled network structure corresponding to the neural network to be trained under the current network channel number configuration scheme is obtained, as follows: Figure 7 As shown, the following S3011 to S3012 may be included:
[0104] S3011, inputting a set of training images into a network having a network structure with a forward channel sequence corresponding to the neural network to be trained under the current network channel number configuration scheme, to obtain a first loss value corresponding to the neural network to be trained, and inputting the set of training images into a network having a network structure with a reverse channel sequence corresponding to the neural network to be trained under the current network channel number configuration scheme, to obtain a second loss value corresponding to the neural network to be trained;
[0105] S3012, taking the average of the first loss value and the second loss value as the loss value of the network of the bidirectional coupling network structure corresponding to the neural network to be trained under the current network channel number configuration scheme.
[0106] For example, for the current network channel number configuration scheme of (3,2,4), as Figure 3a As shown in Figure (a), it is the network structure with a forward channel sequence corresponding to the current network channel number configuration scheme. Figure 3a As shown in Figure (b), the network structure with reverse channel sequence corresponding to the current network channel number configuration scheme is shown in Figure (b). A set of training images is input into the neural network to be trained. Figure 3a The network shown in Figure (a) is trained to obtain the first loss value corresponding to the neural network to be trained. A set of training images is input into the neural network to be trained. Figure 3a The network shown in Figure (b) is trained to obtain a second loss value corresponding to the neural network to be trained, and then the average of the first loss value and the second loss value is used as the loss value of the network of the bidirectional coupling network structure corresponding to the neural network to be trained under the current network channel number configuration scheme, and based on the loss value, the current network parameter values of the processing channels involved in the processing of the neural network to be trained under the current network channel number configuration scheme are adjusted, and the adjusted network parameter values of each processing channel can be used as the network parameter values to be adjusted when the processing channel is used as a processing channel in the next training process.
[0107] For the case where the next network channel number configuration scheme is (3,2,6), the next network channel number configuration scheme can be used as the current network channel number configuration scheme, and then a set of training images is changed to train the network with a bidirectional coupling network structure corresponding to the current network channel number configuration scheme in the above manner. During the training process, the current network parameter value of the processing channel is the network parameter value of the processing channel number adjusted in the most recent training process.
[0108] In the disclosed embodiment, by training the network of the bidirectional coupling network structure corresponding to the neural network to be trained under different network channel number configuration schemes, and updating the network parameter values of the processing channel according to the loss value obtained in each training, the network parameter values of each processing channel included in the neural network to be trained can be updated multiple times in this way, thereby obtaining a neural network for accurately evaluating the accuracy of the network structure corresponding to various candidate network channel number configuration schemes.
[0109] With respect to the multiple predetermined candidate network channel number configuration schemes mentioned in S201 above, in one implementation manner, the embodiment of the present disclosure determines the multiple candidate network channel number configuration schemes in the following manner:
[0110] Based on the loss value of the network of the bidirectionally coupled network structure corresponding to each of the multiple network channel number configuration schemes among the preset multiple network channel number configuration schemes for the neural network to be trained, multiple candidate network channel number configuration schemes are determined.
[0111] In the above process of training the neural network, the accuracy of the network channel number configuration scheme is higher when the corresponding loss value is smaller. Therefore, it is proposed here to determine multiple candidate network channel number configuration schemes based on the loss values obtained in the process of training the neural network to be trained based on multiple pre-set network channel number configuration schemes. In this way, multiple candidate network channel number configuration schemes with smaller corresponding loss values can be obtained, thereby facilitating the selection of a target network channel number configuration scheme with higher accuracy from multiple candidate network channel number configuration schemes.
[0112] Specifically, with respect to the above S202, when determining a target network channel number configuration scheme that meets preset conditions based on the running speed and accuracy of the network of the bidirectional coupling network structure corresponding to the trained neural network under each candidate network channel number configuration scheme, it may include:
[0113] (1) Selecting a network with a running speed greater than or equal to a set speed threshold and the highest accuracy from the networks of bidirectional coupled network structures corresponding to the trained neural networks under multiple candidate network channel number configuration schemes;
[0114] (2) The candidate network channel number configuration scheme corresponding to the screened network is used as the target network channel number configuration scheme.
[0115] By inputting the verification image set into the network of the bidirectional coupling network structure corresponding to the trained neural network under each candidate network channel number configuration scheme, the accuracy and running speed corresponding to the network can be determined. Further, the candidate network channel number configuration scheme corresponding to the network with a running speed greater than or equal to the set speed threshold and the highest accuracy can be screened as the target network channel number configuration scheme.
[0116] Exemplarily, for each candidate network channel number configuration scheme, the floating-point computing amount of the corresponding bidirectional coupling network structure can be predetermined, and the corresponding floating-point running speed can also be determined. In this way, the candidate network channel number configuration schemes whose running speeds are less than a set speed threshold can be filtered out based on the floating-point computing speeds corresponding to each candidate network channel number configuration scheme, and the candidate network channel number configuration schemes whose corresponding running speeds are greater than or equal to the set speed threshold are retained. Then, based on the verification image set and the trained neural network, the candidate network channel number configuration scheme with the highest corresponding accuracy can be selected as the target network channel number configuration scheme.
[0117] Exemplarily, the set speed threshold can be determined in advance based on factors such as the storage capacity and load capacity of the terminal device on which the target neural network is to run. The set speed threshold here can be different for different terminal devices, and a target network channel number configuration scheme with an operating speed greater than or equal to the set speed threshold is selected, so that the target neural network trained based on the target network channel number configuration scheme can run at a faster speed on the terminal device.
[0118] Specifically, when selecting a network with a running speed greater than or equal to a set speed threshold and the highest accuracy from the networks of the bidirectionally coupled network structure corresponding to the trained neural network under multiple candidate network channel number configuration schemes, it may include:
[0119] (1) Based on the running speed of the network of the bidirectional coupling network structure corresponding to each candidate network channel number configuration scheme of the trained neural network, determine the network whose running speed is greater than or equal to the set speed threshold;
[0120] (2) From the determined networks, select the network with the highest accuracy as the screened network.
[0121] In the embodiment of the present disclosure, based on the running speed of the network of the bidirectional coupled network structure corresponding to the trained neural network under each candidate network channel number configuration scheme, the network whose running speed is greater than or equal to the set speed threshold can be screened out. In this way, the range of candidate network channel number configuration schemes can be narrowed down, which facilitates the rapid determination of the target network channel number configuration scheme.
[0122] Specifically, when determining multiple candidate network channel number configuration schemes based on the loss value of the network of the bidirectional coupling network structure corresponding to each network channel number configuration scheme of the neural network to be trained in multiple network channel number configuration schemes, such as Figure 8 As shown, the following S401 to S404 may be included:
[0123] S401, after sorting the loss values of the network of the bidirectional coupling network structure corresponding to each network channel number configuration scheme of the neural network to be trained in ascending order, obtain the network channel number configuration scheme corresponding to the set number of loss values before sorting.
[0124] Exemplarily, in the process of training the neural network to be trained based on each of the pre-set multiple network channel number configuration schemes, the loss value of the network of the bidirectional coupled network structure corresponding to the neural network to be trained under each network channel number configuration scheme can be obtained. For example, there are 1000 loss values corresponding to 1000 network channel number configuration schemes. In this way, the loss values can be sorted in ascending order, and the network channel number configuration scheme corresponding to the set number of loss values before sorting can be selected, such as selecting the network channel number configuration scheme corresponding to the first 100 loss values before sorting.
[0125] S402, based on the set number of loss values before sorting, determine the probability values of different numbers of processing channels contained in each convolutional layer in the target neural network to be trained.
[0126] Exemplarily, the idea of quadratic programming problem can be introduced here to determine the probability values of different numbers of processing channels contained in each convolutional layer in the target neural network to be trained, such as determining that the probability value of the first convolutional layer containing two processing channels is 0.8, determining that the probability value of the first convolutional layer containing three processing channels is 0.1, and determining that the probability value of the first convolutional layer containing four processing channels is 0.1.
[0127] Specifically, the probability values of different numbers of processing channels contained in each convolutional layer in the target neural network to be trained can be determined according to the following formula based on the loss value of the set number before sorting.
[0128]
[0129]
[0130]
[0131] Wherein, in formula (1), I(l,i) represents the expected loss value of the l-th convolutional layer of the target neural network to be trained containing i processing channels; m represents the number of network channel number configuration schemes set before sorting, and k represents the k-th network channel number configuration scheme among the network channel number configuration schemes set before sorting; Indicates that the number of processing channels of the l-th convolutional layer of the target neural network to be trained in the k-th network channel number configuration scheme is i; L (k) Represents the loss value corresponding to the k-th network channel number configuration scheme.
[0132] Formula (2) means that under the condition When it is established, determine the total expected loss value of the target neural network to be trained, which contains i processing channels in the lth convolutional layer p(l,i) represents the probability value that the number of processing channels contained in the lth convolutional layer of the target neural network to be trained is i.
[0133] In formula (3), F(l+1,i,j) represents the number of floating-point operations executed per second when the l+1 convolution layer of the target neural network to be trained contains i input channels (equivalent to the processing channels contained in the lth convolution layer) and j output channels (equivalent to the processing channels contained in the l+1th convolution layer). F(l,i,j) can be queried in a pre-stored mapping table of network structures and corresponding floating-point transport times executed per second. When the number of input channels and output channels contained in the convolution layer is determined, the number of floating-point transports executed per second by the convolution layer is also determined. The number of output channels of the convolution layer represents the number of processing channels of the convolution layer. p(l+1,j) represents the probability value that the number of processing channels contained in the l+1 convolution layer of the target neural network to be trained is j. F b Indicates the preset floating point operation amount.
[0134] S403, based on a plurality of pre-generated random arrays and probability values of different numbers of processing channels, determine a primary network channel number configuration scheme; wherein each random array contains random numbers corresponding to each convolutional layer.
[0135] Exemplarily, each group of random arrays includes random numbers corresponding to each convolution layer, and the random numbers are values ranging from 0 to 1, which can be obtained by a pre-trained random number generator, for example, they can include 0.1, 0.2, ... 1. Specifically, a group of random arrays can determine a candidate network channel number configuration scheme. For example, each candidate network channel number configuration scheme includes the number of processing channels corresponding to three convolution layers, then a group of random arrays here includes 3 random numbers greater than 0 and less than or equal to 1.
[0136] Specifically, when determining the primary network channel number configuration scheme based on the pre-generated multiple random arrays and probability values of different numbers of processing channels, it includes:
[0137] (1) For each convolution layer corresponding to any random array, the number of processing channels included in the convolution layer is determined based on the random number corresponding to the convolution layer in any random array and the probability value of the number of different processing channels included in the convolution layer;
[0138] (2) Based on the obtained number of processing channels contained in each convolutional layer, determine the primary network channel number configuration scheme corresponding to any random array.
[0139] The random numbers contained in the random array are discrete values. In order to facilitate the determination of the number of processing channels contained in each convolution layer based on discrete values, the probability value interval can be divided according to the probability values of the different numbers of processing channels contained in each convolution layer. For example, the probability value of the nth convolution layer containing 2 processing channels is 0.3, the probability value of containing 3 processing channels is 0.6, and the probability value of containing 4 processing channels is 0.1. The probability value interval can be divided based on 0.3, 0.6 and 0.1, and the obtained probability value intervals are 0 to 0.3 (including 2 processing channels), 0.3 to 0.9 (including 3 processing channels) and 0.9 to 1 (including 4 processing channels). When the random number corresponding to the nth convolution layer is 0.4, it can be indicated that the number of processing channels contained in the nth convolution layer is 3.
[0140] According to the above method, a primary network channel number configuration scheme corresponding to any random array can be obtained. Exemplarily, when multiple groups of random arrays are provided, multiple primary network channel number configuration schemes can be obtained.
[0141] In the process of selecting the number of processing channels contained in each convolution layer by setting random numbers, the range of probability value intervals occupied by processing channels with larger probability values is larger. Therefore, under high probability conditions, the random number can hit the number of processing channels with the largest probability value, and also hit the number of processing channels with non-largest probability values. Therefore, when determining multiple primary network channel number configuration methods based on multiple groups of random arrays, multiple different types of primary network channel number configuration schemes can be obtained, such as a primary network channel number configuration scheme including a channel number determined by a large probability value, and a primary channel number configuration scheme including a channel number determined by a small probability value. This facilitates the selection of candidate network channel number configuration schemes based on a genetic algorithm in the later stage, so that candidate network channel number configuration schemes with different structures can be selected, so that a target network channel number configuration scheme that better meets the requirements can be selected from among the candidate network channel number configuration schemes with different structures.
[0142] S404, determining multiple candidate network channel number configuration schemes based on the primary network channel number configuration scheme and the genetic algorithm.
[0143] Exemplarily, when using a genetic algorithm, a primary network channel number configuration scheme suitable as the first generation parent node of the genetic algorithm is selected by the loss value of the network of the bidirectional coupled network structure corresponding to the neural network to be trained under each network channel number configuration scheme, thereby improving the accuracy of determining candidate network channel number configuration schemes based on the genetic algorithm.
[0144] Specifically, when determining multiple candidate network channel number configuration schemes based on the primary network channel number configuration scheme and the genetic algorithm, the following steps may be included:
[0145] (1) The primary network channel number configuration scheme is used as the parent node of the genetic algorithm, and the accuracy corresponding to each parent node is determined based on the network parameter values of the processing channels contained in each parent node of the trained neural network and the network of the bidirectional coupling network structure composed of the processing channels contained in the parent node;
[0146] (2) Based on the accuracy corresponding to each parent node, determine the primary network channel number configuration scheme as the next generation parent node of the genetic algorithm, until the preset number of cycles is reached, and use each generation of primary network channel number configuration scheme as multiple candidate network channel number configuration schemes.
[0147] Exemplarily, after selecting the primary network channel number configuration scheme as the parent node of the genetic algorithm, the verification image set can be input into the network of the bidirectionally coupled network structure of the trained neural case under each primary network channel number configuration scheme to obtain the corresponding accuracy of the network, and then filter out some primary network channel number configuration schemes that do not meet the requirements based on the accuracy, and then obtain the primary network channel number configuration scheme as the next generation parent node through genetic algorithm calculation, and again determine the accuracy of the bidirectionally coupled network structure network corresponding to the trained neural network under the primary network channel number configuration scheme of the next generation parent node, until the preset number of cycles of the genetic algorithm is reached, and each generation of primary network channel number configuration schemes is used as multiple candidate network channel number configuration schemes.
[0148] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0149] Based on the same technical concept, the embodiments of the present disclosure also provide a training device corresponding to the training method of the neural network. Since the principle of solving the problem by the device in the embodiments of the present disclosure is similar to the above-mentioned training method in the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0150] Reference Fig. 9 FIG. 5 is a schematic diagram of a neural network training device 500 provided in an embodiment of the present disclosure, the training device comprising:
[0151] An acquisition module 501 is used to acquire a training image set and a plurality of preset network channel number configuration schemes;
[0152] The determination module 502 is used to determine, based on each network channel number configuration scheme, a bidirectionally coupled network structure composed of processing channels involved in processing of the neural network to be trained under the network channel number configuration scheme; the bidirectionally coupled network structure includes a pair of network structures composed of a network structure having a forward channel sequence and a network structure having a reverse channel sequence, and the forward channel sequence and the reverse channel sequence of the same convolutional layer of the neural network to be trained contain the same number of processing channels;
[0153] The training module 503 is used to train the network of the bidirectional coupling network structure corresponding to each network channel number configuration scheme of the neural network to be trained based on the training image set to obtain a trained neural network.
[0154] In a possible implementation, after obtaining the trained neural network, the training module 503 is further used to:
[0155] Based on the pre-acquired verification image set and the network parameter values of the processing channels included in the trained neural network under each of the multiple predetermined candidate network channel number configuration schemes, determine the accuracy of the network of the bidirectional coupling network structure corresponding to the trained neural network under the candidate network channel number configuration scheme;
[0156] Based on the running speed and accuracy of the bidirectional coupled network structure corresponding to each candidate network channel number configuration scheme of the trained neural network, determine the target network channel number configuration scheme that meets the preset conditions;
[0157] Determine a target neural network to be trained according to the processing channels involved in the processing of the neural network to be trained under the target network channel number configuration scheme;
[0158] The target neural network to be trained is trained using the training image set to obtain the target neural network.
[0159] In a possible implementation, the training device further includes an execution module 504, and the target neural network is a classification network. After obtaining the target neural network, the execution module 504 is used to:
[0160] Get the target image;
[0161] The target image is input into the target neural network, and the target neural network outputs the object category in the target image.
[0162] In a possible implementation, the plurality of network channel number configuration schemes include a plurality of pairs of complementary network channel number configuration schemes;
[0163] The sum of the number of processing channels contained in each pair of complementary network channel number configuration schemes in the same convolutional layer is equal to the total number of channels contained in the convolutional layer.
[0164] In a possible implementation, the training image set includes multiple groups of training images, and the training module 503 is specifically used to:
[0165] For the current network channel number configuration scheme, a set of training images is input into the network of the bidirectional coupling network structure corresponding to the neural network to be trained under the current network channel number configuration scheme, and the loss value of the network of the bidirectional coupling network structure corresponding to the neural network to be trained under the current network channel number configuration scheme is obtained;
[0166] Based on the loss value, current network parameter values of the processing channels involved in the processing of the neural network to be trained under the current network channel number configuration scheme are adjusted to obtain adjusted network parameter values;
[0167] The next network channel number configuration scheme is selected as the current network channel number configuration scheme, and the step of inputting a set of training images into the network to be trained in the network of the bidirectional coupling network structure corresponding to the current network channel number configuration scheme is returned, until the adjusted network parameter values corresponding to the processing channels involved in the processing of the neural network to be trained under the last network channel number configuration scheme are obtained, thereby obtaining a trained neural network.
[0168] In a possible implementation, the training module 503 is specifically configured to:
[0169] Input a set of training images into a network having a network structure with a forward channel sequence corresponding to the neural network to be trained under the current network channel number configuration scheme, and obtain a first loss value corresponding to the neural network to be trained; and input the set of training images into a network having a network structure with a reverse channel sequence corresponding to the neural network to be trained under the current network channel number configuration scheme, and obtain a second loss value corresponding to the neural network to be trained;
[0170] The average of the first loss value and the second loss value is used as the loss value of the network with a bidirectional coupling network structure corresponding to the neural network to be trained under the current network channel number configuration scheme.
[0171] In a possible implementation, the training module 503 is used to determine multiple candidate network channel number configuration schemes in the following manner:
[0172] Determine multiple candidate network channel number configuration schemes based on the loss value of the network of the bidirectional coupling network structure corresponding to each network channel number configuration scheme of the neural network to be trained in the multiple network channel number configuration schemes;
[0173] The training module is used to determine a target network channel number configuration scheme that meets preset conditions based on the running speed and accuracy of the network of the bidirectional network structure corresponding to each candidate network channel number configuration scheme of the trained neural network, including:
[0174] Select a network with a running speed greater than or equal to a set speed threshold and the highest accuracy from the networks of bidirectional coupled network structures corresponding to the trained neural network under multiple candidate network channel number configuration schemes;
[0175] The candidate network channel number configuration scheme corresponding to the screened network is used as the target network channel number configuration scheme.
[0176] In a possible implementation, the training module 503 is specifically configured to:
[0177] After sorting the loss values of the networks of the bidirectional coupling network structure corresponding to each network channel number configuration scheme of the neural network to be trained in ascending order, the network channel number configuration scheme corresponding to the set number of loss values before sorting is obtained;
[0178] Based on the set number of loss values before sorting, determine the probability values of different numbers of processing channels contained in each convolutional layer of the target neural network to be trained;
[0179] Determine the primary network channel number configuration scheme based on multiple pre-generated random arrays and probability values of different numbers of processing channels; each random array contains random numbers for each convolution layer;
[0180] Based on the primary network channel number configuration scheme and the genetic algorithm, multiple candidate network channel number configuration schemes are determined.
[0181] In a possible implementation, the training module 503 is specifically configured to:
[0182] For each convolution layer corresponding to any random array, the number of processing channels included in the convolution layer is determined based on the random number corresponding to the convolution layer in any random array and the probability value of the different numbers of processing channels included in the convolution layer;
[0183] Based on the obtained number of processing channels contained in each convolutional layer, a primary network channel number configuration scheme corresponding to any random array is determined.
[0184] In a possible implementation, the training module 503 is specifically configured to:
[0185] The primary network channel number configuration scheme is used as the parent node of the genetic algorithm, and the accuracy corresponding to each parent node is determined based on the network parameter values of the processing channels contained in each parent node of the trained neural network and the network of the bidirectional coupling network structure composed of the processing channels contained in the parent node;
[0186] Based on the accuracy corresponding to each parent node, the primary network channel number configuration scheme as the next generation parent node of the genetic algorithm is determined, until the preset number of cycles is reached, and each generation of primary network channel number configuration scheme is used as multiple candidate network channel number configuration schemes.
[0187] In a possible implementation, the training module 503 is specifically configured to:
[0188] Based on the running speed of the network of the bidirectional coupling network structure corresponding to each candidate network channel number configuration scheme of the trained neural network, determine the network whose running speed is greater than or equal to the set speed threshold;
[0189] From the determined networks, the network with the highest accuracy is selected as the screened network.
[0190] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0191] Corresponds to Figure 1 The present disclosure also provides an electronic device 600, such as Fig.10 FIG. 6 is a schematic diagram of the structure of an electronic device 600 provided in an embodiment of the present disclosure, including:
[0192] Processor 61, memory 62, and bus 63; memory 62 is used to store execution instructions, including internal memory 621 and external memory 622; the internal memory 621 here is also called internal memory, which is used to temporarily store the operation data in the processor 61 and the data exchanged with the external memory 622 such as a hard disk. The processor 61 exchanges data with the external memory 622 through the internal memory 621. When the electronic device 600 is running, the processor 61 and the memory 62 communicate through the bus 63, so that the processor 61 executes the following instructions: obtain a training image set and a plurality of pre-set network channel number configuration schemes; based on each network channel number configuration scheme, determine the bidirectional coupling network structure composed of the processing channels involved in the processing of the neural network to be trained under the network channel number configuration scheme; the bidirectional coupling network structure includes a pair of network structures composed of a network structure with a forward channel sequence and a network structure with a reverse channel sequence, and the forward channel sequence and the reverse channel sequence of the same convolutional layer of the neural network to be trained contain the same number of processing channels; based on the training image set, the network of the bidirectional coupling network structure corresponding to the neural network to be trained under each network channel number configuration scheme is trained to obtain a trained neural network.
[0193] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the neural network training method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0194] The computer program product of the neural network training method provided in the embodiments of the present disclosure includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the steps of the neural network training method described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0195] The present disclosure also provides a computer program, which implements any one of the methods of the aforementioned embodiments when executed by a processor. The computer program product can be implemented in hardware, software, or a combination thereof. In an optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK), etc.
[0196] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0197] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0198] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0199] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0200] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A neural network training method, It is characterized in that include: Acquire a training image set and a plurality of preset network channel number configuration schemes; the training image set includes a category identifier; Based on each network channel number configuration scheme, determining a bidirectional coupling network structure composed of processing channels involved in processing of the neural network to be trained under the network channel number configuration scheme; the processing channels involved in processing participate in processing image features during the training process; The bidirectional coupling network structure includes a pair of network structures consisting of a network structure having a forward channel sequence and a network structure having a reverse channel sequence, and the forward channel sequence and the reverse channel sequence of the same convolutional layer of the neural network to be trained contain the same number of processing channels; Based on the training image set, the network of the bidirectional coupling network structure corresponding to the neural network to be trained under each network channel number configuration scheme is trained to obtain a trained neural network; the trained neural network is used to classify the target image; Based on the trained neural network, select the network channel configuration scheme that meets the image classification accuracy and running speed requirements; Among them, the forward channel sequence and the reverse channel sequence are both channel sequences formed by at least one channel; the channels in the forward channel sequence and the reverse channel sequence in a pair of network structures are symmetrically distributed according to the center point of the arrangement positions of all channels, and the channels included in the forward channel sequence are counted from one end of all channels until the number of channels in the corresponding network channel configuration scheme is reached.
2. The training method according to claim 1, It is characterized in that After obtaining the trained neural network, the training method further includes: Based on a pre-acquired validation image set and network parameter values of processing channels of the trained neural network involved in processing under each of a plurality of predetermined candidate network channel number configuration schemes, determine the accuracy of a network of a bidirectional coupling network structure corresponding to the trained neural network under the candidate network channel number configuration scheme; Determine a target network channel number configuration scheme that meets preset conditions based on the running speed and accuracy of the network of the bidirectional coupling network structure corresponding to the trained neural network under each candidate network channel number configuration scheme; Determining a target neural network to be trained according to the processing channels involved in processing included in the neural network to be trained under the target network channel number configuration scheme; The target neural network to be trained is trained using the training image set to obtain a target neural network.
3. The training method according to claim 2, It is characterized in that The target neural network is a classification network. After obtaining the target neural network, the training method further includes: Get the target image; The target image is input into the target neural network, and the target neural network outputs the object category in the target image.
4. The training method according to claim 1, It is characterized in that The plurality of network channel number configuration schemes include a plurality of pairs of complementary network channel number configuration schemes; The sum of the number of processing channels included in each pair of complementary network channel number configuration schemes in the same convolutional layer is equal to the total number of channels included in the convolutional layer.
5. The training method according to any one of claims 1 to 4, It is characterized in that The training image set includes a plurality of groups of training images, and the training of the network of the bidirectional coupling network structure corresponding to each network channel number configuration scheme of the neural network to be trained based on the training image set to obtain the trained neural network includes: For the current network channel number configuration scheme, a group of training images are input into the network of the bidirectional coupling network structure corresponding to the current network channel number configuration scheme for training the neural network to be trained, and the loss value of the network of the bidirectional coupling network structure corresponding to the neural network to be trained under the current network channel number configuration scheme is obtained; Based on the loss value, current network parameter values of the processing channels of the neural network to be trained under the current network channel number configuration scheme are adjusted to obtain adjusted network parameter values; Select the next network channel number configuration scheme as the current network channel number configuration scheme, and return to the step of inputting a set of training images into the network of the to-be-trained neural network in the network of the bidirectional coupling network structure corresponding to the current network channel number configuration scheme for training, until the adjusted network parameter values corresponding to the processing channels involved in the processing of the to-be-trained neural network in the last network channel number configuration scheme are obtained, thereby obtaining a trained neural network.
6. The training method according to claim 5, It is characterized in that The step of inputting a set of training images into a network of a bidirectionally coupled network structure corresponding to the current network channel number configuration scheme for training the neural network to be trained, and obtaining a loss value of the network of a bidirectionally coupled network structure corresponding to the neural network to be trained under the current network channel number configuration scheme, comprises: Input a group of training images into a network having a network structure with a forward channel sequence corresponding to the neural network to be trained under the current network channel number configuration scheme, to obtain a first loss value corresponding to the neural network to be trained, and input the group of training images into a network having a network structure with a reverse channel sequence corresponding to the neural network to be trained under the current network channel number configuration scheme, to obtain a second loss value corresponding to the neural network to be trained; The average of the first loss value and the second loss value is used as the loss value of the network of the bidirectional coupling network structure corresponding to the neural network to be trained under the current network channel number configuration scheme.
7. The training method according to claim 2, It is characterized in that The multiple candidate network channel number configuration schemes are determined in the following manner: Determine the plurality of candidate network channel number configuration schemes based on the loss value of the network of the bidirectional coupling network structure corresponding to each network channel number configuration scheme of the neural network to be trained in the plurality of network channel number configuration schemes; The operation speed and accuracy of the network of the bidirectional coupling network structure corresponding to each candidate network channel number configuration scheme based on the trained neural network, and determining the target network channel number configuration scheme that meets the preset conditions, include: Select a network with a running speed greater than or equal to a set speed threshold and the highest accuracy from the networks of the bidirectionally coupled network structure corresponding to the trained neural network under the plurality of candidate network channel number configuration schemes; The candidate network channel number configuration scheme corresponding to the screened network is used as the target network channel number configuration scheme.
8. The training method according to claim 7, It is characterized in that The determining of the plurality of candidate network channel number configuration schemes based on the loss value of the network of the bidirectional coupling network structure corresponding to each network channel number configuration scheme of the neural network to be trained under the plurality of network channel number configuration schemes comprises: After sorting the loss values of the network of the bidirectional coupling network structure corresponding to each network channel number configuration scheme of the neural network to be trained in ascending order, obtaining the network channel number configuration scheme corresponding to the set number of loss values before sorting; Based on the loss values of the set number before the sorting, determining the probability values of different numbers of processing channels contained in each convolutional layer in the target neural network to be trained; Determine a primary network channel number configuration scheme based on a plurality of pre-generated random arrays and probability values of the different numbers of processing channels; each random array contains random numbers for each convolutional layer; Based on the primary network channel number configuration scheme and the genetic algorithm, the plurality of candidate network channel number configuration schemes are determined.
9. The training method according to claim 8, It is characterized in that The method of determining the primary network channel number configuration scheme based on the pre-generated multiple random arrays and the probability values of the different numbers of processing channels includes: For each convolution layer corresponding to any random array, based on the random number corresponding to the convolution layer in any random array and the probability value of the number of different processing channels included in the convolution layer, determine the number of processing channels included in the convolution layer; Based on the obtained number of processing channels contained in each convolutional layer, a primary network channel number configuration scheme corresponding to any random array is determined.
10. The training method according to claim 8 or 9, It is characterized in that The determining of the plurality of candidate network channel number configuration schemes based on the primary network channel number configuration scheme and the genetic algorithm comprises: The primary network channel number configuration scheme is used as the parent node of the genetic algorithm, and the accuracy corresponding to each parent node is determined based on the network parameter values of the processing channels contained in each parent node of the trained neural network and the network of the bidirectional coupling network structure composed of the processing channels contained in the parent node; Based on the accuracy corresponding to each parent node, the primary network channel number configuration scheme as the next generation parent node of the genetic algorithm is determined, until the preset number of cycles is reached, each generation of primary network channel number configuration scheme is used as the multiple candidate network channel number configuration schemes.
11. The training method according to any one of claims 7 to 9, It is characterized in that The step of selecting a network having a running speed greater than or equal to a set speed threshold and having the highest accuracy from the networks of the bidirectionally coupled network structure corresponding to the plurality of candidate network channel number configuration schemes from the trained neural network includes: Based on the running speed of the network of the bidirectional coupling network structure corresponding to the trained neural network under each candidate network channel number configuration scheme, determine a network whose running speed is greater than or equal to the set speed threshold; From the determined networks, the network with the highest accuracy is selected as the screened network.
12. A neural network training device, It is characterized in that include: An acquisition module is used to acquire a training image set and a plurality of pre-set network channel number configuration schemes; The training image set includes a category identifier; A determination module is used to determine, based on each network channel number configuration scheme, a bidirectional coupling network structure composed of processing channels involved in processing of the neural network to be trained under the network channel number configuration scheme; the processing channels involved in processing participate in processing image features during the training process; The bidirectional coupling network structure includes a pair of network structures consisting of a network structure having a forward channel sequence and a network structure having a reverse channel sequence, and the forward channel sequence and the reverse channel sequence of the same convolutional layer of the neural network to be trained contain the same number of processing channels; A training module is used to train the network of the bidirectional coupling network structure corresponding to each network channel number configuration scheme of the neural network to be trained based on the training image set to obtain a trained neural network; the trained neural network is used to classify the target image; based on the trained neural network, a network channel configuration scheme is selected whose image classification accuracy and running speed meet the requirements; Among them, the forward channel sequence and the reverse channel sequence are both channel sequences formed by at least one channel; the channels in the forward channel sequence and the reverse channel sequence in a pair of network structures are symmetrically distributed according to the center point of the arrangement positions of all channels, and the channels included in the forward channel sequence are counted from one end of all channels until the number of channels in the corresponding network channel configuration scheme is reached.
13. An electronic device, It is characterized in that include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the training method as described in any one of claims 1 to 11 are performed.
14. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the training method according to any one of claims 1 to 11 are executed.
Citation Information
Patent Citations
Reinforcement dual-channel sequence learning-based dialog reply generation method and system
CN108763504A
Method for adjusting convolutional neural network and related device
CN108960411A
Unsupervised pedestrian re-identification method based on augmented network
CN111062329A
Method and electronic device for convolution calculation in neutral network
EP3499428A1
Operation apparatus and method for convolutional neural network
US20180089562A1