A model training method, apparatus, device, and storage medium
By combining offline data augmentation with batch iterative training and hard sample removal, the problems of storage space and time consumption were solved, improving the efficiency and effectiveness of model training, especially the ability to identify hard samples.
Patent Information
- Application Number
- CN202210205109.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-02
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2042-03-02
AI Technical Summary
Existing offline data augmentation methods consume a lot of storage space and take a long time, making it difficult to effectively mine dirty data and hard samples in the dataset, thus affecting the model training effect.
We use offline data augmentation to generate data augmentation samples and iteratively train the model by building training sets in batches to simulate the effect of online data augmentation. At the same time, we build hard sample sets and dirty datasets, remove hard samples and optimize the model.
While reducing storage consumption, it achieves the same rich augmentation effects as online data augmentation, improves the model's ability to identify difficult samples, removes dirty data, and improves model training efficiency.
Smart Images

Figure CN114565086B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of deep learning technology, specifically relating to a model training method, apparatus, device, and storage medium. Background Technology
[0002] During convolutional neural network training, data augmentation is used to enhance the model's generalization ability. Generally, offline or online data augmentation is employed during model training. Offline data augmentation involves performing one or more data augmentations on a portion or all of the training set before model training, generating a certain amount of augmented data, which is then saved and used as a new training set alongside the previous training set. The advantage of this method is that data augmentation is performed in advance, eliminating the need for additional time during model training. The disadvantage is the need to save the augmented data, which consumes more storage space as the dataset grows. Online data augmentation, on the other hand, involves performing one or more data augmentations on a portion or all of the training data in each batch during model training, before directly feeding it into the model. Different training methods can be used for each batch, and augmented data is regenerated each time without saving the augmented data. The advantage is that it does not require additional storage space, and the augmentation methods can differ for each batch, resulting in a richer dataset. The disadvantage is that additional time is spent on data augmentation before each batch. Furthermore, during model training, some dirty data inevitably appears in the dataset, interfering with the model and making it difficult to fit some hard samples. Therefore, how to effectively extract dirty data and hard samples from the dataset during training to improve model metrics is currently a hot research topic. Summary of the Invention
[0003] In view of the shortcomings of the prior art described above, the present invention provides a model training method, apparatus, device and storage medium to solve the defects of existing offline data augmentation methods, which consume more space and take longer.
[0004] To achieve the above and other related objectives, the present invention provides a model training method, the method comprising:
[0005] Obtain a first training set, which includes multiple first training samples;
[0006] Data augmentation is performed on each first training sample in the first training set to obtain a second training set; the second training set includes multiple second samples; wherein the first training sample and the corresponding second sample have the same number;
[0007] Multiple third training sets are constructed in batches, and the neural network model is trained iteratively multiple times using the multiple third training sets until the stopping condition is met; wherein, the third training samples in the third training sets are randomly selected from the first training set and / or the second training set, and each third training sample in the multiple third training sets has a different number.
[0008] During each training of the neural network model, the first training sample in the first training set is augmented to obtain an augmented sample; the augmented sample replaces the second training sample in the second training set that has the same number as the augmented sample; wherein the augmented first training sample has the same number as the second training sample in the third training set.
[0009] Optionally, the method further includes:
[0010] Constructing a difficult sample set;
[0011] Multiple fourth training sets are constructed in batches, and the neural network model is iteratively trained using the multiple fourth training sets until the stopping condition is met; wherein, the fourth training samples in the fourth training sets are randomly selected from the first training set or / and the second training set or / and the hard sample set, and each fourth training sample in the multiple fourth training sets has a different number.
[0012] Optionally, constructing the third training set includes:
[0013] Reorder the numbers of the second training samples in the second training set;
[0014] Select multiple numbers from the reordered numbers as the numbers of the third training samples in the third training set;
[0015] Select a first training sample or / and a second training sample corresponding to the plurality of numbers from the first training set or / and the second training set as a third training sample, and construct a third training set based on the third training sample.
[0016] Optionally, constructing the fourth training set includes:
[0017] Reorder the sample numbers in the second training set;
[0018] Select multiple numbers from the reordered numbers as the numbers of the fourth training samples in the fourth training set;
[0019] Select the first training sample and / or the second training sample and / or the hard sample from the first training set and / or the second training set and / or the hard sample set, corresponding to the plurality of numbers, as the fourth training sample, and construct the fourth training set based on the fourth training sample.
[0020] Optionally, if there exists a difficult sample in the difficult sample set that corresponds to one of the plurality of numbers, then the difficult sample with the corresponding number is selected from the difficult sample set;
[0021] If there are multiple difficult samples in the set of difficult samples that correspond to one of the multiple numbers, then a difficult sample is randomly selected from the multiple difficult samples;
[0022] If there is no difficult sample corresponding to the plurality of numbers in the difficult sample set, then the first training sample or / and the second training sample corresponding to the plurality of numbers are taken from the first training set or / and the second training set.
[0023] Optionally, when identifying the first and second training samples in the fourth training set using a neural network model, samples that are incorrectly identified or have a confidence level lower than a set confidence level are added to the difficult sample set.
[0024] When identifying the difficult samples in the fourth training set using a neural network model, the correctly identified samples are removed from the difficult sample set.
[0025] When identifying difficult samples in the fourth training set using a neural network model, samples that have been identified more than a set number of times are removed from the difficult sample set and retained in the dirty dataset.
[0026] Optionally, if a first training sample belonging to the first training set exists in the hard sample set, then only the link of the first training sample is retained.
[0027] To achieve the above and other related objectives, the present invention provides a model training apparatus, the apparatus comprising:
[0028] The training set acquisition module is used to acquire a first training set, which includes multiple first training samples.
[0029] A first augmentation module is used to augment the data of each first training sample in the first training set to obtain a second training set; the second training set includes multiple second samples; wherein the first training sample and the corresponding second sample have the same number;
[0030] The training set construction module is used to construct multiple third training sets in batches and use the multiple third training sets to iteratively train the neural network model multiple times until the stopping condition is met; wherein, the third training samples in the third training sets are randomly selected from the first training set and / or the second training set, and each third training sample in the multiple third training sets has a different number.
[0031] The second enhancement module is used to perform data augmentation on the first training sample of the first training set during each training of the neural network model to obtain an enhanced sample; and to replace the second training sample with the same number as the enhanced sample in the second training set with the enhanced sample; wherein the data-enhanced first training sample has the same number as the second training sample in the third training set.
[0032] To achieve the above and other related objectives, the present invention provides a model training device, characterized in that it comprises:
[0033] Memory, used to store computer programs;
[0034] A processor is configured to execute a computer program stored in the memory to cause the device to perform the model training method.
[0035] To achieve the above and other related objectives, the present invention provides a storage medium for storing a computer program, which is executed by a processor to perform the model training method.
[0036] As described above, the model training method, apparatus, and storage medium of the present invention have the following beneficial effects:
[0037] A model training method according to the present invention includes: acquiring a first training set, the first training set including a plurality of first training samples; performing data augmentation on each first training sample in the first training set to obtain a second training set; the second training set including a plurality of second samples; wherein the first training samples and the corresponding second samples have the same number; constructing a plurality of third training sets in batches, and using the plurality of third training sets to perform multiple iterative training on a neural network model until a stopping condition is met; wherein the third training samples in the third training sets are randomly selected from the first training set and / or the second training set, and the number of each third training sample in the plurality of third training sets is different; in each training process of the neural network model, performing data augmentation on the first training samples in the first training set to obtain augmented samples; replacing the second training samples in the second training set that have the same number as the augmented samples with the augmented samples with the augmented samples; wherein the data-augmented first training samples have the same number as the second training samples in the third training sets. This invention provides a model training method that simulates the data augmentation sample generation strategy of online data augmentation using offline data augmentation. It achieves the same rich augmentation effect as online data augmentation with less storage consumption than offline data augmentation. Compared to online data augmentation, the generation of data augmentation samples is parallel to model training, without adding extra training time costs. This invention also proposes a dirty data and hard sample mining method to extract hard and dirty samples from the dataset, enhancing the model's ability to identify hard samples and removing dirty data from the dataset. Attached Figure Description
[0038] Figure 1 This is a flowchart of a model training method in one embodiment of the present invention;
[0039] Figure 2 This is a diagram showing the correspondence between the first training set, the second training set, and the hard sample set in one embodiment of the present invention.
[0040] Figure 3 This is a flowchart of constructing the fourth training set in one embodiment of the present invention;
[0041] Figure 4 This is a flowchart of constructing the fourth training set in one embodiment of the present invention;
[0042] Figure 5 This is a schematic diagram of a model training device according to an embodiment of the present invention. Detailed Implementation
[0043] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that, unless otherwise specified, the following embodiments and features described therein can be combined with each other.
[0044] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0045] like Figure 1 As shown in the embodiment of this application, a model training method is provided, the method comprising:
[0046] S100 Obtains a first training set, which includes multiple first training samples;
[0047] S101 performs data augmentation on each first training sample in the first training set to obtain a second training set; the second training set includes multiple second samples; wherein, the first training sample and the corresponding second sample have the same number;
[0048] S102 constructs multiple third training sets in batches and uses the multiple third training sets to iteratively train the neural network model multiple times until the stopping condition is met; wherein, the third training samples in the third training sets are randomly selected from the first training set and / or the second training set, and each third training sample in the multiple third training sets has a different number.
[0049] S103 In each training process of the neural network model, the first training sample in the first training set is augmented to obtain an augmented sample; the augmented sample replaces the second training sample in the second training set that has the same number as the augmented sample; wherein, the augmented first training sample has the same number as the second training sample in the third training set.
[0050] The present invention provides a model training method that simulates the data augmentation sample generation strategy of online data augmentation in an offline data augmentation manner; it achieves the same rich augmentation effect as online data augmentation with less storage consumption than offline data augmentation; at the same time, compared with online data augmentation, the generation of data augmentation samples is carried out in parallel with model training, without increasing the additional training time cost.
[0051] The following provides a detailed explanation of each step.
[0052] In step S100, a first training set is obtained, which includes multiple first training samples;
[0053] The first training sample can be understood as a collection of image data. This image data can be images of the same object under different angles, environmental conditions, and pixel colors. Of course, it can also be images of different objects or in different scenes; this embodiment of the application does not impose any limitations on this.
[0054] In step S101, data augmentation is performed on each first training sample in the first training set to obtain a second training set; the second training set includes multiple second samples; wherein the first training sample and the corresponding second sample have the same number;
[0055] Data augmentation involves using computer vision methods to transform existing image data to obtain new, equivalent data that is highly correlated with the original data. In this embodiment, the data augmentation strategy includes one of the following: cropping, rotation, translation, flipping, sharpening, lighting, and occlusion. For example, the data augmentation strategy may include cropping, rotation, translation, flipping, sharpening, lighting, or occlusion. Different first training samples can use different data augmentation strategies, or they can use the same data augmentation strategy; it is sufficient that only one data augmentation strategy is used for each training sample.
[0056] Specifically, the construction of the second training set can be accomplished using the following method:
[0057] First, determine the data augmentation strategy to be used during model training. Then, use this data augmentation strategy to perform data augmentation once on each training sample (i.e., each image) in the first training set train_origin, to obtain a sample set train_aug of the same size as the first training set train_origin, which is denoted as the second training set and saved locally. The second training samples in the second training set train_aug correspond one-to-one with the second training samples in the first training set train_origin. Figure 2 This is a mapping diagram between the first training set Train_origin and the second training set train_aug. Images in the first and second training sets that have a mapping relationship share the same number.
[0058] In step S102, multiple third training sets are constructed in batches, and the neural network model is trained iteratively multiple times using the multiple third training sets until the stopping condition is met; wherein, the third training samples in the third training sets are randomly selected from the first training set and / or the second training set, and each third training sample in the multiple third training sets has a different number.
[0059] In one embodiment, such as Figure 3 As shown, constructing the third training set includes:
[0060] S300 reorders the numbers of the second training samples in the second training set;
[0061] S301 Selects multiple numbers from the reordered numbers as the numbers of the third training samples in the third training set;
[0062] S302 Selects a first training sample or / and a second training sample corresponding to the plurality of numbers from the first training set or / and the second training set as a third training sample, and constructs a third training set based on the third training sample.
[0063] Specifically, multiple third training sets are constructed in batches, and the neural network model is trained iteratively multiple times using the multiple third training sets until the stopping condition is met, including the following steps:
[0064] Step 3.1: Assuming the number of samples in the first training set train_origin is n, then the sample numbers in the first training set train_origin and the second training set train_aug are a = [1, n]. Randomly shuffle a to obtain a new numbering order b.
[0065] b = shuffle(a)
[0066] Step 3.2: Since the model training is batch training—that is, the entire training set is divided into multiple subsets—the model is trained using the first subset during the first training iteration, then the second subset, and so on, until the model training is complete. Therefore, the first bs numbers from b are taken to form bs_c, and the elements in b are shifted left by bs positions. Steps 3.1 and 3.2 ensure that each image is learned the same number of times throughout the training process.
[0067] Step 3.3: Based on bs_c, select a total of bs training samples from the first training set train_origin and the second training set train_aug to form the third training set bs_set. The specific selection process is as follows: iterate through the numbers in bs_c and randomly select the corresponding training sample from either the first training set train_origin or the second training set train_aug. The probability that a sample corresponding to each number comes from either the first training set train_origin or the second training set train_aug can be the same or unequal. Step 3.3 ensures that the training samples in the third training set bs_set of each training batch do not coexist with other samples. Figure 2 The correspondence expressed.
[0068] bs_set∈(train_origin∪train_aug)
[0069] Step 3.4: Input a batch of the third training set bs_set into the neural network model to train the neural network model.
[0070] Step 3.5: Repeat steps 3.2 to 3.4 for m iterations or until other stopping conditions are triggered.
[0071] In step S103, during each training of the neural network model, the first training sample in the first training set is augmented to obtain an augmented sample; the augmented sample replaces the second training sample in the second training set that has the same number as the augmented sample; wherein, the augmented first training sample has the same number as the second training sample in the third training set.
[0072] Specifically, the training sample IDs from the second training set `train_aug` are selected from `bs_set` and denoted as `bs_c_aug`. Simultaneously, a data augmentation thread performs data augmentation on the images in the first training set `train_origin` whose IDs are in `bs_c_aug`. The resulting images replace the samples with the same IDs in the second training set `train_aug`. This ensures that the images in the second training set `train_aug` are untrained, and each time the same ID image is taken from `train_aug`, it is generated by a different data augmentation strategy, thus achieving online data augmentation. Furthermore, the number of images in the second training set `train_aug` remains constant, and the storage space occupied remains unchanged. In addition, model training is generally performed on the GPU, while data augmentation is generally performed on the CPU; their parallel execution does not slow down the model training speed. Theoretically, half of the training images in each batch come from the second training set `train_aug`, so the parallel data augmentation thread only needs to generate approximately `bs / 2` images each time, and the CPU's speed in generating data-augmented images can keep up with the pace of model training.
[0073] bs_c_aug={a|a∈bs_c, bs_set[a]∈traln_aug}
[0074] After step S103, the neural network model has fitted most of the data and can accurately predict most of the original data and data augmentation data. The main challenge at this point is the difficult samples that have not yet been fitted by the model. Based on this, this application also provides the following method, including:
[0075] A hard sample set is constructed; multiple fourth training sets are constructed in batches, and the neural network model is iteratively trained using the multiple fourth training sets until a stopping condition is met; wherein, the fourth training samples in the fourth training sets are randomly selected from the first training set and / or the second training set and / or the hard sample set, and each fourth training sample in the multiple fourth training sets has a different number. It should be noted that, at this time, the hard sample set is empty when it is initially constructed.
[0076] In one embodiment, such as Figure 4 As shown, constructing the fourth training set includes:
[0077] S400 reorders the numbering of the samples in the second training set;
[0078] S401 selects multiple numbers from the reordered numbers as the numbers of the fourth training samples in the fourth training set;
[0079] S402 selects a first training sample or / and a second training sample or / and a difficult sample corresponding to the plurality of numbers from the first training set or / and the second training set or / and the difficult sample set as a fourth training sample, and constructs a fourth training set based on the fourth training sample.
[0080] In one embodiment, if a difficult sample corresponding to one of the plurality of numbers exists in the difficult sample set, then the difficult sample with the corresponding number is selected from the difficult sample set;
[0081] If there are multiple difficult samples in the set of difficult samples that correspond to one of the multiple numbers, then a difficult sample is randomly selected from the multiple difficult samples;
[0082] If there is no difficult sample corresponding to the plurality of numbers in the difficult sample set, then the first training sample or / and the second training sample corresponding to the plurality of numbers are taken from the first training set or / and the second training set.
[0083] In one embodiment, when identifying the first training samples and the second training samples in the fourth training set using a neural network model, samples that are incorrectly identified or have a confidence level lower than a set confidence level are added to the hard sample set; when identifying the hard samples in the fourth training set using a neural network model, correctly identified samples are deleted from the hard sample set; when identifying the hard samples in the fourth training set using a neural network model, samples that have been identified more than a set number of times are deleted from the hard sample set and retained in the dirty dataset.
[0084] Specifically, multiple fourth training sets are constructed in batches, and the neural network model is iteratively trained using these multiple fourth training sets until a stopping condition is met, including the following steps:
[0085] Step 4.1: Assuming the number of samples in the first training set train_origin is n, the sample numbers in the first training set train_origin and the second training set train_aug are a1 = [1, n]. Randomly shuffle a1 to obtain a new numbering order b1.
[0086] b1 = shuffle(a)
[0087] Step 4.2: Since the model training is batch-based, meaning the entire training set is divided into multiple subsets, the model is trained using the first subset during the first training iteration, then the second subset, and so on, until training is complete. Therefore, the first bs1 numbers from b1 are taken to form bs_c1, and the elements in b1 are shifted left by bs1 positions. Steps 4.1 and 4.2 ensure that each image is learned a consistent number of times throughout the training process.
[0088] Step 4.3: Based on bs_c1, select a total of bs1 training samples from the first training set train_origin, the second training set train_aug, and the hard set train_hard to form the fourth training set bs_set1. Specifically, iterate through the numbers in bs_c1. If an image with that number exists in the hard set train_hard, retrieve the corresponding sample from train_hard. If multiple images with that number exist in train_hard, randomly select one. If no image with that number exists in train_hard, randomly retrieve the corresponding training sample from either the first training set train_origin or the second training set train_aug. Step 4.3 also ensures that the training samples in the image set bs_set1 of each training batch do not coexist with other samples. Figure 2 The correspondence expressed.
[0089] Step 4.4: Input a batch of the fourth training set bs_set1 into the neural network model to train the neural network model.
[0090] Step 4.5: Record the inference results corresponding to each batch of images. Add the images that were originally in the first training set train_origin and the second training set train_aug from bs_set1, which were incorrectly identified by the neural network model or whose confidence level was lower than the set confidence level c_t (hard samples), to the hard sample set train_hard and save them, maintaining the corresponding numbering relationship.
[0091] Images in bs_set1 that were originally in the hard dataset train_hard and were correctly identified by the neural network model are removed from the hard dataset train_hard. The number of training iterations for images in bs_set1 that belong to train_hard is recorded. When the number of training iterations e for an image in train_hard exceeds a set number et, it can be considered a hard sample that deviates from the overall data distribution and may be potentially dirty data. This data is then removed from the hard dataset train_hard and retained in the dirty dataset train_dirty for later analysis. It should be noted that the dirty dataset train_dirty is initially empty; that is, it is empty when the model is trained using the first batch of data.
[0092] Regarding the memory space occupied by the hard sample set `train_hard`, considering the extreme case, as the hard sample set `train_hard` gradually increases and includes all the images with all numbers, each batch of training samples will all come from the hard sample set `train_hard`. After this batch of training, no new hard samples will be added to the hard sample set `train_hard`, and the hard sample set `train_hard` will no longer increase in size, and its space usage will not increase again. Theoretically, the maximum storage space occupied by the hard sample set `train_hard` is comparable to the size of the original dataset. Furthermore, for images in the hard sample set `train_hard` that belong to the first training set `train_origin`, only the image links need to be retained, further reducing the storage space occupied. In summary, in step 4.5, when selecting hard samples, the storage space occupied by the hard sample set `train_hard` will be controlled within a reasonable range. In addition, after all training is completed, the aforementioned dirty dataset `train_dirty` and the datasets in the hard sample set `train_hard` can be retained for manual analysis to provide a basis for the next batch of training.
[0093] Step 4.6: Repeat steps 4.1 to 4.5 until the stop condition is triggered.
[0094] To achieve the above and other related objectives, the present invention provides a model training apparatus, such as... Figure 5 The device includes:
[0095] The training set acquisition module 500 is used to acquire a first training set, which includes multiple first training samples.
[0096] The first enhancement module 501 is used to enhance each first training sample in the first training set to obtain a second training set; the second training set includes multiple second samples; wherein the first training sample and the corresponding second sample have the same number.
[0097] The training set construction module 502 is used to construct multiple third training sets in batches and use the multiple third training sets to perform multiple iterative trainings on the neural network model until the stopping condition is met; wherein, the third training samples in the third training sets are randomly selected from the first training set and / or the second training set, and each third training sample in the multiple third training sets has a different number.
[0098] The second enhancement module 503 is used to enhance the first training sample in the first training set during each training of the neural network model to obtain an enhanced sample; and replace the second training sample in the second training set that has the same number as the enhanced sample with the enhanced sample; wherein the enhanced first training sample has the same number as the second training sample in the third training set.
[0099] It should be noted that since the embodiments of the apparatus part correspond to the embodiments of the method part, the content of the embodiments of the apparatus part can be found in the description of the embodiments of the method part, and will not be repeated here.
[0100] The present invention also provides a storage medium for storing a computer program, which is executed by a processor to perform the aforementioned model training method.
[0101] The present invention also provides an apparatus comprising:
[0102] Memory, used to store computer programs;
[0103] A processor is configured to execute a computer program stored in the memory to cause the device to perform the aforementioned model training method.
[0104] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0105] The memory can be an internal storage unit or an external storage device, such as a plug-in hard drive, a smart media card (SMC), a secure digital card (SD), or a flash card. Furthermore, the memory may include both internal storage units and external storage devices. The memory is used to store the computer program, as well as other programs and data. The memory can also be used to temporarily store data that has been output or will be output.
[0106] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0107] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0108] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0109] In the embodiments provided by this invention, it should be understood that the disclosed apparatus / terminal devices and methods can be implemented in other ways. For example, the apparatus / terminal device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0110] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0111] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0112] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0113] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in the present invention should still be covered by the claims of the present invention.
Claims
1. A model training method, characterized in that, The method includes: Obtain a first training set, which includes multiple first training samples; the first training samples are a collection of image data. Data augmentation is performed on each first training sample in the first training set to obtain a second training set; the second training set includes multiple second samples; wherein the first training sample and the corresponding second sample have the same number; Multiple third training sets are constructed in batches, and the neural network model is trained iteratively multiple times using the multiple third training sets until the stopping condition is met; wherein, the third training samples in the third training sets are randomly selected from the first training set and / or the second training set, and each third training sample in the multiple third training sets has a different number. During each training of the neural network model, the first training sample in the first training set is augmented in parallel by a data augmentation thread to obtain an augmented sample; the augmented sample replaces the second training sample in the second training set that has the same number as the augmented sample; wherein the first training sample after data augmentation has the same number as the second training sample in the third training set.
2. The model training method according to claim 1, characterized in that, The method further includes: Constructing a difficult sample set; Multiple fourth training sets are constructed in batches, and the neural network model is iteratively trained using the multiple fourth training sets until the stopping condition is met; wherein, the fourth training samples in the fourth training sets are randomly selected from the first training set or / and the second training set or / and the hard sample set, and each fourth training sample in the multiple fourth training sets has a different number.
3. The model training method according to claim 1, characterized in that, Constructing the third training set includes: Reorder the numbers of the second training samples in the second training set; Select multiple numbers from the reordered numbers as the numbers of the third training samples in the third training set; Select a first training sample or / and a second training sample corresponding to the plurality of numbers from the first training set or / and the second training set as a third training sample, and construct a third training set based on the third training sample.
4. The model training method according to claim 2, characterized in that, Constructing the fourth training set includes: Reorder the sample numbers in the second training set; Select multiple numbers from the reordered numbers as the numbers of the fourth training samples in the fourth training set; Select the first training sample and / or the second training sample and / or the hard sample from the first training set and / or the second training set and / or the hard sample set, corresponding to the plurality of numbers, as the fourth training sample, and construct the fourth training set based on the fourth training sample.
5. The model training method according to claim 4, characterized in that, If a difficult sample with a corresponding number exists in the set of difficult samples, then the difficult sample with the corresponding number is selected from the set of difficult samples. If there are multiple difficult samples in the set of difficult samples that correspond to one of the multiple numbers, then a difficult sample is randomly selected from the multiple difficult samples; If there is no difficult sample corresponding to the plurality of numbers in the difficult sample set, then the first training sample or / and the second training sample corresponding to the plurality of numbers are taken from the first training set or / and the second training set.
6. The model training method according to claim 2, characterized in that, When identifying the first and second training samples in the fourth training set using a neural network model, samples that are identified incorrectly or have a confidence level lower than a set confidence level are added to the difficult sample set. When identifying the difficult samples in the fourth training set using a neural network model, the correctly identified samples are removed from the difficult sample set. When identifying difficult samples in the fourth training set using a neural network model, samples that have been identified more than a set number of times are removed from the difficult sample set and retained in the dirty dataset.
7. The model training method according to claim 6, characterized in that, If a first training sample belonging to the first training set exists in the set of difficult samples, then only the link of the first training sample is retained.
8. A model training device, characterized in that, The device includes: The training set acquisition module is used to acquire a first training set, which includes multiple first training samples; the first training samples are a collection of image data. A first augmentation module is used to augment the data of each first training sample in the first training set to obtain a second training set; the second training set includes multiple second samples; wherein the first training sample and the corresponding second sample have the same number; The training set construction module is used to construct multiple third training sets in batches and use the multiple third training sets to iteratively train the neural network model multiple times until the stopping condition is met; wherein, the third training samples in the third training sets are randomly selected from the first training set and / or the second training set, and each third training sample in the multiple third training sets has a different number. The second enhancement module is used to perform data enhancement on the first training sample of the first training set in parallel through the data enhancement thread during each training of the neural network model, to obtain an enhanced sample; and to replace the second training sample with the same number as the enhanced sample in the second training set with the enhanced sample; wherein the data-enhanced first training sample has the same number as the second training sample in the third training set.
9. A model training device, characterized in that, include: Memory, used to store computer programs; A processor for executing a computer program stored in the memory to cause the device to perform the model training method as described in any one of claims 1 to 7.
10. A storage medium for storing computer programs, characterized in that, The computer program is executed by the processor to perform the model training method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Neural network model training method and device, computer equipment and storage medium
CN109840588A
Adversarial interpolation sequence-based annotation data enhancement method and device, equipment and medium
CN113297355A