Method and system for automatically generating high-quality labeled data using a generative adversarial network
By alternately training the generator and discriminator using a generative adversarial network (GAN), high-quality labeled data is generated, solving the problem of high manual labeling costs in traditional methods and achieving efficient labeled data generation and model training.
Patent Information
- Application Number
- CN202510013219.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-06
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2045-01-06
AI Technical Summary
Traditional machine learning and deep learning models rely on a large amount of manually labeled data, which is costly, especially in high-precision application scenarios. Existing technologies are unable to efficiently generate high-quality labeled data.
Generative Adversarial Networks (GANs) are used to construct generators and discriminators. By training the generator and discriminator alternately, labeled data that closely approximates the real data distribution is generated. Gradient descent is used to optimize the network parameters, thereby gradually improving the labeling quality.
It reduces the need for manually labeled data, significantly lowers labeling costs, and improves model training efficiency, making it suitable for fields such as autonomous driving and medical image analysis.
Smart Images

Figure CN119810557B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data annotation, in particular to a method and system for automatically generating high-quality annotated data using a generative adversarial network. BACKGROUND
[0002] Traditional machine learning and deep learning models rely on a large amount of manually annotated data for training, especially in applications involving complex data types such as images, text, and audio. The process of obtaining annotated data is often time-consuming and costly, especially in high-precision application scenarios such as medical imaging and autonomous driving. Therefore, reducing the demand for manually annotated data and developing technology that can automatically generate high-quality annotated data is crucial.
[0003] Generative adversarial networks (GANs) train generator and discriminator models to oppose each other, causing the generated virtual data to gradually approach the distribution of real data. This technology has great potential in generating annotated data, greatly reducing the need for manual annotation, reducing data annotation costs, and improving model training efficiency. SUMMARY
[0004] The present application addresses the needs and deficiencies of current technology by providing a method and system for automatically generating high-quality annotated data using a generative adversarial network to output high-quality annotated data for training downstream machine learning models.
[0005] In a first aspect, the present application provides a method for automatically generating high-quality annotated data using a generative adversarial network, which solves the above technical problems by adopting the following technical solutions:
[0006] A method for automatically generating high-quality annotated data using a generative adversarial network includes the following steps:
[0007] S1, data collection and enhancement;
[0008] S2, constructing a generative adversarial network;
[0009] S3, using small-scale annotated data to preliminarily train the generator and discriminator of the generative adversarial network, so that the generator can generate synthetic data with preliminary annotations, and the discriminator can distinguish the difference between the generated annotated data and the real annotated data;
[0010] S4, cyclically training the generator and discriminator, and performing annotation optimization based on the discriminator's evaluation of the accuracy of the generated data annotations, by continuously adjusting network parameters and optimizing loss functions, the generator and discriminator gradually reach a balanced state during training;
[0011] S5, using the generated adversarial network trained to label the collected data, and using the labeled data to train the downstream machine learning model.
[0012] Optionally, the step S2 specifically comprises:
[0013] The generator is constructed, including: selecting a random number generator and initializing a seed, generating a random Gaussian noise vector as an input, selecting a network architecture according to the generated data properties, designing an output layer matching the data type, and adding a module capable of automatically generating annotation information;
[0014] The discriminator is constructed, including: taking the real data and the data generated by the generator as inputs, extracting spatial features according to different data selection algorithms, and outputting the data authenticity and annotation accuracy.
[0015] Optionally, the step S3 specifically comprises:
[0016] S3.1, select part of the training data for manual annotation, denoted as data set X={(x1,y1),(x1,y2),...,(x n ,y n )}, wherein x i is the input data, and y i is the real annotation data;
[0017] S3.2, the generator G is a neural network-based model, taking the unlabeled data x in the data set X as the input of the generator G. The generator G first outputs the generated annotation Then, the loss between the generated annotation and the real annotation y i is calculated through a pre-defined annotation loss function, and then the network parameters of the generator G are continuously adjusted by minimizing the annotation loss, so as to gradually learn how to generate more accurate preliminary annotations;
[0018] S3.3, the discriminator D is a neural network-based model, taking the paired data (x,y) and as the input of the discriminator D, wherein (x,y) represents a pair composed of input data and real annotation, represents a pair composed of input data and generated annotation; the discriminator D maximizes the real annotation probability and minimizes the probability that the generated annotation is judged to be real through a pre-defined authenticity loss function, thereby outputting a loss function value D=(x,y), and the loss function value D=(x,y) represents the probability that the input annotation is real annotation.
[0019] In the process of performing steps S3.2 and S3.3, the gradient descent method is used to optimize the labeling loss function of the generator and the authenticity loss function of the discriminator, respectively; in optimizing the generator loss function, the labeling loss of the generator is taken as the target, the gradient with respect to the network parameters of the generator is calculated, and then the parameters of the generator are updated according to the gradient descent strategy; in optimizing the discriminator loss function, the discrimination loss of the discriminator is taken as the target, the gradient with respect to the network parameters of the discriminator is calculated, and then the parameters of the discriminator are adjusted according to the gradient descent strategy.
[0020] Further optionally, the pre-defined labeling loss function is represented as follows:
[0021]
[0022] wherein n represents the number of samples, y i represents the real label, G(x i ) represents the label generated by the generator G according to the input data x i .
[0023] The pre-defined authenticity loss function is represented as follows:
[0024]
[0025] wherein n represents the number of samples, i represents the i-th sample, y i represents the real label, G(x i ) represents the label generated by the generator G according to the input data x i , logD(x i , y i ) represents the logarithm of the probability that the real sample pair D(x i , y i ) is judged as real by the discriminator, (x i , G(x i )) represents the generated sample pair, and log(1-D(x i , G(x i ))) represents the logarithm of the probability that the generated sample pair (x i , G(x i )) is judged as false by the discriminator.
[0026] Based on the labeling loss function and the authenticity loss function, the joint loss function is represented as follows:
[0027] L joint =αL G +βL Greal ,
[0028] wherein α and β are weight coefficients, both of which are taken as values between 0 and 1, and 0 and 1 are included, and α+β=1.
[0029] Further optionally, the step S4 specifically comprises:
[0030] S4.1, training the discriminator: fixing the parameters of the generator, training the discriminator using the real data and the labeled data generated by the generator, calculating the output of the discriminator on the real data and the generated data, and calculating the loss value according to the authenticity loss function, updating the parameters of the discriminator according to the calculated loss value by using the back propagation algorithm;
[0031] S4.2, training the generator: fixing the parameters of the discriminator, the generator generates labeled data based on the input real data, sends the labeled data generated by the generator into the discriminator for calculation, obtains the output result of the discriminator, and calculates the loss value of the generator on these data according to the joint loss function, and updates the parameters of the generator according to the loss value by using the back propagation algorithm;
[0032] S4.3, label optimization: according to the evaluation of the accuracy of the labeled data generated by the discriminator, adjusting the parameters of the generator labeling module and the feedback parameters of the discriminator, so as to make the labeling more accurate;
[0033] S4.4, cyclic alternating training, repeating steps S4.1-S4.3, so that the generator and the discriminator reach balance.
[0034] In a second aspect, the present application provides a system for automatically generating high-quality labeled data by using a generative adversarial network, which solves the above technical problems by adopting the following technical solutions:
[0035] A system for automatically generating high-quality labeled data by using a generative adversarial network, comprising:
[0036] A data acquisition and enhancement module for data acquisition and enhancement;
[0037] A network construction module for constructing a generative adversarial network;
[0038] A preliminary training module for preliminarily training the generator and the discriminator of the generative adversarial network by using small-scale labeled data, so that the generator can generate synthetic data with preliminary labeling, and the discriminator can distinguish the difference between the generated labeled data and the real labeled data;
[0039] An alternating training module for cyclically training the discriminator and the generator, and updating the parameters of the discriminator and the generator by using the back propagation algorithm;
[0040] A labeling optimization module for labeling optimization according to the evaluation of the accuracy of the labeled data generated by the discriminator, and constantly adjusting the network parameters and optimizing the loss function, so that the generator and the discriminator gradually reach a balanced state in the training process;
[0041] The model output module is configured to label the collected data using the trained generative adversarial network, and the labeled data is used to train a downstream machine learning model.
[0042] Optionally, the network construction module specifically includes:
[0043] The generator construction unit is configured to construct the generator, and the specific operations include: selecting a random number generator and initializing a seed, generating a random Gaussian noise vector as an input, selecting a network architecture according to the generated data properties, designing an output layer matching the data type, and adding a module capable of automatically generating labeled information;
[0044] The discriminator construction unit is configured to construct the discriminator, and the specific operations include: taking the real data and the data generated by the generator as inputs, extracting spatial features according to different data selection algorithms, and outputting the data authenticity and the labeling accuracy.
[0045] Optionally, the preliminary training module specifically performs the following operations to preliminarily train the generator and the discriminator:
[0046] Part of the training data is manually labeled, denoted as a data set X={(x1,y1),(x1,y2),...,(x n ,y n )}, wherein x i is input data, and y i is real labeled data;
[0047] The generator G is a neural network-based model, taking the unlabeled data x in the data set X as the input of the generator G. The generator G first outputs the generated label Then, the loss between the generated label and the real label y i is calculated through a pre-defined labeling loss function, and then the network parameters of the generator G are continuously adjusted by minimizing the labeling loss, so as to gradually learn how to generate more accurate preliminary labels.
[0048] The discriminator D is a neural network-based model, taking the paired data (x,y) and as the input of the discriminator D, wherein (x,y) represents a pair of input data and real labels, represents a pair of input data and generated labels; the discriminator D maximizes the real label probability and minimizes the probability that the generated label is judged as real through a pre-defined authenticity loss function, thereby outputting a loss function value D=(x,y). The loss function value D=(x,y) represents the probability that the input label is a real label.
[0049] In the preliminary training process, the gradient descent method is used to optimize the annotation loss function of the generator and the authenticity loss function of the discriminator respectively;
[0050] In optimizing the generator loss function, the annotation loss of the generator is targeted, the gradient with respect to the network parameters of the generator is calculated, and then the parameters of the generator are updated according to the gradient descent strategy;
[0051] In optimizing the discriminator loss function, the discrimination loss of the discriminator is targeted, the gradient with respect to the network parameters of the discriminator is calculated, and then the parameters of the discriminator are adjusted according to the gradient descent strategy.
[0052] Further optionally, the pre-defined annotation loss function is represented as follows:
[0053]
[0054] Wherein, n represents the number of samples, y i represents the real annotation, G(x i ) represents the annotation generated by the generator G according to the input data x i ;
[0055] The pre-defined authenticity loss function is represented as follows:
[0056]
[0057] Wherein, n represents the number of samples, i represents the i-th sample, y i represents the real annotation, G(x i ) represents the annotation generated by the generator G according to the input data x i ; logD(x i ,y i ) represents the logarithm of the probability that the real sample pair D(x i ,y i ) is judged as real by the discriminator, (x i ,G(x i )) represents the generated sample pair, and log(1-D(x i ,G(x i ))) represents the logarithm of the probability that the generated sample pair (x i ,G(x i )) is judged as false by the discriminator;
[0058] Based on the annotation loss function and the authenticity loss function, the joint loss function is represented as follows:
[0059] L joint =αL G +βL Greal ,
[0060] Wherein, alpha and beta are weight coefficients, both of which are taken as values between 0-1, and 0 and 1 are included, alpha+beta=1.
[0061] Optionally, when the alternating training module involved trains the discriminator, the parameters of the generator are fixed, the discriminator is trained using the real data and the labeled data generated by the generator, the output of the discriminator to the real data and the generated data is calculated, and the loss value is calculated according to the authenticity loss function, and the parameters of the discriminator are updated according to the loss value calculated by using the back propagation algorithm.
[0062] When the alternating training module involved trains the generator, the parameters of the discriminator are fixed, the generator generates labeled data based on the input real data, the labeled data generated by the generator is sent into the discriminator for calculation, the output result of the discriminator is obtained, and the loss value of the generator on these data is calculated according to the joint loss function, and the parameters of the generator are updated according to the loss value by using the back propagation algorithm.
[0063] The method and system for automatically generating high-quality labeled data by using the generative adversarial network have the beneficial effects compared with the prior art:
[0064] 1. The generator is used to generate labeled data, and the discriminator is used to evaluate the labeling quality of the labeled data, so that high-quality labeled data close to the quality of artificial labeling is gradually generated, thereby greatly reducing the demand for artificial labeled data;
[0065] 2. The present application can significantly reduce the workload of artificial labeling in various application scenarios, and effectively improve the quality of labeled data and the efficiency of model training, and is not limited to application to the fields of automatic driving, medical image analysis, intelligent monitoring, etc., meets the demand for high-quality and large-scale data labeling, and reduces the development cost. BRIEF DESCRIPTION OF DRAWINGS
[0066] Figure 1 is a method flowchart of the present application embodiment one; Figure 1 Figure 2 is a module connection block diagram of the present application embodiment one;
[0067] Figure 3 is a method flowchart of the present application embodiment two; Figure 2 Figure 4 is a module connection block diagram of the present application embodiment two. DETAILED DESCRIPTION
[0068] In order to make the technical solutions, technical problems solved and technical effects of the present application clearer, the technical solutions of the present application are described in detail below in combination with specific embodiments.
[0069] Embodiment one:
[0070] In combination with Figure 1, the present embodiment proposes a method for automatically generating high-quality labeled data by using the generative adversarial network, which comprises the following steps: Figure 1
[0071] S1, data collection and enhancement.
[0072] This step collects as much diverse data as possible, such as image data, text data and voice data, to ensure that the generator can access different types of data distribution, thereby generating more diverse samples. At the same time, the collected data (also known as real data) is rotated, scaled and cropped for enhancement processing to increase the diversity and complexity of the training data, which helps to improve the generalization ability of the generator.
[0073] S2, constructing a generative adversarial network, specifically including:
[0074] Constructing the generator, including: selecting a random number generator and initializing the seed, generating a random Gaussian noise vector as input, selecting a network architecture according to the nature of the generated data, designing an output layer matching the data type, and adding a module that can automatically generate annotation information;
[0075] Constructing the discriminator, including: taking real data and data generated by the generator as input, extracting spatial features according to different data selection algorithms, and outputting data authenticity and annotation accuracy in the output layer.
[0076] S3, using small-scale labeled data to preliminarily train the generator and discriminator of the generative adversarial network, so that the generator can generate synthetic data with preliminary annotations, and the discriminator can distinguish the difference between the generated annotation data and the real annotation data.
[0077] This step specifically includes:
[0078] S3.1, select part of the training data for manual annotation, denoted as data set X = {(x1, y1), (x1, y2),..., (x n , y n )}, where x i is the input data, and y i is the real annotation data;
[0079] S3.2, the generator G is a neural network-based model that takes unlabeled data x in the data set X as input. The generator G first outputs the generated annotation Then calculate the loss between the generated annotation and the real annotation y i by a pre-defined annotation loss function, and then continuously adjust its network parameters by minimizing this annotation loss, so as to gradually learn how to generate more accurate preliminary annotations;
[0080] The pre-defined annotation loss function is represented as follows:
[0081]
[0082] where n denotes the number of samples, i denotes the i-th sample, y i denotes the real label, G(x i ) denotes the label generated by the generator G according to the input data x i ;
[0083] S3.3, the discriminator D is a neural network-based model to maximize the probability of the real label and minimize the probability of the generated label being judged as real, according to the pair of data (x, y) and as the input of the discriminator D, where (x, y) denotes a pair composed of the input data and the real label, denotes a pair composed of the input data and the label generated by the generator; the discriminator D outputs a loss function value D = (x, y) by maximizing the probability of the real label and minimizing the probability of the generated label being judged as real according to a predefined authenticity loss function, where the loss function value D = (x, y) denotes the probability of the input label being the real label;
[0084] The predefined authenticity loss function is represented as follows:
[0085]
[0086] where n denotes the number of samples, i denotes the i-th sample, y i denotes the real label, G(x i ) denotes the label generated by the generator G according to the input data x i ; log D(x i , y i ) denotes the logarithm of the probability of the real sample pair D(x i , y i ) being judged as real by the discriminator, (x i , G(x i )) denotes the generated sample pair, and log(1-D(x i , G(x i ))) denotes the logarithm of the probability of the generated sample pair (x i , G(x i )) being judged as false by the discriminator;
[0087] In the process of performing steps S3.2 and S3.3, the gradient descent method is used to optimize the label loss function of the generator and the authenticity loss function of the discriminator, respectively. In optimizing the generator loss function, the gradient with respect to the network parameters of the generator is calculated with the label loss of the generator as the target, and then the parameters of the generator are updated according to the gradient descent strategy; in optimizing the discriminator loss function, the gradient with respect to the network parameters of the discriminator is calculated with the discrimination loss of the discriminator as the target, and then the parameters of the discriminator are adjusted according to the gradient descent strategy.
[0088] S4, alternately train the generator and the discriminator, and perform label optimization according to the evaluation of the accuracy of the generated data labeled by the discriminator, so that the generator and the discriminator gradually reach a balanced state in the training process by continuously adjusting the network parameters and optimizing the loss function.
[0089] This step specifically includes:
[0090] S4.1, training the discriminator: fixing the parameters of the generator, training the discriminator using the real data and the labeled data generated by the generator, calculating the output of the discriminator for the real data and the generated data, and calculating the loss value according to the authenticity loss function, and updating the parameters of the discriminator according to the calculated loss value by using the back propagation algorithm;
[0091] The pre-defined authenticity loss function is represented as follows:
[0092]
[0093] Where n represents the number of samples, i represents the i-th sample, y i represents the real label, G(x i ) represents the label generated by the generator G according to the input data x i ; logD(x i ,y i ) represents the logarithm of the probability that the real sample pair D(x i ,y i ) is judged as real by the discriminator; (x i ,G(x i )) represents the generated sample pair, and log(1-D(x i ,G(x i ))) represents the logarithm of the probability that the generated sample pair (x i ,G(x i )) is judged as false by the discriminator.
[0094] S4.2, training the generator: fixing the parameters of the discriminator, the generator generates labeled data based on the input real data, and sends the labeled data generated by the generator into the discriminator for calculation to obtain the output result of the discriminator, and calculates the loss value of the generator on these data according to the joint loss function, and updates the parameters of the generator according to the loss value by using the back propagation algorithm;
[0095] Based on the label loss function and the authenticity loss function, the joint loss function is represented as follows:
[0096] L joint =αL G +βL Greal ,
[0097] Wherein, a and β are weight coefficients, both of which are taken as values between 0 and 1, and contain 0 and 1, a + β = 1;
[0098] S4.3, annotation optimization: according to the accuracy evaluation of the discriminator on the generated data annotation, adjust the generator annotation module parameters and the discriminator feedback parameters, so that the annotation is more accurate;
[0099] S4.4, cyclic alternating training, repeat steps S4.1-S4.3, so that the generator and the discriminator reach balance.
[0100] S5, using the completed training of the generative adversarial network to annotate the collected data, and using the annotated data to train the downstream machine learning model, such as image classification model, target detection model and image segmentation model related to image, text generation model and language translation model related to text, speech recognition model and speech synthesis model related to speech.
[0101] It needs to be further supplemented that:
[0102] (A) For image-related tasks (such as image classification, target detection, image segmentation), a convolutional neural network (CNN) is usually selected to construct the generator and the discriminator. Specifically, (a1) for image classification tasks, the annotation data is annotated with class labels of images, for example, a picture of a cat is annotated as "cat", a picture of a car is annotated as "car", etc. These class labels are manually annotated or obtained through other reliable annotation tools, which are used to train the generator to generate images with correct class annotations, and the discriminator to distinguish between real image class annotations and generated image class annotations; (a2) for target detection tasks, the annotation data contains the position information (usually represented by bounding box coordinates) and class label of the target object in the image, for example, in an image containing a person and a dog, the annotation data will specify the position (bounding box coordinates) and class "person" of the person, and the position (bounding box coordinates) and class "dog" of the dog. Such annotation data is used to train the generator to generate images with target object position and class annotations, and the discriminator to distinguish between real and generated target detection annotations; (a3) for image segmentation tasks, the annotation data is a pixel-level class annotation, that is, each pixel in the image is annotated as belonging to a certain object or background class, for example, in medical image segmentation, for a lung X-ray image, the pixels of the lung tissue may be annotated as "lung" class, the pixels of the lesion area are annotated as "lesion" class, and the rest of the background pixels are annotated as "background" class. These annotation data are used to train the generator to generate images with pixel-level annotations, and the discriminator to distinguish between real and generated image segmentation annotations.
[0103] (B) For text-related tasks (such as text generation, language translation), a recurrent neural network (RNN) or its variants (such as long short-term memory network LSTM, gated recurrent unit GRU) and the Transformer architecture can be used to build the generator and discriminator. Specifically, (b1) for text generation tasks, the annotation data can be the next word, sentence or paragraph of the text, for example, for a sentence generation task, the beginning of the sentence is given as input, and the subsequent content of the sentence is the annotation data. In the preliminary training, the generator learns to generate subsequent text annotations based on the input text part, and the discriminator learns to distinguish between real text and generated text annotations; (b2) for language translation tasks, the annotation data is the target language translation text corresponding to the source language text, for example, for an English to Chinese translation task, the English sentence is the input, and the Chinese translation sentence is the annotation data. In the preliminary training, the generator learns to generate correct translation annotations, and the discriminator learns to distinguish between real and generated translation annotations.
[0104] (C) For speech-related tasks (such as speech recognition, speech synthesis), the generator and discriminator can be built based on the deep neural network architecture WaveNet. Specifically, (c1) for speech recognition tasks, the annotation data is the text content corresponding to the speech signal, for example, the text transcription corresponding to a segment of speech content is the annotation data. In the preliminary training, the generator learns to generate correct speech recognition annotations, and the discriminator learns to distinguish between real and generated speech recognition annotations; (c2) for speech synthesis tasks, the annotation data is the speech feature or speech waveform corresponding to the text content, for example, the speech acoustic parameters or speech waveform corresponding to a sentence is the annotation data. In the preliminary training, the generator learns to generate correct speech synthesis annotations (speech waveform or feature), and the discriminator learns to distinguish between real and generated speech synthesis annotations.
[0105] Embodiment Two:
[0106] In conjunction with the accompanying drawings Figure 2 , the embodiment proposes a system for automatically generating high-quality annotation data using a generative adversarial network, which includes:
[0107] The acquisition and enhancement module is used for data acquisition and enhancement;
[0108] The network construction module is used for constructing a generative adversarial network;
[0109] The preliminary training module is used for preliminary training of the generator and discriminator of the generative adversarial network using small-scale annotation data, so that the generator can generate synthetic data with preliminary annotations, and the discriminator can distinguish the difference between generated annotation data and real annotation data;
[0110] an alternating training module configured to cyclically train the discriminator and the generator and update parameters of the discriminator and the generator using a back propagation algorithm;
[0111] a label optimization module configured to perform label optimization according to an evaluation of label accuracy of the generated data by the discriminator, and constantly adjust network parameters and optimize a loss function, so that the generator and the discriminator gradually reach a balanced state in the training process;
[0112] a model output module configured to use the trained generative adversarial network to label the collected data, and use the labeled data to train a downstream machine learning model.
[0113] In this embodiment, the network construction module specifically includes:
[0114] a generator construction unit configured to construct the generator, and specifically configured to: select a random number generator and initialize a seed, generate a random Gaussian noise vector as an input, select a network architecture according to a property of the generated data, design an output layer matching a data type, and add a module capable of automatically generating label information;
[0115] a discriminator construction unit configured to construct the discriminator, and specifically configured to: take real data and data generated by the generator as inputs, extract spatial features according to different data, and output data authenticity and label accuracy.
[0116] In this embodiment, the preliminary training module specifically performs the following operations to preliminarily train the generator and the discriminator:
[0117] part of the training data is manually labeled, and is denoted as a data set X={(x1,y1),(x1,y2),...,(x n ,y n )}, where x i is input data, and y i is real label data;
[0118] The generator G is a neural network-based model, and the unlabeled data x in the data set X is taken as an input of the generator G. The generator G first outputs generated label Then, a pre-defined label loss function is used to calculate a loss between the generated label and the real label y i , and then the network parameters of the generator G are constantly adjusted by minimizing the label loss, so that the generator G gradually learns how to generate more accurate preliminary labels;
[0119] The discriminator D is a neural network-based model, and takes pairs of data (x,y) and As the input of the discriminator D, where (x, y) represents a pair of input data and real label, (x, y) represents a pair of input data and label generated by the generator; the discriminator D maximizes the probability of the real label and minimizes the probability of the generated label being judged as real through a predefined authenticity loss function, so as to output a loss function value D = (x, y), the loss function value D = (x, y) represents the probability that the input label is a real label.
[0120] In the preliminary training process, the gradient descent method is used to optimize the label loss function of the generator and the authenticity loss function of the discriminator respectively. When optimizing the loss function of the generator, the label loss of the generator is taken as the target, the gradient with respect to the network parameters of the generator is calculated, and then the parameters of the generator are updated according to the gradient descent strategy; when optimizing the loss function of the discriminator, the discrimination loss of the discriminator is taken as the target, the gradient with respect to the network parameters of the discriminator is calculated, and then the parameters of the discriminator are adjusted according to the gradient descent strategy.
[0121] In this embodiment, when the alternating training module trains the discriminator, the parameters of the generator are fixed, the discriminator is trained using real data and label data generated by the generator, the output of the discriminator on the real data and the generated data is calculated, and the loss value is calculated according to the authenticity loss function; the parameters of the discriminator are updated according to the loss value calculated by using the back propagation algorithm.
[0122] When the alternating training module trains the generator, the parameters of the discriminator are fixed, the generator generates label data based on the input real data, the label data generated by the generator is sent to the discriminator for calculation, the output result of the discriminator is obtained, and the loss value of the generator on these data is calculated according to the joint loss function; the parameters of the generator are updated according to the loss value by using the back propagation algorithm.
[0123] In this embodiment, the predefined label loss function is as follows:
[0124]
[0125] Where n represents the number of samples, y i represents the real label, G(x i ) represents the label generated by the generator G according to the input data x i .
[0126] The predefined authenticity loss function is as follows:
[0127]
[0128] Where n represents the number of samples, i represents the i-th sample, y i represents the real label, G(x i) represents the generator G according to the input data x i generated label; logD(x i ,y i ) represents the logarithm of the probability that the real sample pair D(x i ,y i ) is judged as real by the discriminator, (x i ,G(x i )) represents the generated sample pair, and log(1-D(x i ,G(x i ))) represents the logarithm of the probability that the generated sample pair (x i ,G(x i )) is judged as false by the discriminator.
[0129] Based on the labeling loss function and the authenticity loss function, the joint loss function is represented as follows:
[0130] L joint =αL G +βL Greal ,
[0131] Wherein, α and β are weight coefficients, both of which are taken as values between 0 and 1, and contain 0 and 1, and α+β=1.
[0132] In this embodiment, the model output module uses the high-quality labeled data output by the generative adversarial network to train the downstream machine learning model, and based on this, the network construction module and the preliminary training module need to be further supplemented as follows:
[0133] (A) For image-related tasks (such as image classification, object detection, image segmentation), the network construction module usually selects a convolutional neural network (CNN) to construct the generator and the discriminator. Specifically, (a1) for image classification tasks, the annotation data is annotated with class labels of images, for example, a picture of a cat is annotated as "cat", a picture of a car is annotated as "car", and so on. These class labels are manually annotated or obtained through other reliable annotation tools, and are used to train the generator to generate images with correct class annotations, and to train the discriminator to distinguish between real image class annotations and generated image class annotations; (a2) for object detection tasks, the annotation data contains the position information (usually represented by bounding box coordinates) and class labels of the target objects in the image, for example, in an image containing a person and a dog, the annotation data specifies the position (bounding box coordinates) and class "person" of the person, and the position (bounding box coordinates) and class "dog" of the dog. Such annotation data is used to train the generator to generate images with target object position and class annotations, and to train the discriminator to distinguish between real and generated object detection annotations; (a3) for image segmentation tasks, the annotation data is a pixel-level class annotation, that is, each pixel in the image is annotated as belonging to a certain object or background class, for example, in medical image segmentation, for a lung X-ray image, the pixels of the lung tissue may be annotated as "lung" class, the pixels of the lesion area are annotated as "lesion" class, and the remaining background pixels are annotated as "background" class. These annotation data are used to train the generator to generate images with pixel-level annotations, and the discriminator to distinguish between real and generated image segmentation annotations.
[0134] (B) For text-related tasks (such as text generation, language translation), the network construction module may use recurrent neural networks (RNN) or its variants (such as long short-term memory networks LSTM, gated recurrent units GRU) and Transformer architecture to construct the generator and the discriminator. Specifically, (b1) for text generation tasks, the annotation data can be the next word, sentence or paragraph of the text, for example, for a sentence generation task, the beginning of the sentence is given as input, and the subsequent content of the sentence is annotated as annotation data. In the preliminary training, the generator learns to generate subsequent text annotations based on the input text part, and the discriminator learns to distinguish between real text and generated text annotations; (b2) for language translation tasks, the annotation data is the target language translation text corresponding to the source language text, for example, for an English to Chinese translation task, the English sentence is the input, and the Chinese translation sentence is the annotation data. In the preliminary training, the generator learns to generate correct translation annotations, and the discriminator learns to distinguish between real translation and generated translation annotations.
[0135] (C) For speech-related tasks (such as speech recognition, speech synthesis), the network construction module can construct the generator and the discriminator based on the deep neural network architecture WaveNet. Specifically, (c1) for the speech recognition task, the labeled data is the text content corresponding to the speech signal, for example, the text transcription corresponding to a piece of speech content is the labeled data, in the preliminary training, the generator learns to generate correct speech recognition labels, and the discriminator learns to distinguish between real and generated speech recognition labels; (c2) for the speech synthesis task, the labeled data is the speech feature or speech waveform corresponding to the text content, for example, the speech acoustic parameters or speech waveform corresponding to a sentence are the labeled data, in the preliminary training, the generator learns to generate correct speech synthesis labels (speech waveform or feature), and the discriminator learns to distinguish between real and generated speech synthesis labels.
[0136] In summary, the method and system for automatically generating high-quality labeled data using a generative adversarial network can automatically generate high-quality labeled data, reduce manual labeling work, reduce data labeling costs, and improve the training efficiency of downstream machine learning models.
[0137] The above application specific examples have described the principles and embodiments of the present application in detail, and these embodiments are only used to help understand the core technical content of the present application. Based on the above specific embodiments of the present application, any improvement and modification of the present application made by those skilled in the art without departing from the principles of the present application shall fall within the scope of the patent protection of the present application.
Claims
1. A method for automatically generating high-quality labeled data using generative adversarial networks, characterized in that, Includes the following steps: S1. Perform data acquisition and enhancement; S2. Construct a generative adversarial network; S3. Use small-scale labeled data to initially train the generator and discriminator of the generative adversarial network, so that the generator can generate synthetic data with preliminary labels, and the discriminator can distinguish the difference between the generated labeled data and the real labeled data. This process specifically includes: S3.
1. Select a portion of the training data for manual annotation, denoted as dataset X = {(x1,y1),(x1,y2),...,(x1,y2),...} n ,y n )}, where x i It is the input data, y i It is real labeled data; S3.
2. Generator G is a neural network-based model that takes unlabeled data x from dataset X as input and outputs the generated labels. Then, the generated labels are calculated using a predefined labeling loss function. Compared with the true label y i The network learns how to generate more accurate initial labels by minimizing the labeling loss between the two points and continuously adjusting its parameters. S3.3, Discriminator D is a neural network-based model that uses paired data (x, y) and As input to the discriminator D, (x,y) represents a pair consisting of input data and ground truth labels. This represents a pair consisting of input data and labels generated by the generator; the discriminator D maximizes the probability of true labels and minimizes the probability of generated labels being judged as true by a predefined truth loss function, thus outputting a loss function value D = (x, y), which represents the probability that the input label is a true label; During steps S3.2 and S3.3, gradient descent is used to optimize the labeled loss function of the generator and the realism loss function of the discriminator, respectively. When optimizing the generator loss function, the gradient with respect to the generator network parameters is calculated with the labeled loss of the generator as the objective, and then the generator parameters are updated according to the gradient descent strategy. When optimizing the discriminator loss function, the gradient with respect to the discriminator network parameters is calculated with the discriminator discrimination loss as the objective, and then the discriminator parameters are adjusted according to the gradient descent strategy. S4. The generator and discriminator are trained alternately in a loop, and the annotation is optimized based on the discriminator's evaluation of the accuracy of the generated data annotation. By continuously adjusting the network parameters and optimizing the loss function, the generator and discriminator gradually reach a balance during the training process. S5. Use the trained generative adversarial network to label the collected data, and use the labeled data to train the downstream machine learning model.
2. The method for automatically generating high-quality labeled data using generative adversarial networks according to claim 1, characterized in that, Step S2 specifically includes: The generator is constructed by: selecting a random number generator and initializing a seed, generating a random Gaussian noise vector as input, selecting a network architecture based on the nature of the generated data, designing an output layer that matches the data type, and adding a module that can automatically generate annotation information. Constructing a discriminator involves: taking real data and data generated by the generator as input, selecting an algorithm to extract spatial features for different data, and outputting the data authenticity and labeling accuracy in the output layer.
3. The method for automatically generating high-quality labeled data using generative adversarial networks according to claim 1, characterized in that, The predefined annotation loss function is expressed as follows: Where n represents the number of samples, y i Represents the true annotation, G(x) i ) indicates that the generator G is based on the input data x i The generated annotations; The predefined realism loss function is expressed as follows: Where n represents the number of samples, i represents the i-th sample, and y i Represents the true annotation, G(x) i ) indicates that the generator G is based on the input data x i The generated annotation; logD(x) i ,y i ) represents the true sample pair D(x) i ,y i The logarithm of the probability that the discriminator classifies something as true, (x) i ,G(x i )) represents generating sample pairs, log(1-D(x) i ,G(x i ))) indicates generating sample pairs (x i ,G(x i The logarithm of the probability that the discriminator judges it as false; Based on the labeled loss function and the ground truth loss function, the joint loss function is expressed as follows: L joint =αL G +βL Greal , Here, α and β are weighting coefficients, both ranging from 0 to 1, including 0 and 1, and α + β = 1.
4. The method for automatically generating high-quality labeled data using generative adversarial networks according to claim 3, characterized in that, Step S4 specifically includes: S4.1 Training the discriminator: With the generator parameters fixed, the discriminator is trained using real data and labeled data generated by the generator. The output of the discriminator to real data and generated data is calculated, and the loss value is calculated according to the realism loss function. The backpropagation algorithm is used to update the parameters of the discriminator based on the calculated loss value. S4.2 Training the generator: With the discriminator parameters fixed, the generator generates labeled data based on the input real data. The labeled data generated by the generator is sent to the discriminator for calculation. The output of the discriminator is obtained, and the loss value of the generator on these data is calculated according to the joint loss function. The backpropagation algorithm is used to update the generator parameters according to the loss value. S4.3 Annotation Optimization: Based on the discriminator's assessment of the accuracy of the generated data annotations, adjust the parameters of the generator annotation module and the discriminator feedback parameters to make the annotations more accurate; S4.
4. Cyclic training, repeating steps S4.1-S4.3, to balance the generator and discriminator.
5. A system for automatically generating high-quality labeled data using generative adversarial networks, characterized in that, It includes: The data acquisition and enhancement module is used for data acquisition and enhancement. The network building block is used to build generative adversarial networks; The initial training module is used to initially train the generator and discriminator of the generative adversarial network using a small-scale labeled data, enabling the generator to generate synthetic data with preliminary labels and enabling the discriminator to distinguish the differences between the generated labeled data and the real labeled data. The alternating training module is used to train the discriminator and generator alternately in a loop and update the parameters of the discriminator and generator using the backpropagation algorithm. The annotation optimization module is used to optimize the annotation based on the discriminator's evaluation of the accuracy of the generated data annotation. It continuously adjusts the network parameters and optimizes the loss function so that the generator and discriminator gradually reach a balance during the training process. The model output module is used to label the collected data using the trained generative adversarial network. The labeled data is then used to train the downstream machine learning model. The initial training module specifically performs the following operations: initial training of the generator and discriminator: A subset of training data is manually labeled, denoted as dataset X = {(x1,y1),(x1,y2),...,(x1,y2),...} n ,y n )}, where x i It is the input data, y i It is real labeled data; A generator G is a neural network-based model that takes unlabeled data x from a dataset X as input and outputs the generated labels. Then, the generated labels are calculated using a predefined labeling loss function. Compared with the true label y i The network learns how to generate more accurate initial labels by minimizing the labeling loss between the two points and continuously adjusting its parameters. Discriminator D is a neural network-based model that uses pairs of data (x, y) and As input to the discriminator D, (x,y) represents a pair consisting of input data and ground truth labels. This represents a pair consisting of input data and labels generated by the generator; the discriminator D maximizes the probability of true labels and minimizes the probability of generated labels being judged as true by a predefined truth loss function, thus outputting a loss function value D = (x, y), which represents the probability that the input label is a true label; During the initial training process, gradient descent is used to optimize the annotation loss function of the generator and the realism loss function of the discriminator, respectively. When optimizing the generator loss function, the labeled loss of the generator is used as the objective. The gradient with respect to the generator network parameters is calculated, and then the generator parameters are updated according to the gradient descent strategy. When optimizing the discriminator loss function, the discriminator loss is taken as the objective, the gradient with respect to the discriminator network parameters is calculated, and then the discriminator parameters are adjusted according to the gradient descent strategy.
6. The method for automatically generating high-quality labeled data using generative adversarial networks according to claim 5, characterized in that, The network construction module specifically includes: The generator building unit is used to build the generator. The specific operations include: selecting a random number generator and initializing the seed, generating a random Gaussian noise vector as input, selecting a network architecture according to the nature of the generated data, designing an output layer that matches the data type, and adding a module that can automatically generate annotation information. The discriminator construction unit is used to build the discriminator. The specific operations include: taking real data and data generated by the generator as input, selecting an algorithm to extract spatial features for different data, and outputting the data authenticity and labeling accuracy in the output layer.
7. The method for automatically generating high-quality labeled data using generative adversarial networks according to claim 5, characterized in that, The predefined annotation loss function is expressed as follows: Where n represents the number of samples, y i Represents the true annotation, G(x) i ) indicates that the generator G is based on the input data x i The generated annotations; The predefined realism loss function is expressed as follows: Where n represents the number of samples, i represents the i-th sample, and y i Represents the true annotation, G(x) i ) indicates that the generator G is based on the input data x i The generated annotation; logD(x) i ,y i ) represents the true sample pair D(x) i ,y i The logarithm of the probability that the discriminator classifies something as true, (x) i ,G(x i )) represents generating sample pairs, log(1-D(x) i ,G(x i ))) indicates generating sample pairs (x i ,G(x i The logarithm of the probability that the discriminator judges it as false; Based on the labeled loss function and the ground truth loss function, the joint loss function is expressed as follows: L joint =αL G +βL Greal , Here, α and β are weighting coefficients, both ranging from 0 to 1, including 0 and 1, and α + β = 1.
8. The method for automatically generating high-quality labeled data using generative adversarial networks according to claim 7, characterized in that, When the alternating training module trains the discriminator, the generator parameters are fixed, and the discriminator is trained using real data and labeled data generated by the generator. The output of the discriminator to real data and generated data is calculated, and the loss value is calculated according to the realism loss function. The backpropagation algorithm is used to update the parameters of the discriminator based on the calculated loss value. When the alternating training module trains the generator, the discriminator parameters are fixed, the generator generates labeled data based on the input real data, the labeled data generated by the generator is sent to the discriminator for calculation, the output result of the discriminator is obtained, and the loss value of the generator on these data is calculated according to the joint loss function. The backpropagation algorithm is used to update the generator parameters according to the loss value.
Citation Information
Patent Citations
Digital human face editing method and device, equipment, medium and program product
CN118692125A