Model training method, device, electronic device and storage medium

By adjusting model parameters with confidence pseudo-labels and loss weights in semi-supervised model training, the problem of limited improvement in training accuracy of semi-supervised model is solved, achieving higher training accuracy and faster convergence speed.

CN114881129BActive Publication Date: 2025-02-18BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210441633.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-25
Publication Date
2025-02-18
Estimated Expiration
2042-04-25

AI Technical Summary

Technical Problem

During the semi-supervised model training process, the pseudo-tagged model is obtained offline, and the model that generates the pseudo-tagged model is not updated, resulting in the semi-supervised model training accuracy that cannot continue to improve, limiting the model's training accuracy.

Method used

By obtaining the sample used for model training, where the unlabeled sample has a pseudo-label and has confidence, input the sample into the semi-supervised model, calculate the model loss and adjust the model parameters, set the loss weight using the confidence of the pseudo-label, and perform model training .

Benefits of technology

Through more accurate model loss calculation, the training accuracy of the semi-supervised model is improved, the convergence speed of the model is accelerated, the calculation resource occupation time is reduced, and the computing resources during model training is saved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114881129B_ABST
    Figure CN114881129B_ABST
Patent Text Reader

Abstract

The present disclosure provides a model training method, which relates to the field of artificial intelligence technology, especially to the technical fields of deep learning, image processing, computer vision, etc., and specifically to a model training method, device, electronic device and storage medium. The specific implementation scheme is: obtain each sample for model training; input the obtained samples into the semi-supervised model to be trained respectively to obtain the output result; calculate the model loss by using the difference between the output result and the label of each sample, and the loss weight corresponding to the pseudo-label; adjust the model parameters of the semi-supervised model based on the model loss, so as to obtain the target semi-supervised model. Through this scheme, the accuracy of the semi-supervised model can be improved; and through a more accurate model loss, the convergence speed of the model can be accelerated, and the occupation time of computing resources can be reduced, thereby saving the computing resources used in model training.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to technical fields such as deep learning, image processing, and computer vision, and specifically to a model training method, device, electronic device, and storage medium. Background Art

[0002] A semi-supervised model is a model trained using a semi-supervised learning method, which is a method of deep learning using partially labeled samples and partially unlabeled samples. The tasks that a semi-supervised model can implement include: object detection tasks, such as image detection tasks or text detection tasks, but are of course not limited to these.

[0003] In order to ensure that the semi-supervised model can converge quickly and avoid occupying computing resources for a long time, pseudo labels can be generated for unlabeled samples during the training process of the semi-supervised model, so that the unlabeled samples and the generated pseudo labels can be used for model training. Summary of the invention

[0004] The present invention provides a model training method, device, electronic device and storage medium.

[0005] According to one aspect of the present disclosure, a model training method is provided, comprising:

[0006] Acquire various samples for model training; wherein an unlabeled first sample in each sample has a pseudo label, and the pseudo label has a confidence level;

[0007] Input the obtained samples into the semi-supervised model to be trained respectively to obtain output results;

[0008] Calculating the model loss using the difference between the output result and the label of each sample, and the loss weight corresponding to the pseudo label; wherein the loss weight is set based on the confidence level and is positively correlated with the confidence level;

[0009] The model parameters of the semi-supervised model are adjusted based on the model loss to obtain a target semi-supervised model.

[0010] According to a second aspect of the present disclosure, a model training device is provided, comprising:

[0011] An acquisition module, used for acquiring each sample for model training; wherein the unlabeled first sample in each sample has a pseudo label, and the pseudo label has a confidence level;

[0012] An input module, used to input the acquired samples into the semi-supervised model to be trained to obtain output results;

[0013] A calculation module, used to calculate the model loss by using the difference between the output result and the label of each sample, and the loss weight corresponding to the pseudo label; wherein the loss weight is set based on the confidence level and is positively correlated with the confidence level;

[0014] A judgment module is used to adjust the model parameters of the semi-supervised model based on the model loss, so as to obtain a target semi-supervised model.

[0015] According to a third aspect of the present disclosure, there is provided an electronic device, including:

[0016] at least one processor; and

[0017] a memory communicatively connected to the at least one processor; wherein,

[0018] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any model training method.

[0019] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any model training method.

[0020] According to another aspect of the present disclosure, a computer program product is also provided, including a computer program, which implements any model training method when executed by a processor.

[0021] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0023] Figure 1 is a flow chart of a model training method provided according to the present disclosure;

[0024] Figure 2 is another flow chart of a model training method provided according to the present disclosure;

[0025] Figure 3 is a structural schematic diagram of a model training device provided according to the present disclosure;

[0026] Figure 4 It is a block diagram of an electronic device used to implement the model training method of an embodiment of the present disclosure. DETAILED DESCRIPTION

[0027] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0028] STAC (A Simple Semi-Supervised Learning Framework for Object Detection) is representative in the current semi-supervised training based on self-training. For this kind of semi-supervised learning architecture, firstly, a teacher model for generating pseudo labels is trained using labeled samples, that is, a pseudo label generation model is trained using labeled samples. The model is used to generate pseudo labels corresponding to a given sample. Specifically, the model can output the confidence of each type of label, and the label with the highest confidence is used as the pseudo label of the sample; then, the trained Teacher model can be used to generate pseudo labels for unlabeled samples; finally, the labeled samples and unlabeled samples with pseudo labels are input into the student model to be trained, that is, the semi-supervised model, and the loss of the semi-supervised model is calculated to detect whether the model is trained.

[0029] However, during the training of the semi-supervised model, the pseudo-labels are obtained offline, and the model that generates the pseudo-labels is not updated during the training of the semi-supervised model. Therefore, during the training of the semi-supervised model, when the accuracy of the semi-supervised model exceeds the accuracy of the model that generates the pseudo-labels, the accuracy of the semi-supervised model training cannot be further improved, thus limiting the training accuracy of the semi-supervised model.

[0030] In another semi-supervised model training process, the pseudo-label online update method is used to improve the accuracy of the semi-supervised model. In this training method, the model that generates pseudo-labels is updated online, and the quality of pseudo-labels will be improved in time, thereby improving the accuracy of model training and making the model converge. However, in this training method, the unlabeled samples used to train the semi-supervised model, regardless of the confidence of the pseudo-label, that is, the credibility of the pseudo-label, have the same supervisory role in model training, which undoubtedly limits the improvement of the accuracy of the semi-supervised model.

[0031] Based on the above problems, the embodiments of the present disclosure provide a model training method, device, electronic device and storage medium to further improve the accuracy of the semi-supervised model.

[0032] The following first introduces a model training method provided by the present invention.

[0033] Among them, a model training method involved in an embodiment of the present disclosure can be applied to an electronic device, which can be a terminal device or a server, and the present disclosure does not limit the specific form of the electronic device. In addition, a model training method provided in an embodiment of the present disclosure can be applied to any scenario of training a semi-supervised model using labeled samples and unlabeled samples, and the present disclosure does not limit the specific scenario.

[0034] Furthermore, the semi-supervised model involved in the present disclosure is a model trained using a semi-supervised learning method; the tasks that can be implemented by the semi-supervised model may include: object detection tasks, but are of course not limited thereto. Among them, the essence of the object detection task can be considered as a classification task, that is, the category to which the detected object belongs. At this time, the object category is the label, the labeled sample can be a sample labeled with an object category, the unlabeled sample can be a sample of an unlabeled object category, and the pseudo-label of the unlabeled sample represents an object category, and the confidence of the pseudo-label is the credible probability that the unlabeled sample belongs to the represented object category.

[0035] In addition, in specific applications, the sample type can be image, text, etc., but it is certainly not limited to this. For example, if the sample type is an image type, then the object detection task can be to detect the identity category of the object in the sample image, or it can also be to detect the identity category and location information of the object in the sample image; if the sample type is a text type, then the object detection task can be to detect the category of the emotion represented by the text, such as pessimism, positivity, etc.

[0036] A model training method provided in an embodiment of the present disclosure may include the following steps:

[0037] Acquire various samples for model training; wherein an unlabeled first sample in each sample has a pseudo label, and the pseudo label has a confidence level;

[0038] Input the obtained samples into the semi-supervised model to be trained respectively to obtain output results;

[0039] Calculating the model loss using the difference between the output result and the label of each sample, and the loss weight corresponding to the pseudo label; wherein the loss weight is set based on the confidence level and is positively correlated with the confidence level;

[0040] The model parameters of the semi-supervised model are adjusted based on the model loss to obtain a target semi-supervised model.

[0041] In this solution, the pseudo-label corresponds to a loss weight, and the loss weight is set based on the confidence of the pseudo-label and is positively correlated with the confidence. That is, the supervisory role of the pseudo-label of the first sample in the model training process is affected by the confidence, which makes the application of the pseudo-label of the first sample more reasonable; therefore, when training the semi-supervised model, a more accurate model loss can be calculated by using the difference between the output results of each sample and the labels of each sample, as well as the loss weight corresponding to the pseudo-label. It can be seen that this solution can further improve the accuracy of the semi-supervised model; and through a more accurate model loss, the convergence speed of the model can be accelerated, reducing the time occupied by computing resources, thereby saving computing resources used in model training.

[0042] The following is an exemplary introduction to a model training method provided by the present disclosure in conjunction with the accompanying drawings.

[0043] like Figure 1 As shown, a model training method provided by the present disclosure may include the following steps:

[0044] S101: Obtain samples for model training;

[0045] Wherein, the unlabeled first sample in each sample has a pseudo label, and the pseudo label has a confidence level;

[0046] In the model training process for the semi-supervised model, each sample can be first obtained, and then the obtained samples can be used for model training. It can be understood that since it is a training for the semi-supervised model, each sample can include an unlabeled first sample and a labeled second sample. Among them, the second sample has a labeled label, and the labeled label is the true value labeled for the second sample; while the first sample is not labeled, but a pseudo label is set for the first sample in advance through a predetermined pseudo label generation method, and the pseudo label has a confidence level.

[0047] Exemplarily, each sample can be an image sample, in which case the pseudo-label of the first sample can be the object category in the image, and the confidence of the pseudo-label is the probability of belonging to the object category; and the annotated label of the second sample can be the object category in the image. Exemplarily, each sample can be a text sample, in which case the pseudo-label of the first sample can be the emotion category represented by the text, and the confidence of the pseudo-label is the probability of belonging to the emotion category; and the annotated label of the second sample can be the emotion category expressed by the text.

[0048] The method for obtaining the second sample may include obtaining the second sample from a public data set, but is not limited thereto, and this embodiment does not limit this. In addition, for the sake of clarity of the scheme and layout, the specific method for obtaining the first sample is exemplarily introduced below in combination with other embodiments.

[0049] It should be noted that the collection, storage, use, processing, transmission, provision and disclosure of samples involved in the technical solution of the present disclosure are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0050] S102: Input the acquired samples into the semi-supervised model to be trained respectively to obtain output results;

[0051] After obtaining each sample, the semi-supervised model to be trained can be trained. First, each sample can be input into the semi-supervised model to be trained to obtain each output result; then, according to the output result, the subsequent model training steps are performed. It should be noted that each sample will correspond to an output result.

[0052] For example, taking the object detection task as an example, the output result can be the confidence of each object category, for example, if the input is a text, the output result can be the confidence of the text category, for example, the confidence of the pessimistic category is 40%, and the confidence of the positive category is 60%. Of course, it is not limited to this.

[0053] When the accuracy of the semi-supervised model is very high, the output result may be similar to the label corresponding to the input sample, but there are small differences, for example: the output result of the first sample is similar to the pseudo label of the first sample; the output result of the second sample is similar to the label of the second sample. When the model accuracy is very low, the output result may be very different from the label corresponding to the input sample, and some may even be completely different. This is all possible.

[0054] It should be noted that the output results of different samples may be the same or different, and the present disclosure does not limit this.

[0055] S103: Calculate the model loss using the difference between the output result and the label of each sample, and the loss weight corresponding to the pseudo label;

[0056] Among them, the loss weight is set based on the confidence of the pseudo-label, and is positively correlated with the confidence of the pseudo-label; that is, the loss weight is affected by the confidence of the pseudo-label, and the change trend of the loss weight is consistent with the change trend of the confidence of the pseudo-label. When the loss weight is high, the confidence is also high, and when the loss weight is low, the confidence is also low. It should be emphasized that the label of the first sample is the pseudo-label of the first sample; the label of the second sample is the label marked by the second sample.

[0057] After obtaining the output result of the semi-supervised model to be trained, the output result can be used to calculate the model loss of the semi-supervised model, so as to judge whether the model training is completed according to the model loss.

[0058] It should be noted that there will be a difference between the output result of each sample and the label of each sample. The label corresponding to the first sample is a pseudo label, and the label corresponding to the second sample is a marked label. The difference between the output result of each sample and the label of each sample can be used to calculate the loss of the semi-supervised model.

[0059] Exemplarily, by utilizing the difference between the output results of each sample and the label of each sample, and the loss weight corresponding to the pseudo-label, the method for calculating the model loss can be: calculating the model loss by calculating the output results of each sample with the label of each sample, and the loss weight corresponding to the pseudo-label according to a predetermined loss value calculation function.

[0060] Exemplarily, in one implementation, the loss of the semi-supervised model to be trained can be calculated by calculating the cross entropy. At this time, the output results of each sample, the labels of each sample, and the loss weights corresponding to the pseudo labels can be substituted into the specified cross entropy calculation formula to obtain the model loss.

[0061] The calculation formula of cross entropy is:

[0062] C=-1 / n*∑ x [ylna+(1-y)ln(1-a)]

[0063] Where n is the number of samples, x is the sample, a is the output result corresponding to the sample, when x is the second sample, y is the label of the second sample, when x is the first sample, y is the product of the pseudo label of the first sample and the loss weight. In this way, the loss weight corresponding to the pseudo label acts on the calculation process of the model loss.

[0064] It should be noted that the above method of calculating the model loss using cross entropy is only an example, and any method that can calculate the model loss can be applied to the present disclosure and is not limited here.

[0065] S104: adjusting model parameters of the semi-supervised model based on the model loss, thereby obtaining a target semi-supervised model;

[0066] After the model loss calculation is completed, it can be determined whether the model has converged based on the calculation results. Exemplarily, in one implementation, the method for determining whether the model has converged may include: if the model loss is not higher than a preset threshold, the model accuracy is determined to meet the requirements and the training is completed; if the model loss is higher than the preset threshold, the model accuracy is still too low and further training is required. At this time, the model parameters of the semi-supervised model are adjusted, and the above steps of obtaining each sample for model training are returned until the model loss is no higher than the preset threshold, and the target semi-supervised model is obtained. Among them, when adjusting the model parameters, the gradient descent method can be used, but it is of course not limited to this.

[0067] In this solution, the pseudo-label corresponds to a loss weight, and the loss weight is set based on the confidence of the pseudo-label and is positively correlated with the confidence. That is, the supervisory role of the pseudo-label of the first sample in the model training process is affected by the confidence, which makes the application of the pseudo-label of the first sample more reasonable; therefore, when training the semi-supervised model, a more accurate model loss can be calculated by using the difference between the output results of each sample and the labels of each sample, as well as the loss weight corresponding to the pseudo-label. It can be seen that this solution can further improve the accuracy of the semi-supervised model; and through a more accurate model loss, the convergence speed of the model can be accelerated, reducing the time occupied by computing resources, thereby saving computing resources used in model training.

[0068] Optionally, in another embodiment of the present disclosure, a method for acquiring the first sample includes:

[0069] Determine at least one initial sample that is unlabeled;

[0070] Generate a pseudo label for the initial sample using a pre-trained pseudo label generation model; wherein the pseudo label generation model is a model trained using labeled samples and corresponding labels;

[0071] From the initial samples with pseudo labels, select the first sample.

[0072] Among them, the pseudo-label generation model can be trained online, that is, it can be updated in time, so as to improve the training accuracy of the semi-supervised model. The specific model structure of the pseudo-label generation model is not limited in this disclosure; in addition, the training process of the pseudo-label generation model can include: outputting the labeled samples to the pseudo-label generation model to be trained to obtain the output result, and then calculating the model loss of the pseudo-label generation model by using the difference between the output result and the pseudo-label. If the model loss is less than the set threshold, convergence is determined; if it is not less than the set threshold, the model parameters are adjusted, and the labeled samples and corresponding labels are continued to be obtained, so as to continue to train the model.

[0073] Exemplarily, in one implementation, each initial sample with a pseudo-label can be used as a first sample to be applied to the training process of the semi-supervised model, thereby ensuring the sufficiency of the first samples.

[0074] Exemplarily, the method of selecting the first sample from the initial samples with pseudo labels may be: selecting, from the initial samples with pseudo labels, an initial sample having a pseudo label whose confidence level is not less than a first threshold, to obtain the first sample.

[0075] Since pseudo-labels with low confidence levels play a small or no role in the training process of the semi-supervised model, initial samples with pseudo-label confidence levels not lower than a first threshold can be selected from the initial samples with pseudo-labels as the first samples, that is, the initial samples are screened to select pseudo-labels that can play a greater role in the training process of the semi-supervised model, thereby improving the accuracy of semi-supervised model training.

[0076] It should be noted that the above method of obtaining various samples for model training is only an example and should not constitute a limitation of the present disclosure.

[0077] It can be seen that in this embodiment, a pseudo-label generation model is used to generate pseudo-labels for each initial sample, and the first sample is selected based on the initial sample with the pseudo-label, so that the first sample can be obtained quickly and effectively.

[0078] Based on the above model training method, in another embodiment of the present disclosure, another model training method is provided, such as Figure 2 As shown, the following steps may be included:

[0079] S201: Obtain samples for model training;

[0080] S202: Input the acquired samples into the semi-supervised model to be trained respectively to obtain output results;

[0081] S203: Determine the loss weight corresponding to the pseudo label of the first sample;

[0082] Since the loss weight corresponding to the pseudo label is needed in the model loss calculation process, the loss weight corresponding to the pseudo label can be determined first, so as to perform subsequent loss calculation steps.

[0083] Exemplarily, a method for determining the loss weight corresponding to the pseudo label may include steps A1 and A2:

[0084] Step A1, determining a target confidence interval in which the confidence of the pseudo label of the first sample lies; wherein the target confidence interval is one of a plurality of confidence intervals, and different confidence intervals correspond to different loss weights;

[0085] Step A2: determine the loss weight corresponding to the target confidence interval as the loss weight corresponding to the pseudo label.

[0086] Due to the positive correlation between confidence and loss weight, multiple confidence intervals can be set. When it is necessary to determine the loss weight corresponding to a certain pseudo-label confidence, the corresponding confidence interval can be determined first, thereby determining the loss weight corresponding to the pseudo-label. It can be understood that, under the premise of ensuring that the loss weight is positively correlated with the confidence, the specific value of the loss weight corresponding to each confidence interval can be set according to the actual situation, and this disclosure does not limit it.

[0087] It should be noted that by setting multiple confidence intervals, it is possible to avoid setting too many loss weights, which would result in cumbersome calculations, because each different confidence level corresponds to a different loss weight.

[0088] Optionally, in one implementation, multiple confidence intervals are divided according to a specified step size. For example, the specified unit step size may be 20%. In this case, the multiple confidence intervals are: (0, 20%], (20%, 40%], (40%, 60%], (60%, 80%], (80%, 100%], and the loss weights corresponding to the confidence intervals may be 0.2, 0.4, 0.6, 0.8, and 1, respectively.

[0089] Optionally, in another implementation, the confidence level of the pseudo-label is not lower than a first threshold. In this case, the multiple confidence intervals include a first confidence interval and a second confidence interval, and the loss weight corresponding to the first confidence interval is higher than the loss weight corresponding to the second confidence interval; wherein the confidence levels in the first confidence interval are all higher than the second threshold, the confidence levels in the second confidence interval are not lower than the first threshold and not higher than the second threshold, and the second threshold is higher than the first threshold.

[0090] For example, if the confidence of the pseudo-label is not less than the first threshold (30%), then if the first threshold is 30% and the second threshold is 60%, the first confidence interval can be 100% to 60%, and the corresponding loss weight is 1, and the second confidence interval can be 60% to 30%, and the corresponding loss weight is 0.5. If the confidence of a pseudo-label is 80%, it belongs to the first confidence interval, and its weight is set to 1. If the confidence of a pseudo-label is 40%, it belongs to the second confidence interval, and its weight is set to 0.5.

[0091] This method of setting the interval through the first threshold and the second threshold can be called a dual threshold method. Of course, multiple thresholds can also be set according to actual needs, which is reasonable. At this time, the weights of pseudo-labels with higher confidence levels can be directly determined, which improves the efficiency of model training and can improve the accuracy of the model. In addition, it should be emphasized that the "first" in the "first threshold", the "second" in the "second threshold", the "first" in the "first confidence interval", and the "second" in the "second confidence interval" mentioned in the embodiments of the present disclosure are only used to distinguish different thresholds and intervals belonging to different thresholds in terms of naming, and do not have any limiting meaning.

[0092] The above description of the method for determining the loss weight corresponding to the pseudo label is merely an example and should not constitute a limitation of the present disclosure.

[0093] S204: Calculate the model loss using the difference between the output result and the label of each sample, and the loss weight corresponding to the pseudo label;

[0094] S205: adjusting the model parameters of the semi-supervised model based on the model loss, thereby obtaining a target semi-supervised model;

[0095] Steps S201 and S202 are similar to the above-mentioned steps S101 and S102, and steps S204 and S205 are similar to the above-mentioned steps S103 and S104, and are not described in detail here.

[0096] In this solution, the pseudo-label corresponds to a loss weight, and the loss weight is set based on the confidence of the pseudo-label and is positively correlated with the confidence. That is, the supervisory role of the pseudo-label of the first sample in the model training process is affected by the confidence, which makes the application of the pseudo-label of the first sample more reasonable; therefore, when training the semi-supervised model, a more accurate model loss can be calculated using the output results of each sample and the difference between each sample, as well as the loss weight corresponding to the pseudo-label. It can be seen that this solution can further improve the accuracy of the semi-supervised model; and through a more accurate model loss, the convergence speed of the model can be accelerated, reducing the time occupied by computing resources, thereby saving computing resources used in model training.

[0097] Optionally, in another embodiment of the present disclosure, the task for the semi-supervised model may be an object detection task, which is a detection task for an image.

[0098] Accordingly, a model training method may include steps A to D:

[0099] Step A, obtaining each image sample for model training;

[0100] Among them, the first image sample is an unlabeled image sample, and the second image sample is a labeled image sample. The second sample is labeled with a label. Exemplary labels may be: animal image labels, plant image labels, etc. The pseudo-label of the first sample may be a pseudo-label generated by a predetermined pseudo-label generation method. For example, the image of the first sample contains image content of a dog, and the labels generated by the predetermined pseudo-label generation method are: an animal image label with a confidence of 80%, and a plant image label with a confidence of 20%. At this time, the animal image label can be used as the pseudo-label of the first sample image, and its confidence is 80%.

[0101] Step B: input each acquired image sample into the semi-supervised model to be trained to obtain an output result.

[0102] For the first image sample, the first image sample is an image of a cat, and the output result may be: animal type, and for the second image sample, the second image sample is an image of a tree, and the output result may be: plant type. If the accuracy of the semi-supervised model to be trained is not high, the output result may be greatly different from the actual result, for example, for a certain animal image, the output result is a plant type image.

[0103] Step C, using the difference between the output result and the label of each image sample, as well as the loss weight corresponding to the pseudo label, calculates the model loss.

[0104] Among them, when the confidence of the pseudo-label is very high, its loss weight can be set to a larger value, so as to increase the role of the first image sample in the model loss calculation during loss calculation. When the confidence of the pseudo-label is low, a smaller loss weight can be set to reduce the role of the first image sample in the model loss calculation and increase the accuracy of the model loss calculation.

[0105] Step D, adjust the model parameters of the semi-supervised model based on the model loss to obtain the target semi-supervised model:

[0106] When testing image samples, if the model loss is very small, such as 0.1 or 0.2, the parameters of the semi-supervised model can be left unchanged, and the target semi-supervised model can be directly obtained. When the model loss is large, such as 0.5, 0.6 or 0.7, the model parameters need to be adjusted, and the semi-supervised model needs to be trained continuously until the image obtained is the target image, thereby obtaining the target semi-supervised model.

[0107] It can be seen that this scheme can further improve the accuracy of the semi-supervised model; and, through a more accurate model loss, the convergence speed of the model can be accelerated, reducing the time occupied by computing resources, thereby saving computing resources used in model training.

[0108] According to an embodiment of the present disclosure, the present disclosure also provides a model training device, such as Figure 3 As shown, the device comprises:

[0109] An acquisition module 310 is used to acquire each sample for model training; wherein an unlabeled first sample in each sample has a pseudo label, and the pseudo label has a confidence level;

[0110] An input module 320, used to input the acquired samples into the semi-supervised model to be trained to obtain output results;

[0111] A calculation module 330, configured to calculate a model loss by using the difference between the output result and the label of each sample, and the loss weight corresponding to the pseudo label; wherein the loss weight is set based on the confidence level and is positively correlated with the confidence level;

[0112] The judgment module 340 is used to adjust the model parameters of the semi-supervised model based on the model loss, so as to obtain a target semi-supervised model.

[0113] In this solution, the pseudo-label corresponds to a loss weight, and the loss weight is set based on the confidence of the pseudo-label and is positively correlated with the confidence. That is, the supervisory role of the pseudo-label of the first sample in the model training process is affected by the confidence, which makes the application of the pseudo-label of the first sample more reasonable; therefore, when training the semi-supervised model, a more accurate model loss can be calculated by using the difference between the output results of each sample and the corresponding label, as well as the loss weight corresponding to the pseudo-label. It can be seen that this solution can further improve the accuracy of the semi-supervised model; and through a more accurate model loss, the convergence speed of the model can be accelerated, reducing the time occupied by computing resources, thereby saving computing resources used in model training.

[0114] Optionally, it also includes:

[0115] A first determination module is used to determine a target confidence interval in which the confidence of the pseudo label of the first sample is located before the calculation module calculates the model loss using the difference between the output results of each sample and the labels of each sample and the loss weight corresponding to the pseudo label; wherein the target confidence interval is one of a plurality of confidence intervals, and different confidence intervals correspond to different loss weights;

[0116] The second determination module is used to determine the loss weight corresponding to the target confidence interval as the loss weight corresponding to the pseudo label.

[0117] Optionally, the pseudo-label has a confidence level not less than a first threshold;

[0118] The multiple confidence intervals include a first confidence interval and a second confidence interval, and the loss weight corresponding to the first confidence interval is higher than the loss weight corresponding to the second confidence interval;

[0119] The confidence levels in the first confidence interval are all higher than the second threshold, the confidence levels in the second confidence interval are not lower than the first threshold and not higher than the second threshold, and the second threshold is higher than the first threshold.

[0120] Optionally, the method for obtaining the first sample includes:

[0121] Determine at least one initial sample that is unlabeled;

[0122] Generate a pseudo label for the initial sample using a pre-trained pseudo label generation model; wherein the pseudo label generation model is a model trained using labeled samples and corresponding labels;

[0123] From the initial samples with pseudo labels, select the first sample.

[0124] Optionally, selecting a first sample from the initial samples with pseudo labels includes:

[0125] From the initial samples with pseudo labels, an initial sample having a pseudo label whose confidence level is not less than a first threshold is selected to obtain a first sample.

[0126] Optionally, the calculation module is specifically used for:

[0127] Based on the output results and the labels of each sample, and the loss weights corresponding to the pseudo labels, the model loss is calculated according to a predetermined loss value calculation function.

[0128] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0129] An embodiment of the present disclosure provides an electronic device, including:

[0130] at least one processor; and

[0131] a memory communicatively connected to the at least one processor; wherein,

[0132] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any model training method.

[0133] An embodiment of the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute any model training method.

[0134] An embodiment of the present disclosure provides a computer program product, including a computer program, which implements any model training method when executed by a processor.

[0135] Figure 4 A schematic block diagram of an example electronic device 400 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0136] like Figure 4 As shown, the device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0137] A number of components in the device 400 are connected to the I / O interface 405, including: an input unit 406, such as a keyboard, a mouse, etc.; an output unit 407, such as various types of displays, speakers, etc.; a storage unit 408, such as a disk, an optical disk, etc.; and a communication unit 409, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 409 allows the device 400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0138] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above, such as the model training method. For example, in some embodiments, the model training method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 400 via ROM 402 and / or communication unit 409. When the computer program is loaded into RAM 403 and executed by the computing unit 401, one or more steps of the model training method described above may be performed. Alternatively, in other embodiments, the computing unit 401 may be configured to perform the model training method in any other appropriate manner (e.g., by means of firmware).

[0139] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0140] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0141] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0142] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0143] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0144] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0145] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0146] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A model training method, comprising: Obtain each sample for model training; wherein, the unlabeled first sample in each sample has a pseudo-label, and the pseudo-label has a confidence level; the pseudo-label of the first sample is generated by a pseudo-label generation model based on online training; the method for obtaining the first sample includes: determining at least one initial sample that is unlabeled; using a pre-trained pseudo-label generation model to generate a pseudo-label for the initial sample, and selecting an initial sample whose pseudo-label confidence level is not less than a first threshold from the initial samples with pseudo-labels to obtain a first sample; wherein the pseudo-label generation model is a model trained using labeled samples and corresponding labels; each sample is of the same type, and any sample is of an image type or a text type; Input the obtained samples into the semi-supervised model to be trained respectively to obtain output results; Determine a target confidence interval in which the confidence of the pseudo label of the first sample is located; wherein the target confidence interval is any one of a first confidence interval and a second confidence interval, the loss weight corresponding to the first confidence interval is higher than the loss weight corresponding to the second confidence interval, and the loss weight corresponding to the first confidence interval is 1; the confidences in the first confidence interval are all higher than a second threshold, the confidences in the second confidence interval are not lower than the first threshold and not higher than the second threshold, and the second threshold is higher than the first threshold; Determine the loss weight corresponding to the target confidence interval as the loss weight corresponding to the pseudo label; Calculate the model loss using the difference between the output result and the label of each sample, and the loss weight corresponding to the pseudo label; The model parameters of the semi-supervised model are adjusted based on the model loss to obtain a target semi-supervised model.

2. The method according to claim 1, wherein: The calculating the model loss by using the difference between the output result and the label of each sample and the loss weight corresponding to the pseudo label includes: Based on the output results and the labels of each sample, as well as the loss weights corresponding to the pseudo labels, the model loss is calculated according to a preset loss value calculation function.

3. A model training device, comprising: An acquisition module is used to acquire various samples for model training; wherein, an unlabeled first sample in each sample has a pseudo-label, and the pseudo-label has a confidence level; the pseudo-label of the first sample is generated by a pseudo-label generation model based on online training; the acquisition method of the first sample includes: determining at least one initial sample that is unlabeled; using a pre-trained pseudo-label generation model to generate a pseudo-label for the initial sample, and selecting an initial sample whose pseudo-label confidence level is not less than a first threshold from the initial samples with pseudo-labels to obtain a first sample; wherein the pseudo-label generation model is a model trained using labeled samples and corresponding labels; the types of the various samples are the same, and the type of any sample is an image type or a text type; An input module, used to input the acquired samples into the semi-supervised model to be trained to obtain output results; A first determination module is used to determine a target confidence interval in which the confidence of the pseudo-label of the first sample is located before the calculation module calculates the model loss using the difference between the output results of each sample and the labels of each sample, and the loss weight corresponding to the pseudo-label; wherein the target confidence interval is any one of the first confidence interval and the second confidence interval, the loss weight corresponding to the first confidence interval is higher than the loss weight corresponding to the second confidence interval, and the loss weight corresponding to the first confidence interval is 1; the confidences in the first confidence interval are all higher than a second threshold, the confidences in the second confidence interval are not lower than the first threshold and not higher than the second threshold, and the second threshold is higher than the first threshold; A second determination module is used to determine the loss weight corresponding to the target confidence interval as the loss weight corresponding to the pseudo label; A calculation module, used to calculate the model loss by using the difference between the output result and the label of each sample, and the loss weight corresponding to the pseudo label; A judgment module is used to adjust the model parameters of the semi-supervised model based on the model loss, so as to obtain a target semi-supervised model.

4. The device according to claim 3, wherein: The calculation module is specifically used for: Based on the output results and the labels of each sample, and the loss weights corresponding to the pseudo labels, the model loss is calculated according to a predetermined loss value calculation function.

5. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 2.

6. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-2.

7. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 2.

Citation Information

Patent Citations

  • Semi-supervised learning method based on pseudo label weighting

    CN112232416A

  • Ship detection semi-supervised online training method and device and computer storage medium

    CN114186615A