A training processing method and device, electronic equipment and readable storage medium
Virtual unlabeled sample data is generated by clustering and generative network models. By combining self-supervised and generative adversarial network techniques, the problem of insufficient number or imbalanced distribution of unlabeled samples is solved, thereby improving the performance and generalization ability of machine learning models.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
- Filing Date
- 2022-09-23
- Publication Date
- 2026-05-12
AI Technical Summary
The existing technology suffers from poor performance of machine learning models due to insufficient number or uneven distribution of unlabeled samples.
By clustering sample data, a generative network model is generated to produce virtual unlabeled sample data. Cluster labels are then used for semi-supervised model training. By combining generative adversarial network models and self-supervised training techniques, the quality and balance of the sample data are improved.
It improved the performance of the trained model, increased the quantity and quality of available sample data, and enhanced the model's generalization ability.
Smart Images

Figure CN115456100B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of machine learning, and more specifically, to a training processing method, apparatus, electronic device, and readable storage medium. Background Technology
[0002] In machine learning, the quality of training data plays a crucial role. Machine learning can include supervised training and semi-supervised training. Supervised training uses only labeled training data (also known as labeled sample data), and a machine learning model can be trained using labeled sample data. However, in practical applications, labeling labeled sample data is costly. Therefore, in addition to labeled sample data, unlabeled sample data is also available in practice. To use this unlabeled sample data in training, semi-supervised training is introduced. In semi-supervised training, labeled sample data can be used to label unlabeled sample data, which is equivalent to augmenting the sample data.
[0003] In semi-supervised training, insufficient number or imbalanced distribution of unlabeled samples can lead to poor model performance. Current technologies do not offer solutions to this problem. Summary of the Invention
[0004] This application provides a training processing method, apparatus, electronic device, and readable storage medium to at least solve the problem of poor model performance caused by insufficient number or unbalanced distribution of unlabeled samples in the prior art.
[0005] According to one aspect of this application, a training processing method is provided, comprising: acquiring sample data, wherein the sample data includes labeled sample data and unlabeled sample data; clustering the labeled sample data and the unlabeled sample data to obtain multiple clusters; acquiring remaining sample data in the sample data, wherein the remaining sample data is labeled sample data that is not clustered with the unlabeled sample data; inputting the remaining sample data into a generative network model to obtain generated sample data output by the generative network model, wherein the generative network model is trained using the sample data of the multiple clusters, and the generative network model is used to generate virtual unlabeled sample data based on the labeled sample data; clustering the generated sample data into one of the multiple clusters, wherein each of the multiple clusters corresponds to a cluster label; and training a semi-supervised model using the sample data of the multiple clusters, wherein the cluster label of each cluster is used as the label of the sample data during training.
[0006] Furthermore, clustering the labeled and unlabeled sample data into multiple clusters includes: extracting sample features from the labeled and unlabeled sample data using a feature extraction model, wherein the feature extraction model is pre-trained using training data of the same data type as the sample data, and the feature extraction model is used to extract features from the input data; and clustering based on the sample features corresponding to the labeled and unlabeled sample data.
[0007] Furthermore, clustering the labeled sample data and the unlabeled sample data includes: performing self-supervised training based on the labeled sample data and the unlabeled sample data, wherein the self-supervised training is used to cluster the sample data, and adjust the feature extraction model according to the characteristics of the sample data in the clusters after clustering, and then clustering and adjusting the feature extraction model again until no new clusters are generated.
[0008] Further, clustering based on the labeled sample data and the unlabeled sample data includes: selecting sample data as cluster centers from the sample data; clustering based on the selected cluster centers to obtain multiple clusters, and calculating a first distance from the sample data in each cluster to the cluster center of the cluster to which the sample data belongs and a second distance to the cluster centers of other clusters; changing the sample data used as cluster centers and re-clustering, and calculating the first distance and the second distance, until the value of the loss function is optimal, wherein the smaller the first distance and the larger the second distance, the better the value of the loss function.
[0009] Further, training the generative network model using sample data from the multiple clusters includes: training the generative adversarial network model using sample data from the multiple clusters, wherein the multi-adversarial network model includes a first generator and a first discriminator, the first generator being used to generate unlabeled sample data based on labeled sample data, and the first discriminator being used to determine whether an unlabeled sample data is unlabeled sample data within the same cluster or unlabeled sample data generated by the first generator; after determining that the generative adversarial network model has been trained, the first generator in the multi-adversarial network model is used as the generative network model.
[0010] Furthermore, the generative adversarial network model further includes: a second generator and a second discriminator, wherein the second generator is used to generate labeled sample data based on unlabeled sample data, and the second discriminator is used to determine whether a labeled sample data is labeled sample data within the cluster or labeled sample data generated by the second generator.
[0011] Further, determining that the generative adversarial network (GAN) model training is complete includes: calculating the value of the loss function of the GAN model; and determining that the GAN model training is complete when the value of the loss function is optimal. The loss function of the GAN model includes: a first loss obtained by comparing the unlabeled sample data generated by the first generator with the unlabeled sample data within the cluster; a second loss obtained by comparing the labeled sample data with the constructed labeled sample data; a third loss obtained by comparing the labeled sample data generated by the second generator with the labeled sample data within the cluster; and a fourth loss obtained by comparing the unlabeled sample data with the constructed unlabeled sample data. Compared to the fourth loss and the fifth loss obtained by comparing labeled sample data and unlabeled sample data within the same cluster, the smaller the sum of the first loss, the second loss, the third loss, the fourth loss, and the fifth loss, the better the value of the loss function. The constructed labeled sample data is generated by passing labeled sample data through the first generator to generate unlabeled sample data, and then passing the unlabeled sample data through the second generator to generate labeled sample data. The constructed unlabeled sample data is generated by passing unlabeled sample data through the second generator to generate labeled sample data, and then passing the labeled sample data through the first generator to generate unlabeled sample data.
[0012] Furthermore, training the adversarial network using sample data from the plurality of clusters includes: dividing the sample data of each of the plurality of clusters into sample pairs, wherein each sample pair includes labeled sample data and unlabeled sample data; and training the generative adversarial network model using the sample pairs.
[0013] Furthermore, training a semi-supervised model using sample data from the multiple clusters includes: training a semi-supervised neural network model using sample data from the multiple clusters, wherein the value of the loss function of the neural network model is obtained based on the difference between the cluster labels corresponding to the sample data and the labels output by the neural network model.
[0014] Furthermore, it also includes: obtaining the labels corresponding to the labeled sample data within each cluster; and using the average value of the labels of the labeled sample data within the same cluster as the cluster label.
[0015] According to another aspect of this application, a training processing apparatus is also provided, comprising: an acquisition module, a clustering module, a generation module, and a processing module, wherein the acquisition module is used to acquire sample data, wherein the sample data includes labeled sample data and unlabeled sample data; the clustering module is used to cluster the labeled sample data and the unlabeled sample data to obtain multiple clusters; the acquisition module is further used to acquire remaining sample data in the sample data, wherein the remaining sample data is labeled sample data that is not clustered with the unlabeled sample data; and the generation module is used to input the remaining sample data into the generation module. The network model obtains generated sample data output by the generative network model, wherein the generative network model is trained using sample data from the multiple clusters, and the generative network model is used to generate virtual unlabeled sample data based on labeled sample data; the clustering module is further used to cluster the generated sample data into one of the multiple clusters, wherein each of the multiple clusters corresponds to a cluster label; the processing module is used to train a semi-supervised model using the sample data from the multiple clusters, wherein the cluster label of each cluster is used as the label of the sample data during training.
[0016] According to another aspect of this application, an electronic device is also provided, including a memory and a processor; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the above-described method steps.
[0017] According to another aspect of this application, a readable storage medium is also provided, on which computer instructions are stored, wherein the computer instructions, when executed by a processor, implement the above-described method steps.
[0018] In this embodiment, the following methods are employed: acquiring sample data, which includes labeled and unlabeled sample data; clustering the labeled and unlabeled sample data into multiple clusters; acquiring remaining sample data, which consists of labeled sample data not clustered with unlabeled sample data; inputting the remaining sample data into a generative network model to obtain generated sample data output by the model, wherein the generative network model is trained using the sample data from the multiple clusters and is used to generate unlabeled sample data based on the labeled sample data; clustering the generated sample data into one of the multiple clusters, wherein each cluster corresponds to a cluster label; and training a semi-supervised model using the sample data from the multiple clusters, wherein the cluster label of each sample data is used as the label for the sample data during training. This application solves the problem of poor model performance caused by insufficient or unevenly distributed unlabeled samples in existing technologies, improving the data and quality of available sample data during training, thereby improving the quality of the trained model. Attached Figure Description
[0019] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0020] Figure 1 This is a flowchart of a training processing method according to an embodiment of this application;
[0021] Figure 2 This is a schematic diagram of self-supervised sample data clustering according to an embodiment of this application;
[0022] Figure 3 This is a schematic diagram of the structure of a recurrent generative adversarial network model according to an embodiment of this application;
[0023] Figure 4 This is a schematic diagram illustrating training using sample data from a cluster according to an embodiment of this application; and,
[0024] Figure 5 This is a schematic diagram of the semi-supervised training process according to an embodiment of this application. Detailed Implementation
[0025] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0026] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0027] The sample data used for machine learning training includes labeled samples (X samples) and unlabeled samples (U samples). Labeled samples have labels that are manually assigned, while unlabeled samples are those that have not yet been labeled. Generally, the larger the amount of sample data used in machine learning training, the better the model performance. Therefore, unlabeled samples are also used in training. However, unlabeled samples need to be labeled before training. For example, a machine learning model can be trained using existing labeled samples through supervised training, and then the unlabeled samples can be labeled using this model. However, this method relies heavily on the quality of the labeled samples. If the labels in the labeled samples are mislabeled, the labeling of the unlabeled samples will also be problematic, affecting the model's generalization ability. Unlabeled samples may also contain data with features significantly different from other samples; if such samples are also used in training, it will also affect the model's generalization ability. The generalization ability of a model can be understood as its performance on a test set (data not used in training), essentially its ability to apply knowledge to new situations. However, this data must be in the same distribution (In Distribution, or ID) as the training data (i.e., the data characteristics of the test and training data are similar). For example, even if a test data point was not used in training, if it shares the same distribution as the training data, the model can still make good predictions on that test data; this is model generalization. The higher the accuracy of the model's predictions on the test set, the better its generalization ability.
[0028] To address the problems with the aforementioned sample data, a training processing method is provided in the following implementation. Figure 1 The flow of the training processing method according to the embodiments of this application is as follows: Figure 1 As shown below, Figure 1 The steps involved in the method described are explained.
[0029] Step S102: Obtain sample data, wherein the sample data includes labeled sample data and unlabeled sample data.
[0030] Step S104 involves clustering the labeled sample data and the unlabeled sample data to obtain multiple clusters. In this step, multiple clusters are obtained, and the sample data within each cluster share similar characteristics, thus allowing them to be clustered into one cluster.
[0031] Step S106: Obtain the remaining sample data in the sample data, wherein the remaining sample data is labeled sample data that is not clustered with the unlabeled sample data.
[0032] Step S108: Input the remaining sample data into the generator network model to obtain the generated sample data output by the generator network model. The generator network model is trained using the sample data of the multiple clusters. The generator network model is used to generate unlabeled sample data based on the labeled sample data. Since the unlabeled sample data is generated, it is also called virtual unlabeled sample data.
[0033] Step S110: The generated sample data are clustered into one of the multiple clusters, wherein each of the multiple clusters corresponds to a cluster label.
[0034] Step S112: Use the sample data from the multiple clusters to train a semi-supervised model, wherein the cluster label of each cluster is used as the label of the sample data during training.
[0035] The above steps cluster unlabeled and labeled sample data together, allowing unlabeled and labeled sample data with similar features to be grouped into the same cluster. This helps identify unlabeled sample data with consistent distribution. This approach primarily considers that unlabeled sample data, compared to labeled sample data, can exhibit both consistent and out-of-distribution (OOD) samples. Generally speaking, consistent unlabeled sample data has a high similarity to labeled sample data, while out-of-distribution unlabeled sample data has a low similarity. Using out-of-distribution unlabeled sample data for training can lead to insufficient generalization of the model. In practical applications, OOD samples of sample U are divided into two categories: the first category consists of shallow distribution variations caused by factors such as lighting, angle, motion, and imaging; these samples can be matched with corresponding samples X through features. The second category includes samples that have not appeared in samples X; these samples show significant differences in features compared to existing samples X. The above steps leverage the similarity in features between unlabeled and labeled sample data with consistent and inconsistent distributions (Type I) to cluster them into multiple clusters. Training is then performed using sample data from these multiple clusters, thus addressing the issue of insufficient model generalization caused by training with consistent distributions (Type II). Furthermore, unlabeled sample data with inconsistent distributions (Type II) can be trained as separate clusters.
[0036] On another front, in the steps described above, unlabeled sample data can be generated from the unassigned labeled sample data. This generated unlabeled sample data (hereinafter referred to as virtual unlabeled samples, and the original unlabeled sample data as original unlabeled samples) is then clustered again, and the cluster label to which it belongs after clustering is used as the label for that sample data. This process helps to identify "problem" samples in the labeled sample data and generate virtual sample data corresponding to the distribution of unlabeled samples. Furthermore, it increases the number of unlabeled sample data, improving data balance. Therefore, these steps improve the quality and quantity of the sample data available for training, thereby enhancing the quality of the trained model.
[0037] The steps described above involve clustering labeled and unlabeled sample data. Clustering is the process of dividing sample data into multiple classes composed of similar sample data. A cluster generated by clustering is a set of sample data; sample data within the same cluster are similar to each other, while sample data in other clusters are dissimilar. Unsupervised learning algorithms can be used for clustering sample data. In unsupervised learning, labels for the sample data are not required; instead, the inherent properties and patterns of the sample data are revealed through learning, dividing the sample data into multiple disjoint clusters, providing a foundation for further processing of the sample data. Existing unsupervised learning algorithms can be used for clustering, which will not be elaborated upon here.
[0038] While unsupervised learning algorithms can be used for clustering, this method involves extracting sample features and then clustering based on those features. Because it's unsupervised learning, the extracted features can be inaccurate, affecting the clustering results. To address this, an optional implementation can pre-train a model (called a feature extraction model) to extract sample features. These features are then used for clustering, and the model is adjusted based on the features of the sample data in the resulting clusters. This process is repeated until no new clusters are generated. This optional implementation improves clustering accuracy. Specifically, clustering labeled and unlabeled sample data to obtain multiple clusters can include the following steps: extracting sample features from the labeled and unlabeled sample data using the feature extraction model, which is pre-trained using training data of the same data type as the sample data. The feature extraction model is used to extract features from the input data; and clustering is performed based on the corresponding sample features of the labeled and unlabeled sample data. This optional implementation primarily utilizes existing datasets. This is because, with the development of machine learning technology, many labeled training datasets are readily available through public channels such as the internet. For example, if the sample data to be clustered is image data, a labeled image dataset can be obtained from public sources, and a feature extraction model can be trained using this dataset. Similarly, if the sample data to be clustered is speech data, a speech dataset can be obtained from public sources, and a feature extraction model can be trained using this speech dataset. Since the data used for training the feature extraction model is of the same type as the sample data, the sample features extracted by this feature extraction model are more accurate. Then, using the sample features extracted by the feature extraction model for classification can lead to more accurate classification. In this optional implementation, unlike unsupervised learning, feature extraction is first performed using a feature extraction model, followed by clustering. The feature extraction model is then adjusted based on the clusters obtained, and this process is repeated until no new clusters are generated. This approach can be considered a form of self-supervised training.
[0039] In clustering, the distance between sample data within a single cluster is typically considered. For example, in the K-Means clustering algorithm: First, determine the value of K, i.e., cluster the sample data into K clusters. It should be noted that the sample data used for clustering in the above implementation includes labeled sample data; therefore, the number of K can be determined based on the types of labels. Second, randomly select K data points from the dataset as the cluster centers of each cluster. Third, calculate the distance from each point to each cluster center and assign each point to the cluster closest to its center. Fourth, after each centroid has gathered some points, select new cluster centers. These four steps are iterated to complete the clustering. This clustering algorithm relies solely on the optimal distance from the sample data to the cluster. This method does not constrain the distance between clusters, which may result in clusters being too close together, affecting the accuracy of the clustering. In machine learning algorithms, loss functions are generally used to determine training effectiveness. Each sample data point, after being processed by the model, yields a predicted value. The difference between the predicted value and the true value is called the loss (a smaller loss value indicates a more successful model). A function that calculates the difference between the predicted and true values is called a loss function. In machine learning, we aim for predicted values to be as close as possible to the true values, so we need to minimize the difference. This process requires the introduction of a loss function, whose value is used to determine whether training is complete. This analysis shows that existing clustering algorithms' loss functions only consider the distance from the sample data point to the cluster center. This leads to an inability to limit the distance between clusters, resulting in poor clustering performance.
[0040] To address this issue, in one optional implementation, the loss function of the clustering algorithm is adjusted by incorporating the distance from each cluster's sample data to the cluster centers of other clusters into the loss function. In this case, the loss includes both the distance from the sample data to its own cluster center and the distance from the sample data to the cluster centers of other clusters. Therefore, this loss is also called contrastive loss. In this optional implementation, clustering based on the labeled and unlabeled sample data may include the following steps: selecting sample data as cluster centers from the sample data; clustering based on the selected cluster centers to obtain multiple clusters, and calculating a first distance from the sample data in each cluster to the cluster center of its own cluster and a second distance to the cluster centers of other clusters; changing the sample data used as cluster centers and re-clustering, calculating the first and second distances again, until the loss function value is optimal. The smaller the first distance and the larger the second distance, the better the loss function value. By introducing the second distance, the distance between different clusters is maximized after clustering, meaning the sample differences between different clusters are maximized, improving the clustering effect and laying a good foundation for the next training step.
[0041] The following is combined Figure 2 This section explains the clustering of sample data based on self-supervised training. Figure 2 This is a schematic diagram of self-supervised sample data clustering according to an embodiment of this application. Figure 2 In this approach, a pre-trained model (based on a publicly available large-scale dataset) extracts sample features, which are then clustered. Each cluster serves as the unit for a particular class of samples, and the feature extraction model is trained using self-supervised learning (SSL). Self-supervised training introduces contrastive loss, which brings samples within the same cluster closer together and samples in different clusters further apart. For example... Figure 2 As shown, cluster A includes multiple sample data, in Figure 2 Only sample data a1 and sample data a2 are shown in the diagram; cluster B includes multiple sample data, in Figure 2 Only sample data b1 and sample data b2 are shown. It should be noted that a cluster can also include multiple clusters. Figure 2Only clusters A and B are shown. Sample data a1, a2, b1, and b2 are extracted using a feature extraction model to obtain sample features a1, a2, b1, and b2. Then, the distances from the extracted sample features to the cluster centers are calculated to obtain response matrices. Response matrices a1, a2, b1, and b2 are used to identify the distances to the cluster centers.
[0042] exist Figure 2 In this clustering model, the loss is not directly achieved through comparison of sample features, but rather by comparing the response (i.e., distance) of sample data to cluster centers. This ensures that samples within the same cluster have similar responses to their cluster centers, while maximizing the difference in responses from samples within different clusters to other cluster centers. The loss function L of this clustering model can be expressed by the following formula:
[0043] L(a1,a2,b1,b2)=l(sim_a1,sim_a2)+l(sim_b1,sim_b2)+D(sim_a1,sim_a2,sim_b1,sim_b2)
[0044] Here, sim_a1, sim_a2, sim_b1, and sim_b2 identify response matrices a1, a2, b1, and b2, respectively. l(sim_a1, sim_a2) and l(sim_b1, sim_b2) measure the distance between sample data within a cluster and the cluster center. D(sim_a1, sim_a2, sim_b1, sim_b2) measures the distribution distance of response matrices between different clusters (i.e., the distance between sample data in one cluster and the cluster centers of other clusters). During clustering, the cluster centers are updated iteratively, and the loss function is calculated until the optimal loss function value is found.
[0045] It should be noted that L(a1,a2,b1,b2) or l(sim_a1,sim_a2) and l(sim_b1,sim_b2) can be various types of loss functions. In an optional implementation, cross-entropy loss can be selected as the loss function.
[0046] Cross-entropy loss is frequently used in classification problems, especially in clustering problems using neural networks. The definition of cross-entropy loss is as follows:
[0047] Assuming there are only two categories (categories are clusters), the predicted probability for each category is:
[0048] The base of the logarithm is e, where yi The label represents the sample data i, and the positive sample y represents the label. i The value is 1, and the negative sample y is 1. i p is 0; i Let N represent the probability that sample i is predicted to be a positive sample, and let N represent the number of samples.
[0049] Extending binary classification to multiple classifications yields:
[0050]
[0051] Where M represents the number of categories, y ic The sign function (0 or 1) is set to 1 if the true class of sample i is equal to c, and 0 otherwise. ic This represents the predicted probability that sample data i belongs to category c.
[0052] Through the aforementioned self-supervised training-based feature extraction model and clustering, samples with certain representational changes but unchanged features can be clustered together. This allows ID samples and first-class OOD samples in the U sample set to be matched with X samples into the same cluster. The pseudo-label of the U sample within the same cluster corresponds to the artificial label of the X sample in that cluster. For example, the labels corresponding to the labeled sample data within each cluster can be obtained; the average value of the labels of the labeled sample data within the same cluster is used as the cluster label. After obtaining the cluster label, the unlabeled data within that cluster also uses the cluster label (also called the pseudo-label) to provide a data foundation for the next step of processing.
[0053] In the above clustering, there may be unlabeled data and labeled data that are not clustered into any cluster. For unlabeled data that is not clustered into any cluster, pseudo-labels can be generated. For example, the K nearest clusters that meet the distance requirement of the unlabeled data can be obtained, and the average of the labels of the K clusters can be used as the pseudo-label of the unlabeled data. For labeled data that is not clustered into any cluster, in order to increase the number of samples, a generative network model can be used to transfer it into unlabeled sample data. The generative network model can be implemented using various neural network models. In an optional implementation, the generative network model can be implemented using a generative adversarial network model.
[0054] Generative Adversarial Networks (GANs) generally consist of two parts: a generator (or generator model, represented by the letter G or F) and a discriminator (or discriminator model, represented by the letter D). Both the generator and discriminator are neural network models. The generator's main role is to use the neural network to generate images, aiming to "fool" the discriminator. The discriminator's main function is to use the neural network model to determine whether the sample data is real or generated by the generator, aiming to identify the "fake sample data" generated by the generator. In other words, the generator is used to generate "fake sample data" based on "real sample data," and the discriminator is used to distinguish between "real sample data" and "fake sample data." During training, one of the discriminator or generator can be fixed initially. For example, the discriminator can be fixed, and the generator's ability to generate sample data can be trained using the discriminator, making it unable to distinguish which sample data is real and which images are generated by the generator. Then, the generator can be fixed, and the discriminator's ability to judge sample data can be trained using the sample data generated by the generator, enabling the discriminator to distinguish which sample data is generated by the generator and which is real. Through repeated training, the capabilities of both the generator and the discriminator are improved. The generator and discriminator exist in an "adversarial" manner; therefore, this network is called a Generative Adversarial Network (GAN).
[0055] The following explanation uses the example of fixing the discriminator first and then fixing the generator. Alternatively, the generator can be fixed first and then the discriminator. The process is similar and will not be elaborated on here.
[0056] Phase 1: Fix the discriminator D and train the generator G.
[0057] A discriminator with some judgment capability is used to continuously generate "fake data" from a generator G, which is then used by the discriminator D to judge the data. Initially, the discriminator D easily identifies the fake data generated by generator G. However, as training continues, generator G's capabilities improve, eventually producing fake data that the discriminator D cannot detect. At this point, the discriminator D correctly identifies whether the data is fake with a 50% probability.
[0058] Second stage: Fix the generator G and train the discriminator D.
[0059] Once the first stage is passed, continuing to train the generator G is pointless. At this point, the generator G is fixed, and the discriminator D is trained. Through continuous training, the discriminator D improves its judgment ability, and eventually, the discriminator D can accurately identify the "fake data" generated by the generator. At this point, the generator G can no longer fool the discriminator D.
[0060] By iterating through the first and second phases, the generator G and discriminator D become increasingly powerful. Ultimately, a highly effective generator G is obtained, which can then be used to generate data.
[0061] A generative adversarial network model can be trained using sample data from multiple clusters after clustering. The multi-adversarial network model includes a first generator and a first discriminator. The first generator is used to generate unlabeled sample data based on labeled sample data, and the first discriminator is used to determine whether an unlabeled sample data is unlabeled sample data within the same cluster or unlabeled sample data generated by the first generator. After the generative adversarial network model is determined to be trained, the first generator in the multi-adversarial network model is used as the generative network model.
[0062] The features of labeled and unlabeled sample data within each cluster are similar. Therefore, when training the adversarial network, the sample data of each cluster can be divided into sample pairs, where each sample pair includes both labeled and unlabeled sample data. These sample pairs are then used to train the generative adversarial network model. The generator trained in this way generates unlabeled sample data that more closely resembles real unlabeled sample data when generating unlabeled sample data from labeled sample data, thus expanding the amount of sample data available for training to some extent.
[0063] There are many types of generative adversarial network (GAN) models, one of which is the CycleGAN model. CycleGAN has a circular structure, mainly composed of two generators and two discriminators. X represents data in the X domain (e.g., labeled sample data), and Y represents data in the Y domain (e.g., unlabeled sample data). Data in the X domain is used by generator G to generate data in the Y domain, and then reconstructed back to the original data input in the X domain by generator F; similarly, data in the Y domain is used by generator F to generate data in the X domain, and then reconstructed back to the original data input in the Y domain by generator G. The discriminators Dx and Dy play a discriminative role, ensuring data transfer.
[0064] If CycleGAN is used, the above generative adversarial network model can further include: a second generator and a second discriminator. The second generator generates labeled sample data from unlabeled sample data, and the second discriminator determines whether a labeled sample is a labeled sample within the cluster or a labeled sample generated by the second generator. CycleGAN uses two generators and two discriminators for adversarial processing, which can further improve the performance of the adversarial network model, making the virtual unlabeled sample data closer to the real unlabeled sample data.
[0065] Figure 3 This is a schematic diagram of the structure of a recurrent generative adversarial network model according to an embodiment of this application. Figure 3 The CycleGAN-based model shown includes: a generator G, a generator F, a discriminator Du, and a discriminator Dx. G is used to generate unlabeled sample data from labeled sample data, F is used to generate labeled sample data from unlabeled sample data, discriminator Du is used to distinguish between virtual unlabeled sample data and real unlabeled sample data, and discriminator Dx is used to distinguish between virtual labeled sample data and real labeled sample data. Figure 3 The CycleGAN diagram illustrates using X samples in clusters as the source domain and U samples as the target domain.
[0066] Typically, the loss function for training CycleGAN includes: (1) Adversarial loss from X to U: generated by the generator G from X (labeled sample data). (Virtual unlabeled sample data), discriminator D U Discrimination The difference from U (unlabeled sample data). That is, the first loss is obtained by comparing the unlabeled sample data generated by the first generator with the unlabeled sample data in the cluster. (2) Adversarial loss of U→X: generated by generator F from U (Virtual labeled sample data), Discriminator D X Discrimination The difference from X. That is, the third loss obtained by comparing the labeled sample data generated by the second generator with the labeled sample data in the cluster. (3) Consistency loss: the consistency loss of F(G(X)) with X, and G(F(U)) with U. That is, the second loss obtained by comparing the labeled sample data with the constructed labeled sample data, and the fourth loss obtained by comparing the labeled sample data with the constructed unlabeled sample data, wherein the constructed labeled sample data is the labeled sample data generated by the first generator after the labeled sample data is processed by the first generator, and the unlabeled sample data is the labeled sample data generated by the second generator after the unlabeled sample data is processed by the second generator.
[0067] After introducing the aforementioned loss function, the value of the loss function of the generative adversarial network model is calculated. If the value of the loss function of the generative adversarial network model is optimal, the training of the generative adversarial network model is considered complete. In an optional implementation, considering that the labeled and unlabeled sample data used are obtained through clustering, a consistency loss of the sample features extracted from the sample data within the same cluster is also introduced. This consistency loss represents the loss obtained by comparing labeled and unlabeled sample data within the same cluster (i.e., the fifth loss). After introducing the fifth loss, the loss function L(G,F,D) of the generative adversarial network model is... U D x This can be expressed using the following formula:
[0068] L(G,F,D U D x ) = L GAN (G,D U ,X,U)+L GAN (F,D X ,U,X)+L cyc (G,F)+L feat (X,U)
[0069] Among them, L GAN (G,D U Let L(X,U) be the adversarial loss (i.e., the first loss) for X→U. GAN (F,D X Let L(U,X) be the adversarial loss (i.e., the second loss) for U→X. cyc (G,F) represents the consistency loss (i.e., the third and fourth losses) between F(G(X)) and X, and between G(F(U)) and U. feat(X,U) represents the fifth loss. In this case, the smaller the sum of the first, second, third, fourth, and fifth losses, the better the value of the loss function.
[0070] The model trained using the loss function introduced above (the fifth loss) can generate a model corresponding to the target domain when the input source domain is not clustered, through the generator G. This refers to virtual, unlabeled sample data. The process is a migration of X samples. By migrating all unclustered X samples, and adding the generated virtual samples to the original X and U samples, samples with a distribution more similar to the source domain can be obtained in the target domain.
[0071] After obtaining the above sample data, it can be used for training. For example, the sample data from the multiple clusters can be used to train a semi-supervised neural network model, wherein the loss function of the neural network model is obtained based on the difference between the cluster label corresponding to the sample data and the label output by the neural network model. Figure 4 This is a schematic diagram illustrating training using sample data from a cluster according to an embodiment of this application, such as... Figure 4 As shown, original labeled sample data, original unlabeled sample data, and virtual unlabeled sample data were used. Since the cluster labels are obtained from the labels in the original labeled sample data, the cluster labels are also called virtual labels of the original unlabeled sample data and the virtual unlabeled sample data. Semi-supervised training is carried out using these sample data and labels.
[0072] That is, in Figure 4 Semi-supervised training is performed on a cluster-by-cluster basis. During training, each iteration selects one cluster and randomly selects one sample from it.
[0073] (1) If the sample is sample X, the loss is the loss of the model's prediction result on sample X and the cluster label X_label, that is, the loss of the label value obtained by the semi-supervised model for sample X compared with the cluster label.
[0074] (2) If the sample is a U sample, the loss is the loss of the model’s prediction result on the U sample compared with the cluster label P_label, that is, the loss of the label value obtained by the semi-supervised model for the U sample compared with the cluster label.
[0075] (3) If the sample is Samples, loss is the model in The loss between the prediction results on the sample and the cluster label P_label, i.e., the semi-supervised model's performance on the sample. The loss of the predicted label value of the sample compared to the family label.
[0076] Then, the above three losses are used as the losses for the semi-supervised model:
[0077]
[0078] Among them, L entropy L represents the cross-entropy loss. softmax This indicates the loss calculated using softmax as the loss function. Softmax, literally, can be divided into two parts: soft and max, where max means the maximum value. The core of Softmax lies in "soft," which implies a flexible approach, as opposed to "hard." The biggest characteristic of hardmax is that it only selects one maximum value, i.e., a black-and-white approach. The meaning of Softmax is that it no longer uniquely determines a single maximum value, but instead assigns a probability value to each output classification result, representing the likelihood of belonging to each category. The Softmax function can convert the output values of multi-class classification into a probability distribution ranging from [0,1] to 1.
[0079] The semi-supervised training described above is applicable to various application scenarios such as image classification, image recognition, object detection, image segmentation, speech recognition, sequence learning, and other related tasks.
[0080] Figure 5 This is a schematic diagram of the semi-supervised training process according to an embodiment of this application. Figure 5 The process shown can be used to transfer samples, expand the size of the unlabeled dataset, and balance the class ratio, thereby improving the semi-supervised training effect. Figure 5 The process shown is mainly achieved through the following three steps:
[0081] Step 1: Sample matching: Extract features from labeled sample data (i.e., X samples) and unlabeled sample data (i.e., U samples) using a pre-trained model and cluster them. Optimize the feature extraction model using the clusters as units. Repeat this process until no new clusters are generated.
[0082] Step 2 Sample Transfer: For samples U and X within the same sample cluster, construct sample pairs and train the sample generation model (also known as the sample transfer model); input samples X that are not clustered with samples U into the sample transfer model to generate virtual unlabeled sample data in the target domain, and merge them with existing clusters, repeating until no new clusters can be generated.
[0083] Step 3: Model Training: Input labeled sample data, unlabeled sample data, and virtual unlabeled sample data into semi-supervised training.
[0084] Figure 5The process shown addresses the issue of a small and imbalanced number of unlabeled sample data in semi-supervised training. It utilizes a sample transfer model to map labeled sample data from the source domain to the target domain, constructing virtual unlabeled sample data to ensure the data volume and balance of the final training set and improve the robustness of semi-supervised training.
[0085] The above embodiments propose a self-supervised training method based on online clustering, enabling initial X samples and U samples to cluster accordingly based on adaptive representation features. The embodiments also utilize a CycleGAN sample transfer network with incorporating intra-cluster representation feature consistency to transfer X samples to the U sample target domain, generating virtual samples and improving sample balance between the X source domain and the U target domain. Furthermore, in semi-supervised training, using clustered sample clusters as units, any sample within a cluster is extracted in a single iteration, and the loss between its prediction result and the cluster label is used as the optimization objective, improving the model's generalization ability on unlabeled samples.
[0086] In this embodiment, an electronic device is provided, including a memory and a processor. The memory stores a computer program, and the processor is configured to run the computer program to perform the methods described in the above embodiments.
[0087] The aforementioned program can run on a processor or be stored in memory (or computer-readable medium). Computer-readable medium includes both permanent and non-permanent, removable and non-removable media, and information storage can be achieved by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable medium does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0088] These computer programs may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1The steps for the functions specified in one or more boxes can be implemented using different modules, and different steps can be implemented using different modules.
[0089] This embodiment provides such a device. This device, referred to as a training processing device, includes: an acquisition module, a clustering module, a generation module, and a processing module. The acquisition module is used to acquire sample data, which includes labeled sample data and unlabeled sample data. The clustering module is used to cluster the labeled sample data and the unlabeled sample data to obtain multiple clusters. The acquisition module is also used to acquire remaining sample data from the sample data, wherein the remaining sample data consists of labeled sample data that is not clustered with the unlabeled sample data. The generation module is used to input the remaining sample data into a generative network model. The generated sample data output by the generative network model is obtained, wherein the generative network model is trained using sample data from the multiple clusters, and the generative network model is used to generate unlabeled sample data based on labeled sample data; the clustering module is further used to cluster the generated sample data into one of the multiple clusters, wherein each of the multiple clusters corresponds to a cluster label; the processing module is used to train a semi-supervised model using the sample data from the multiple clusters, wherein the cluster label of each cluster is used as the label of the sample data during training.
[0090] The system or apparatus is used to implement the functions of the methods in the above embodiments. Each module in the system or apparatus corresponds to each step in the method, as has been described in the method and will not be repeated here.
[0091] For example, the clustering module is used to: extract sample features from the labeled sample data and unlabeled sample data using a feature extraction model, wherein the feature extraction model is pre-trained using training data of the same data type as the sample data, and the feature extraction model is used to extract features from the input data; and perform clustering based on the sample features corresponding to the labeled sample data and unlabeled sample data.
[0092] Optionally, the clustering module is used to: perform self-supervised training based on the labeled sample data and the unlabeled sample data, wherein the self-supervised training is used to cluster the sample data, adjust the feature extraction model based on the features of the sample data in the clusters after clustering, and then cluster and adjust the feature extraction model again until no new clusters are generated.
[0093] Optionally, the clustering module is configured to: select sample data as cluster centers from the sample data; cluster the data according to the selected cluster centers to obtain multiple clusters, and calculate a first distance from the sample data in each cluster to the cluster center of the cluster to which the sample data belongs and a second distance to the cluster centers of other clusters; change the sample data as cluster centers and re-cluster the data, and calculate the first distance and the second distance until the value of the loss function is optimal, wherein the smaller the first distance and the larger the second distance, the better the value of the loss function.
[0094] For example, the generation module is used to: train a generative adversarial network model using sample data from the multiple clusters, wherein the multi-adversarial network model includes a first generator and a first discriminator, the first generator is used to generate unlabeled sample data based on labeled sample data, and the first discriminator is used to determine whether an unlabeled sample data is unlabeled sample data within the cluster or unlabeled sample data generated by the first generator; after determining that the generative adversarial network model has been trained, the first generator in the multi-adversarial network model is used as the generative network model.
[0095] Optionally, the generative adversarial network model further includes: a second generator and a second discriminator, wherein the second generator is used to generate labeled sample data based on unlabeled sample data, and the second discriminator is used to determine whether a labeled sample data is labeled sample data within the cluster or labeled sample data generated by the second generator.
[0096] Optionally, the generation module is configured to: calculate the value of the loss function of the generative adversarial network model, and determine that the training of the generative adversarial network model is complete when the value of the loss function of the generative adversarial network model is optimal, wherein the loss function of the generative adversarial network model includes: a first loss obtained by comparing the unlabeled sample data generated by the first generator with the unlabeled sample data in the cluster; a second loss obtained by comparing the labeled sample data with the constructed labeled sample data; a third loss obtained by comparing the labeled sample data generated by the second generator with the labeled sample data in the cluster; and a fourth loss obtained by comparing the unlabeled sample data with the constructed unlabeled sample data. The fourth loss is a comparison between labeled and unlabeled sample data within the same cluster, and the fifth loss is a comparison between labeled and unlabeled sample data. The smaller the sum of the first, second, third, fourth, and fifth losses, the better the value of the loss function. The constructed labeled sample data is generated by passing labeled sample data through the first generator to generate unlabeled sample data, and then passing the unlabeled sample data through the second generator to generate labeled sample data. The constructed unlabeled sample data is generated by passing unlabeled sample data through the second generator to generate labeled sample data, and then passing the labeled sample data through the first generator to generate unlabeled sample data.
[0097] Optionally, the generation module is used to: divide the sample data of each of the plurality of clusters into sample pairs, wherein each sample pair includes labeled sample data and unlabeled sample data; and use the sample pairs to train the generative adversarial network model.
[0098] For example, the processing module is used to: train a semi-supervised neural network model using sample data from the plurality of clusters, wherein the value of the loss function of the neural network model is obtained based on the difference between the cluster labels corresponding to the sample data and the labels output by the neural network model.
[0099] For example, the device may further include: a tag processing module, used to obtain the tags corresponding to the tagged sample data in each cluster; and to use the average value of the tags with tagged sample data in the same cluster as the cluster tag of that cluster.
[0100] The above implementation method solves the problem of poor model performance caused by insufficient number or imbalanced distribution of unlabeled samples in the prior art. It improves the data quality and quantity of available sample data during training, thereby improving the quality of the trained model.
[0101] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A training processing method, characterized by, The method comprises: acquiring sample data, a data type of the sample data comprising one of image data and voice data, wherein the sample data comprises labeled sample data and unlabeled sample data; clustering the labeled sample data and the unlabeled sample data to obtain a plurality of clusters; acquiring remaining sample data in the sample data, wherein the remaining sample data is labeled sample data that is not clustered with the unlabeled sample data; inputting the remaining sample data into a generative network model to obtain generated sample data output by the generative network model, wherein the generative network model is trained using sample data of the plurality of clusters, and the generative network model is used to generate virtual unlabeled sample data according to labeled sample data; clustering the generated sample data into one of the plurality of clusters respectively, wherein each of the plurality of clusters corresponds to a cluster label; training a semi-supervised model using sample data in the plurality of clusters, wherein sample data in each cluster uses a cluster label of the cluster as a label of the sample data in training.
2. The method of claim 1, wherein, The clustering of the labeled sample data and the unlabeled sample data to obtain a plurality of clusters comprises: extracting sample features of the labeled sample data and the unlabeled sample data using a feature extraction model, wherein the feature extraction model is pre-trained using training data of the same type as the sample data, and the feature extraction model is used to extract features from input data; clustering according to sample features corresponding to the labeled sample data and the unlabeled sample data.
3. The method of claim 2, wherein, The clustering of the labeled sample data and the unlabeled sample data comprises: performing self-supervised training according to the labeled sample data and the unlabeled sample data, wherein the self-supervised training is used to cluster sample data, and adjust the feature extraction model according to features of sample data in a cluster after clustering, and then cluster again and adjust the feature extraction model until no new cluster is generated.
4. The method according to claim 1 or 2, characterized in that, The clustering of the labeled sample data and the unlabeled sample data comprises: selecting sample data as cluster centers from the sample data; clustering according to the selected cluster centers to obtain a plurality of clusters, and calculating a first distance of sample data in each cluster to a cluster center of a cluster to which the sample data belongs and a second distance to cluster centers of other clusters; changing the sample data as cluster centers to cluster again, and calculating the first distance and the second distance until a value of a loss function is optimal, wherein the smaller the first distance and the larger the second distance, the more optimal the value of the loss function.
5. The method of claim 1, wherein, The training using sample data of the plurality of clusters to obtain the generative network model comprises: training a generative adversarial network model using sample data of the plurality of clusters, wherein the generative adversarial network model comprises a first generator and a first discriminator, the first generator is used to generate unlabeled sample data according to labeled sample data, and the first discriminator is used to determine whether an unlabeled sample data is an unlabeled sample data in the cluster or an unlabeled sample data generated by the first generator. After determining that the generative adversarial network model is trained, the first generator in the generative adversarial network model is used as the generative network model.
6. The method of claim 5, wherein, The generative adversarial network model further comprises a second generator and a second discriminator, wherein the second generator is configured to generate labeled sample data from unlabeled sample data, and the second discriminator is configured to determine whether a labeled sample data is a labeled sample data in the cluster or a labeled sample data generated by the second generator.
7. The method of claim 6, wherein, Determining that the generative adversarial network model is trained comprises: The value of the loss function of the generative adversarial network model is calculated, and the generative adversarial network model is determined to be trained in the case that the value of the loss function of the generative adversarial network model is optimal, wherein the loss function of the generative adversarial network model comprises a first loss obtained by comparing the unlabeled sample data generated by the first generator with the unlabeled sample data in the cluster, a second loss obtained by comparing the labeled sample data with the constructed labeled sample data, a third loss obtained by comparing the labeled sample data generated by the second generator with the labeled sample data in the cluster, a fourth loss obtained by comparing the unlabeled sample data with the constructed unlabeled sample data, and a fifth loss obtained by comparing the labeled sample data in the same cluster with the unlabeled sample data, wherein the smaller the sum of the first loss, the second loss, the third loss, the fourth loss and the fifth loss is, the more optimal the value of the loss function is, the constructed labeled sample data is the labeled sample data generated by the second generator after the labeled sample data is converted into the unlabeled sample data by the first generator, and the constructed unlabeled sample data is the unlabeled sample data generated by the first generator after the unlabeled sample data is converted into the labeled sample data by the second generator.
8. The method according to any one of claims 5 to 7, characterized in that, Training the adversarial network using the sample data of the plurality of clusters comprises: The sample data of each cluster in the plurality of clusters is divided into sample pairs, wherein each sample pair comprises labeled sample data and unlabeled sample data. The generative adversarial network model is trained using the sample pairs.
9. The method of claim 1, wherein, Training a semi-supervised model using the sample data in the plurality of clusters comprises: A semi-supervised neural network model is trained using the sample data in the plurality of clusters, wherein the value of the loss function of the neural network model is obtained according to the difference between the cluster label corresponding to the sample data and the label output by the neural network model.
10. The method of claim 1, wherein, Further comprising: Obtaining the label corresponding to the labeled sample data in each cluster; The average value of the labels of the labeled sample data in the same cluster is used as the cluster label of the cluster.
11. A training processing device, characterized by, Comprising: An acquisition module, a clustering module, a generation module and a processing module, wherein The acquisition module is configured to acquire sample data, wherein the data type of the sample data comprises one of image data and voice data, and the sample data comprises labeled sample data and unlabeled sample data; The acquisition module is configured to acquire sample data, wherein the data type of the sample data comprises one of image data and voice data, and the sample data comprises labeled sample data and unlabeled sample data; The clustering module is used to cluster the labeled sample data and the unlabeled sample data to obtain multiple clusters. The acquisition module is further configured to acquire the remaining sample data in the sample data, wherein the remaining sample data is labeled sample data that is not clustered with the unlabeled sample data; The generation module is used to input the remaining sample data into the generation network model to obtain the generated sample data output by the generation network model, wherein the generation network model is trained using the sample data of the multiple clusters, and the generation network model is used to generate virtual unlabeled sample data based on the labeled sample data; The clustering module is further configured to cluster the generated sample data into one of the plurality of clusters, wherein each of the plurality of clusters corresponds to a cluster label; The processing module is used to train a semi-supervised model using sample data from the multiple clusters, wherein the cluster label of each cluster is used as the label of the sample data during training.
12. An electronic device comprising a memory and a processor; wherein, The memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the steps of the method according to any one of claims 1 to 10.
13. A readable storage medium having stored thereon computer instructions, wherein, When executed by a processor, the computer instructions implement the steps of the method described in any one of claims 1 to 10.