A method and device for extracting target features
Through data parallel training, multiple initial neural networks are trained, and hyperparameters at different training stages are used to solve the problem of hyperparameter setting relying on manual experience, achieving higher-precision target feature extraction and image processing.
Patent Information
- Application Number
- CN202011180820.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-29
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2040-10-29
AI Technical Summary
In the existing technology, the hyperparameter setting of the neural network model relies on manual experience, which easily leads to poor accuracy of the network model and affects the accuracy of the image processing results.
A data parallel training method is used to train multiple initial neural networks. Different hyperparameters are used in different training stages. The optimal network structure is selected through precision testing to form the final model.
The accuracy of the network model is improved, ensuring that the extracted target features are more accurate, thereby improving the accuracy of the image processing results.
Smart Images

Figure CN114429205B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of intelligent technology, and in particular to a target feature extraction method and device. Background Art
[0002] Neural networks, an emerging field in machine learning research, analyze data by mimicking the human brain and have been widely used in the field of intelligence. In image processing applications, by inputting the image to be processed into a network model, target features can be extracted from the image, achieving end-to-end image processing capabilities. These network models are built and trained based on neural networks, and the training process directly affects the accuracy of the image processing results.
[0003] In related technologies, the process of training network models requires manual configuration of certain parameters, such as the number of intermediate layers, the activation function used, the loss function, and the number of iterations. These parameters are referred to as hyperparameters. The settings of these hyperparameters affect the performance of the trained network model and, therefore, the accuracy of the image processing results.
[0004] However, in related technologies, hyperparameters are often set by technicians based on their own parameter adjustment experience. If the settings are unreasonable, it will lead to poor accuracy of the network model, further affecting the accuracy of the image processing results. Summary of the Invention
[0005] The purpose of the embodiments of the present application is to provide a method and apparatus for extracting target features to improve the accuracy of image processing results. The specific technical solutions are as follows:
[0006] In a first aspect, an embodiment of the present application provides a method for extracting target features, the method comprising:
[0007] Get the image to be processed;
[0008] The target features are extracted from the above images using a pre-trained network model; wherein the network model is obtained by training multiple initial neural networks using data parallel training method with different hyperparameters set for different training stages.
[0009] In a possible embodiment, the network model training method includes:
[0010] Using the same pre-set hyperparameters, multiple initial neural networks are trained in data parallel;
[0011] When a preset first stopping condition is met, stopping the training of the multiple initial neural networks to obtain multiple updated neural networks;
[0012] In each different training stage, the multiple updated neural networks are trained in parallel, and after each training stage is completed, the accuracy of each neural network trained in the training stage is tested, wherein the hyperparameters set for each updated neural network in each training stage are different;
[0013] When a preset second stopping condition is met, the parallel training of the multiple updated neural networks is stopped, and the network model finally obtained by training is determined based on the network structure of the neural network with the highest accuracy among the neural networks trained in the last training stage.
[0014] In a possible embodiment, the step of training the multiple updated neural networks in parallel in each different training stage, and performing accuracy testing on each neural network trained in the training stage after each training stage is completed, includes:
[0015] In each training phase, for each updated neural network, a single training is performed on the updated neural network using the hyperparameters corresponding to the updated neural network set according to the preset rules to obtain a neural network after the single training;
[0016] After each training phase is completed, the accuracy of each neural network after single training is tested to determine the neural network with the highest accuracy trained in that training phase;
[0017] The network weights of the neural network with the highest accuracy obtained in the training phase are copied to the neural networks after each single training;
[0018] The neural networks after each single training are used as new updated neural networks to start parallel training of the next training stage. In other training stages except the first training stage, the hyperparameters corresponding to an updated neural network are set to the hyperparameters corresponding to the neural network with the highest accuracy obtained in the previous training stage.
[0019] In a possible embodiment, the preset rules include:
[0020] If the updated neural network is the neural network with the highest accuracy obtained in the previous training phase, the hyperparameters corresponding to the updated neural network remain unchanged;
[0021] If the updated neural network is not the neural network with the highest accuracy obtained in the previous training phase, the hyperparameters corresponding to the updated neural network are randomly set.
[0022] In a possible embodiment, randomly setting the hyperparameters corresponding to the updated neural network includes:
[0023] The hyperparameters corresponding to the updated neural network are randomly set within a specified hyperparameter range, wherein the specified hyperparameter range is determined based on the hyperparameters corresponding to the neural network with the highest accuracy obtained by training in the previous training phase.
[0024] In a possible embodiment, in each different training stage, the multiple updated neural networks are trained in parallel, and after each training stage is completed, the accuracy test of each neural network trained in the training stage is performed, and the method further includes:
[0025] If the number of completed training stages reaches a preset threshold, the parallel training of the multiple updated neural networks is stopped, and the network model finally trained is determined based on the network structure of the neural network with the highest accuracy among the neural networks trained in the last training stage.
[0026] In a possible embodiment, the parallel training of the multiple updated neural networks includes:
[0027] The multiple updated neural networks are trained in parallel using multiple GPUs, wherein each GPU is used to train one updated neural network.
[0028] In a possible embodiment, after the step of extracting target features from the image using a pre-trained network model, the method further includes:
[0029] Based on the target features, the target is identified to obtain a target identification result.
[0030] In a second aspect, an embodiment of the present application provides a target feature extraction device, the device comprising:
[0031] An acquisition module, used for acquiring an image to be processed;
[0032] The feature extraction module is used to extract target features from the above image using a pre-trained network model; wherein the network model is obtained by using a data parallel training method and training multiple initial neural networks using different hyperparameters set for different training stages.
[0033] In a third aspect, an embodiment of the present application provides a computer device comprising a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor, and the processor is prompted by the machine-executable instructions to implement the method provided in the first aspect of the embodiment of the present application.
[0034] In a fourth aspect, an embodiment of the present application provides a machine-readable storage medium storing machine-executable instructions, which, when called and executed by a processor, implements the method provided in the first aspect of the embodiment of the present application.
[0035] In a fifth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method provided in the first aspect of the embodiment of the present application.
[0036] The embodiment of the present application provides a method and device for extracting target features, which obtains an image to be processed and uses a pre-trained network model to extract target features from the image. The network model is obtained by adopting a data parallel training method, and multiple initial neural networks are trained respectively using different hyperparameters set for different training stages. When training the network model, a data parallel training method is adopted, and multiple initial neural networks are trained respectively using different hyperparameters set for different training stages. For each initial neural network, there is no need to set a unified hyperparameter. The setting of the hyperparameter is more flexible, and the network model is less affected by the hyperparameter, thereby ensuring the accuracy of the network model. The target features extracted using the trained network model are more accurate, thereby improving the accuracy of the image processing results. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying any creative work.
[0038] Figure 1 Schematic diagram of the process of extracting target features according to an embodiment of the present application;
[0039] Figure 2 A flowchart of network model training according to an embodiment of the present application is shown;
[0040] Figure 3 for Figure 2 A schematic diagram of the process executed by S203 in the embodiment shown;
[0041] Figure 4 A flowchart of network model training according to another embodiment of the present application is shown;
[0042] Figure 5 This is a flow chart of conventional data parallel training according to an embodiment of the present application;
[0043] Figure 6 A flowchart of unconventional data parallel training according to an embodiment of the present application is shown;
[0044] Figure 7A schematic diagram of the process of accuracy testing and network weight copying in an embodiment of the present application;
[0045] Figure 8 This is a schematic structural diagram of a target feature extraction device according to an embodiment of the present application;
[0046] Figure 9 This is a schematic diagram of the structure of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0048] In order to improve the accuracy of image processing results, the present invention provides a method, apparatus, computer device and machine-readable storage medium for extracting target features.
[0049] In order to more clearly illustrate the target feature extraction method provided in the embodiment of the present application, the application scenario of the target feature extraction method provided in the embodiment of the present application will be exemplified below. The following example is only one possible application scenario of the target feature extraction method provided in the embodiment of the present application. In other possible embodiments, the target feature extraction method provided in the embodiment of the present application can also be applied to other possible application scenarios. The following example does not impose any restrictions on this.
[0050] To improve the accuracy of image analysis results, a distributed training approach can be used to train the network model used for image analysis. Distributed training methods mainly include data-parallel training and model-parallel training. Data-parallel training involves training multiple initial neural networks separately using training samples, and then combining the trained network structures of each neural network to form the final network model. Model-parallel training involves splitting the initial neural network into different parts, training each part using training samples, and then combining the trained network structures of each part to form the final network model.
[0051] In the corresponding distributed training scheme, the same hyperparameters are used to train initial neural networks with different network structures. The initial neural network that reaches the stopping condition first has a better network structure. Therefore, after the initial neural network that reaches the stopping condition first, other initial neural networks are added and further trained to determine the next initial neural network that reaches the stopping condition. This process is repeated to obtain the final network model. This scheme uses the order in which the initial neural networks reach the stopping condition to select the neural networks that reach the stopping condition faster from multiple neural networks. After repeated iterations, a higher-precision network model can be obtained.
[0052] However, the hyperparameters are often set by technicians based on their own parameter adjustment experience. If the settings are unreasonable, it will lead to poor accuracy of the network model, further affecting the accuracy of the image processing results.
[0053] Based on this, embodiments of the present application provide a method for extracting target features. The target feature extraction method provided in embodiments of the present application can be executed by a computer device with image processing capabilities, and the execution entity can include at least a core processing chip with data processing capabilities. The target feature extraction method provided in embodiments of the present application can be implemented by at least one of software, hardware circuits, and logic circuits provided in the execution entity.
[0054] like Figure 1 FIG. 1 is a flow chart of a target feature extraction method according to an embodiment of the present application, and the method may include the following steps.
[0055] S101: Acquire an image to be processed.
[0056] S102, using a pre-trained network model to extract target features from the above image; wherein the network model is obtained by using a data parallel training method, using different hyperparameters set for different training stages to train multiple initial neural networks respectively.
[0057] By using the embodiment of the present application, the target features are extracted from the image by acquiring the image to be processed and using the pre-trained network model. The network model is obtained by adopting a data parallel training method, and multiple initial neural networks are trained respectively using different hyperparameters set for different training stages. When training the network model, a data parallel training method is adopted, and multiple initial neural networks are trained respectively using different hyperparameters set for different training stages. For each initial neural network, there is no need to set a unified hyperparameter. The setting of the hyperparameter is more flexible, and the network model is less affected by the hyperparameter, thereby ensuring the accuracy of the network model. The target features extracted by the trained network model are more accurate, thereby improving the accuracy of the image processing results.
[0058] In an embodiment of the present application, the image to be processed can be an image obtained from a front-end image acquisition device or from a local database, which requires target recognition, target detection, and other processing. When processing the image, it is necessary to extract the target features in the image. The target features specifically refer to information that can characterize the target attributes, such as human facial features, license plates, pet faces, etc.
[0059] In an embodiment of the present application, a network model is used to extract target features from the image to be processed, and the network model is obtained by training a neural network using training samples. Specifically, in an embodiment of the present application, the network model is obtained by adopting a data parallel training method, and multiple initial neural networks are trained respectively using different hyperparameters set for different training stages. Data parallel training means: for multiple initial neural networks, training samples are input respectively for training, and the network structures of each trained neural network are combined to obtain the final network model. The multiple initial neural networks can be multiple neural networks with the same network structure, or multiple neural networks with different network structures, which is not specifically limited here. The neural network can be a convolutional neural network, a recurrent neural network, a long short-term memory network, etc., which is not specifically limited here.
[0060] In an embodiment of the present application, multiple initial neural networks can be distributed on different GPUs (Graphics Processing Units), and the training process of the network model can be specifically completed by the collaboration of the GPUs in the computer device. In addition, a processor can also be set in the computer device to coordinate the GPUs.
[0061] In another implementation of the embodiment of the present application, after S102, the method may further include: identifying the target based on the target features to obtain a target identification result.
[0062] In combination with specific application scenarios, in an embodiment of the present application, after extracting target features, the target can be identified based on the target features to obtain a target recognition result, which may include information such as the target's location and category.
[0063] The network model training process in the embodiment of the present application is divided into multiple different training phases. Each training phase uses different hyperparameters when training the neural network, and the hyperparameters used to train each neural network can also be different. Hyperparameters refer to the constraint parameters used in the training process, such as learning rate, batch size, momentum, weight decay, etc. The specific training method is introduced below.
[0064] like Figure 2 The network model training process shown may include the following steps.
[0065] S201, using the same pre-set hyperparameters to perform data parallel training on multiple initial neural networks.
[0066] S202: When a preset first stopping condition is met, stop training the multiple initial neural networks to obtain multiple updated neural networks.
[0067] S203, in each different training stage, parallel training is performed on the multiple updated neural networks, and after each training stage, accuracy testing is performed on each neural network trained in that training stage, wherein different hyperparameters are set for each updated neural network in each training stage.
[0068] S204, when a pre-set second stopping condition is met, the parallel training of the multiple updated neural networks is stopped, and the network model finally obtained by training is determined based on the network structure of the neural network with the highest accuracy among the neural networks trained in the last training stage.
[0069] In the network model training process of the embodiment of the present application, it is mainly divided into two different training stages, namely the conventional data parallel training stage and the unconventional data parallel training stage. The training process may include multiple conventional data parallel training stages and multiple unconventional data parallel training stages. Multiple trainings can be performed in one training stage, or single training can be performed. The conventional data parallel training stage is to use the same pre-set hyperparameters and training samples to perform data parallel training on multiple initial neural networks. When the pre-set first stopping condition is met, the training of the multiple initial neural networks is stopped to obtain multiple updated neural networks. Among them, the first stopping condition may be that the number of trainings in the conventional data parallel training stage has reached a certain number or the training accuracy has reached a certain accuracy. The specific training process refers to the traditional data parallel training and will not be repeated here.
[0070] The unconventional data parallel training stage is to train multiple updated neural networks obtained in the previous training stage multiple times. The previous training stage of the first unconventional data parallel training stage is the last conventional data parallel training stage, and the previous training stage of other training stages except the first unconventional data parallel training stage is the previous unconventional data parallel training stage. For the convenience of description, the "training stage" below refers to the unconventional data parallel training stage unless otherwise specified.
[0071] After each training stage is completed, the accuracy of each neural network obtained by training in the training stage is tested. When the pre-set second stopping condition is met, the parallel training of multiple updated neural networks is stopped, and the network model obtained by final training is determined based on the network structure of the neural network with the highest accuracy among the neural networks obtained by training in the last training stage. Among them, the super parameters corresponding to each updated neural network set in each training stage are different, that is, the super parameters corresponding to any two updated neural networks in the same training stage are different. The different super parameters can mean that the super parameters are not completely the same or that the super parameters are completely different. For example, assuming that there are three super parameters in total, which are respectively recorded as super parameter 1, super parameter 2 and super parameter 3, then the super parameters corresponding to the two updated neural networks are different, which can mean that any super parameter of the super parameters 1-3 corresponding to the two updated neural networks is different, or it can mean that each super parameter of the super parameters 1-3 corresponding to the two updated neural networks is different.
[0072] Since different hyperparameters are set for different updated neural networks in the same training phase, the network weights of each updated neural network after training will be different. Different network weights will make the accuracy of each trained neural network different. Through multiple training phases, the accuracy of the neural network will become higher and higher. In this way, when the pre-set second stopping condition is met, the parallel training of multiple updated neural networks can be stopped, and the network model finally trained can be determined based on the network structure of the neural network with the highest accuracy among the neural networks trained in the last training phase. Specifically, the process of accuracy testing can be to input data that has been marked with label information into the neural network and obtain the analysis results of the neural network. The closer the analysis results are to the label information, the higher the accuracy of the neural network. The second stopping condition can be that the number of times the unconventional data parallel training phase has been completed has reached a certain number or the accuracy of a certain neural network training has reached a certain accuracy. There is no specific limitation here.
[0073] In another implementation of the application embodiment, after S203, it may also include: if the total number of completed regular training stages and unconventional training stages reaches a preset threshold, the training of multiple updated neural networks is stopped, and the network model finally obtained by training is determined based on the network structure of the neural network with the highest accuracy among the neural networks obtained by training in the last training stage.
[0074] based on Figure 2 The embodiment shown, as Figure 3 As shown, S203 may specifically include the following steps.
[0075] S2031, in each training stage, for each updated neural network, a single training is performed on the updated neural network using the hyperparameters corresponding to the updated neural network according to preset rules to obtain a neural network after the single training.
[0076] S2032, after each training stage is completed, the accuracy test is performed on each neural network after single training to determine the neural network with the highest accuracy trained in the training stage.
[0077] S2033, copying the network weights of the neural network with the highest accuracy obtained in the training phase to other neural networks after single training.
[0078] S2034, using the neural networks after each single training as new updated neural networks, and starting parallel training for the next training stage, wherein, in other training stages except the first training stage, the hyperparameters corresponding to an updated neural network are set to the hyperparameters corresponding to the neural network with the highest accuracy obtained in the previous training stage.
[0079] In a specific implementation, in the first training stage, the hyperparameters corresponding to each updated neural network set according to the preset rules can be used to perform a single training on each updated neural network. The preset rules here can be different according to different application scenarios, but should satisfy the requirement of setting different hyperparameters for different updated neural networks. For example, the preset rule setting can be a random setting, and the method of randomly setting the hyperparameters can be a random selection, or a hyperparameter change rule, a hyperparameter change range, etc. can be specified. For example, in one possible embodiment, the hyperparameters corresponding to the updated neural network can be randomly set within a specified hyperparameter range, wherein the specified hyperparameter range is determined based on the hyperparameters corresponding to the neural network with the highest accuracy obtained by training in the previous training stage. For example, the hyperparameters can be randomly generated within the range of 50%-150% of the specified hyperparameters.
[0080] After each training phase is completed, the accuracy of each neural network after single training can be tested to determine the neural network with the highest accuracy. The network weights of the neural network with the highest accuracy are copied to the neural networks after each single training, so that when the next training starts, the network weights of each neural network are the same, ensuring that the training benchmark of each neural network is the same. Then, the neural networks after each single training are used as new updated neural networks to start parallel training for the next training phase. In the next training phase, the hyperparameters of an updated neural network are set to the hyperparameters corresponding to the aforementioned neural network with the highest accuracy. For example, assuming that the neural network with the highest accuracy among the neural networks trained in the nth training phase is neural network A, then the hyperparameters corresponding to an updated neural network in the n+1th training phase are the same as the hyperparameters corresponding to neural network A.
[0081] The method of setting the hyperparameters of an updated neural network to the hyperparameters corresponding to the aforementioned neural network with the highest accuracy in the next training phase may vary depending on the application scenario.
[0082] In a possible embodiment, when setting the hyperparameters of the updated neural network, the hyperparameters corresponding to any updated neural network are set to the hyperparameters corresponding to the neural network with the highest accuracy obtained by training in the previous training phase, and the hyperparameters corresponding to other updated neural networks except the updated neural network are randomly set.
[0083] For example, using the aforementioned example, the hyperparameters corresponding to any neural network other than neural network A obtained during the nth training phase may be set as the hyperparameters corresponding to neural network A, and the hyperparameters corresponding to the other neural networks other than the aforementioned neural network obtained during the nth training phase may be randomly reset. The preset rules can be found in the aforementioned description and will not be further elaborated here. The hyperparameters corresponding to the neural network after the reset should be different from the hyperparameters corresponding to the neural network before the reset.
[0084] In another possible embodiment, for the neural network with the highest accuracy obtained in the previous training phase, the hyperparameters corresponding to the updated neural network may be kept unchanged. For the neural network that is not the one with the highest accuracy obtained in the previous training phase, the hyperparameters corresponding to the updated neural network may be randomly set.
[0085] For example, using the aforementioned example, the hyperparameters corresponding to neural network A can be kept unchanged, and the hyperparameters corresponding to the other neural networks trained in the nth training phase, except for neural network A, can be reset according to preset rules. This embodiment eliminates the need to reset the hyperparameters of neural network A, thereby reducing the system resources consumed by resetting the hyperparameters of the neural networks.
[0086] For ease of understanding, the following mainly introduces the process of network model training in the embodiment of this application with reference to specific examples. Figure 4 As shown, the following steps are included.
[0087] S401, configure the same hyperparameters on different GPUs.
[0088] S402, conventional data parallel training.
[0089] The process of conventional data parallel training is as follows Figure 5 As shown, the training samples are input into each GPU, and each GPU uses the configured hyperparameters to train its own deployed initial neural network to obtain multiple updated neural networks.
[0090] S403: Determine whether a preset first stop condition is met. If yes, execute S404; otherwise, return to S401.
[0091] S404, configure different hyperparameters on different GPUs.
[0092] The hyperparameters on each GPU are randomly configured.
[0093] S405, unconventional data parallel training.
[0094] The process of unconventional data parallel training is as follows Figure 6 As shown in the figure, the training samples are input into each GPU, and each GPU uses the configured hyperparameters to perform a single training (also called single epoch training) on its deployed initial neural network. The training results of each GPU are different.
[0095] S406, accuracy test and network weight copy.
[0096] The implementation process of this step is as follows Figure 7 As shown, the accuracy of the training results of each GPU is tested separately to determine the neural network with the highest accuracy, and then the network weights of the neural network with the highest accuracy are copied to the other neural networks after single training.
[0097] S407: Determine whether the total number of training times has reached the upper limit. If yes, execute S409; otherwise, execute S408.
[0098] S408: Determine whether a preset second stop condition is met. If yes, execute S409; otherwise, return to S404.
[0099] If the pre-set second stopping condition is not met, the hyperparameters corresponding to the neural network with the highest accuracy can be maintained unchanged, and the hyperparameters of the other neural networks after single training can be randomly set. Then, the hyperparameters corresponding to the neural networks after single training are used to train the neural networks after the next training.
[0100] S409, determining a network model obtained by final training based on the network structure of the neural network with the highest accuracy among the neural networks obtained by the last training on the unconventional data, and saving the network model.
[0101] It can be seen that this solution is different from the traditional mode of configuring a single training hyperparameter, and can automatically adjust the hyperparameters to achieve the purpose of precision tuning. First, the introduction of stopping conditions as the starting conditions for training at different stages of the network model can greatly reduce the interference of the initial values of the network weights on the selection of hyperparameters, and on the other hand, it also reduces human participation in the entire training process. Secondly, due to the use of an unconventional distributed training process, the speed of superparameter adjustment during training is accelerated, thereby accelerating precision tuning. Therefore, the training process of the network model can be shortened, and the trained network model is more accurate. Therefore, when the trained network model is used for target feature extraction, the extracted target features are more accurate, thereby improving the accuracy of the image processing results.
[0102] Corresponding to the above method embodiment, the present application embodiment provides a target feature extraction device, such as Figure 8 As shown, the device may include:
[0103] An acquisition module 810 is used to acquire an image to be processed;
[0104] The feature extraction module 820 is used to extract target features from the above image using a pre-trained network model; wherein the network model is obtained by using a data parallel training method and training multiple initial neural networks using different hyperparameters set for different training stages.
[0105] In a possible embodiment, the device may further include: a training module;
[0106] The training module is used to use the same preset hyperparameters to perform data parallel training on multiple initial neural networks; when a preset first stopping condition is met, the training of the multiple initial neural networks is stopped to obtain multiple updated neural networks; in each different training stage, the multiple updated neural networks are trained in parallel, and after each training stage is completed, the accuracy test is performed on each neural network trained in the training stage, wherein the hyperparameters set for each updated neural network in each training stage are different; when a preset second stopping condition is met, the parallel training of the multiple updated neural networks is stopped, and the network model finally trained is determined based on the network structure of the neural network with the highest accuracy among the neural networks trained in the last training stage.
[0107] In a possible embodiment, the training module is specifically used to:
[0108] In each training phase, for each updated neural network, a single training is performed on the updated neural network using the hyperparameters corresponding to the updated neural network set according to the preset rules to obtain a neural network after the single training;
[0109] After each training phase is completed, the accuracy of each neural network after single training is tested to determine the neural network with the highest accuracy trained in that training phase;
[0110] The network weights of the neural network with the highest accuracy obtained in the training phase are copied to the neural networks after each single training;
[0111] The neural network after each single training is used as a new updated neural network, and parallel training of the next training stage is started. In other training stages except the first training stage, the hyperparameters corresponding to an updated neural network are set to the hyperparameters corresponding to the neural network with the highest accuracy obtained in the previous training stage.
[0112] In a possible embodiment, the preset rules include:
[0113] If the updated neural network is the neural network with the highest accuracy obtained in the previous training phase, the hyperparameters corresponding to the updated neural network remain unchanged;
[0114] If the updated neural network is not the neural network with the highest accuracy obtained in the previous training phase, the hyperparameters corresponding to the updated neural network are randomly set.
[0115] In a possible embodiment, the training module randomly sets the hyperparameters corresponding to the updated neural network, including:
[0116] The hyperparameters corresponding to the updated neural network are randomly set within a specified hyperparameter range, wherein the specified hyperparameter range is determined based on the hyperparameters corresponding to the neural network with the highest accuracy obtained by training in the previous training phase.
[0117] In a possible embodiment, the training module performs parallel training on the multiple updated neural networks in each different training stage, and after completing each training stage, performs accuracy testing on each neural network trained in the training stage, and is further configured to:
[0118] If the number of completed training stages reaches a preset threshold, the parallel training of the multiple updated neural networks is stopped, and the network model finally trained is determined based on the network structure of the neural network with the highest accuracy among the neural networks trained in the last training stage.
[0119] In a possible embodiment, the training module performs parallel training on the multiple updated neural networks, including:
[0120] The multiple updated neural networks are trained in parallel using multiple GPUs, wherein each GPU is used to train one updated neural network.
[0121] In a possible embodiment, the device further includes a recognition module for identifying the target based on the target features to obtain a target recognition result after the step of extracting target features from the image using a pre-trained network model.
[0122] The present application embodiment provides a computer device, such as Figure 9 As shown, it includes a processor 901 and a machine-readable storage medium 902, the machine-readable storage medium 902 stores machine-executable instructions that can be executed by the processor 901, and the processor 901 is prompted by the machine-executable instructions to implement all steps of the target feature extraction method as described above.
[0123] The machine-readable storage medium may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Alternatively, the machine-readable storage medium may be at least one storage device located remotely from the processor.
[0124] The above-mentioned processor can be a general-purpose processor, including a CPU (Central Processing Unit), an NP (Network Processor), etc.; it can also be a DSP (Digital Signal Processing), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0125] Data can be transmitted between the machine-readable storage medium 902 and the processor 901 via a wired connection or a wireless connection, and the computer device can communicate with other devices via a wired communication interface or a wireless communication interface. Figure 9 What is shown is merely an example of data transmission between the processor 901 and the machine-readable storage medium 902 via the bus, and is not intended to limit a specific connection method.
[0126] In this embodiment, the processor 901 can achieve the following by reading the machine executable instructions stored in the machine-readable storage medium 902 and running the machine executable instructions: applying the embodiment of the present application, by obtaining the image to be processed, and using the pre-trained network model to extract the target features from the image. Among them, the network model is obtained by adopting a data parallel training method, and using different hyperparameters set for different training stages to train multiple initial neural networks respectively. When training the network model, a data parallel training method is adopted, and different hyperparameters set for different training stages are used to train multiple initial neural networks respectively. For each initial neural network, there is no need to set a unified hyperparameter. The setting of the hyperparameter is more flexible, and the network model is less affected by the hyperparameter, thereby ensuring the accuracy of the network model. The target features are extracted using the trained network model, and the extracted target features are more accurate, thereby improving the accuracy of the image processing results.
[0127] In another embodiment provided in the present application, a machine-readable storage medium is also provided, which stores machine-executable instructions, and when called and executed by a processor, implements all steps of the target feature extraction method as described above.
[0128] In another embodiment provided by the present application, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute all the steps of the target feature extraction method described above.
[0129] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center by wired (such as coaxial cable, optical fiber, DSL (Digital Subscriber Line, digital subscriber line)) or wireless (such as infrared, wireless, microwave, etc.) mode to another website, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD (Digital Versatile Disc)), or a semiconductor medium (eg, an SSD (Solid State Disk)).
[0130] For the embodiments of the apparatus, computer equipment, machine-readable storage medium and computer program product, since the method contents involved are basically similar to the aforementioned method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0131] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0132] Each embodiment in this specification is described in a related manner. Similar portions between the various embodiments can be referenced to each other. Each embodiment focuses on the differences from other embodiments. In particular, the target feature extraction device, computer device, machine-readable storage medium, and computer program product embodiments are generally similar to the method embodiments, so their descriptions are relatively simple. For relevant portions, reference can be made to the descriptions of the method embodiments.
[0133] The above description is only a preferred embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application are included in the scope of protection of the present application.
Claims
1. A target feature extraction method, characterized in that: The method comprises: Get the image to be processed; Extracting target features from the image using a pre-trained network model; wherein the network model is obtained by training multiple initial neural networks using different hyperparameters set for different training stages using a data parallel training method; The training method of the network model includes: Using the same pre-set hyperparameters, multiple initial neural networks are trained in data parallel; When a preset first stopping condition is met, stopping the training of the multiple initial neural networks to obtain multiple updated neural networks; In each different training stage, the multiple updated neural networks are trained in parallel, and after each training stage is completed, the accuracy of each neural network trained in the training stage is tested, wherein the hyperparameters set for each updated neural network in each training stage are different; When a preset second stopping condition is met, the parallel training of the multiple updated neural networks is stopped, and a final trained network model is determined based on the network structure of the neural network with the highest accuracy among the neural networks trained in the last training phase; The step of training the multiple updated neural networks in parallel in each different training stage, and performing accuracy testing on each neural network trained in the training stage after each training stage is completed, includes: In each training phase, for each updated neural network, a single training is performed on the updated neural network using the hyperparameters corresponding to the updated neural network set according to the preset rules to obtain a neural network after the single training; After each training phase is completed, the accuracy of each neural network after single training is tested to determine the neural network with the highest accuracy trained in that training phase; The network weights of the neural network with the highest accuracy obtained in the training phase are copied to the neural networks after each single training; The neural networks after each single training are used as new updated neural networks to start parallel training of the next training stage. In other training stages except the first training stage, the hyperparameters corresponding to an updated neural network are set to the hyperparameters corresponding to the neural network with the highest accuracy obtained in the previous training stage.
2. The method according to claim 1, characterized in that The preset rules include: If the updated neural network is the neural network with the highest accuracy obtained in the previous training phase, the hyperparameters corresponding to the updated neural network remain unchanged; If the updated neural network is not the neural network with the highest accuracy obtained in the previous training phase, the hyperparameters corresponding to the updated neural network are randomly set.
3. The method according to claim 2, characterized in that The randomly setting of the hyperparameters corresponding to the updated neural network includes: The hyperparameters corresponding to the updated neural network are randomly set within a specified hyperparameter range, wherein the specified hyperparameter range is determined based on the hyperparameters corresponding to the neural network with the highest accuracy obtained by training in the previous training phase.
4. The method according to any one of claims 1 to 3, characterized in that: In each different training stage, the multiple updated neural networks are trained in parallel, and after each training stage is completed, the accuracy test of each neural network trained in the training stage is performed, and the method further includes: If the number of completed training stages reaches a preset threshold, the parallel training of the multiple updated neural networks is stopped, and the network model finally trained is determined based on the network structure of the neural network with the highest accuracy among the neural networks trained in the last training stage.
5. The method according to claim 1, wherein The parallel training of the multiple updated neural networks comprises: The multiple updated neural networks are trained in parallel using multiple GPUs, wherein each GPU is used to train one updated neural network.
6. The method according to claim 1, characterized in that After the step of extracting target features from the image using the pre-trained network model, the method further includes: Based on the target features, the target is identified to obtain a target identification result.
7. A target feature extraction device, characterized in that: The device comprises: An acquisition module, used for acquiring an image to be processed; A feature extraction module is configured to extract target features from the image using a pre-trained network model, wherein the network model is obtained by training multiple initial neural networks using different hyperparameters set for different training stages using a data parallel training method; The device further comprises: a training module; The training module is configured to perform data parallel training on multiple initial neural networks using the same preset hyperparameters; stop training the multiple initial neural networks when a preset first stopping condition is met, thereby obtaining multiple updated neural networks; perform parallel training on the multiple updated neural networks in each different training phase, and perform accuracy testing on each neural network obtained by training in the training phase after each training phase is completed, wherein different hyperparameters are set for each updated neural network in each training phase; stop training the multiple updated neural networks in parallel when a preset second stopping condition is met, and determine a final trained network model based on the network structure of the neural network with the highest accuracy among the neural networks obtained by training in the last training phase; The training module is specifically used to: In each training phase, for each updated neural network, a single training is performed on the updated neural network using the hyperparameters corresponding to the updated neural network set according to the preset rules to obtain a neural network after the single training; After each training phase is completed, the accuracy of each neural network after single training is tested to determine the neural network with the highest accuracy trained in that training phase; The network weights of the neural network with the highest accuracy obtained in the training phase are copied to the neural networks after each single training; The neural networks after each single training are used as new updated neural networks to start parallel training of the next training stage. In other training stages except the first training stage, the hyperparameters corresponding to an updated neural network are set to the hyperparameters corresponding to the neural network with the highest accuracy obtained in the previous training stage.
8. The device according to claim 7, characterized in that The preset rules include: If the updated neural network is the neural network with the highest accuracy obtained in the previous training phase, the hyperparameters corresponding to the updated neural network remain unchanged; If the updated neural network is not the neural network with the highest accuracy obtained in the previous training phase, the hyperparameters corresponding to the updated neural network are randomly set.
Citation Information
Patent Citations
Method and equipment for training convolutional neural network used for image recognition
CN106056529A