Model training method, device and computer storage medium

Through the semi-supervised model training method with a dual-branch structure, combined with labeled and unlabeled sample training image classification model, the problems of low labeling efficiency and high cost are solved, the model training cost is reduced and the stability and generalization of the prediction results are improved.

CN114299355BActive Publication Date: 2025-09-09GUANGZHOU YUNCONG INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111476661.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-02
Publication Date
2025-09-09
Estimated Expiration
2041-12-02

Smart Images

  • Figure CN114299355B_ABST
    Figure CN114299355B_ABST
Patent Text Reader

Abstract

The present disclosure provides a model training method, apparatus, and computer storage medium, comprising constructing a classification branch and an embedding branch of a target model; inputting a first training sample generated based on a first labeled original image sample into the classification branch to perform classification prediction, thereby obtaining a classification loss function for the classification branch; inputting any two second training samples generated based on a second unlabeled original image sample into the embedding branch to perform comparative prediction, thereby obtaining a comparative loss function for the embedding branch; and training the target model based on the classification loss function and the comparative loss function. Consequently, the present disclosure can reduce data annotation costs and expand the amount of sample data for training, thereby improving the stability and generalization of model prediction results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of artificial intelligence technology, and in particular to a model training method, device, and computer storage medium. Background Art

[0002] Currently, supervised learning methods are commonly used to train deep learning models for image classification. This method relies on a large amount of labeled data as a dataset to train the model.

[0003] However, target data labeling is mostly done manually, which not only has low labeling efficiency and is prone to errors, but also leads to high model training costs.

[0004] In view of this, there is an urgent need for a model training method that can reduce training costs. Summary of the Invention

[0005] In view of the above problems, the present disclosure provides a model training method, device and computer storage medium, which can reduce the cost of model training.

[0006] The first aspect of the present disclosure provides a model training method, including constructing a classification branch and an embedding branch of a target model; inputting a first training sample generated based on a labeled first original image sample into the classification branch to perform classification prediction, and obtaining a classification loss function of the classification branch; inputting any two second training samples generated based on an unlabeled second original image sample into the embedding branch to perform comparative prediction, and obtaining a comparative loss function of the embedding branch; training the target model according to the classification loss function and the comparative loss function; inputting any two first training samples generated based on the labeled first original image sample into the embedding branch to perform comparative prediction, and obtaining a first comparative loss sub-function of the embedding branch; inputting any two second training samples generated based on the unlabeled second original image sample into the embedding branch to perform comparative prediction, and obtaining a second comparative loss sub-function of the embedding branch; and obtaining the comparative loss function of the embedding branch according to the first comparative loss sub-function and the second comparative loss sub-function.

[0007] A second aspect of the present disclosure provides a computer storage medium storing instructions for executing each step in the model training method described in the first aspect.

[0008] The third aspect of the present disclosure provides a model training device, including: a construction module, for constructing a classification branch and an embedding branch of a target model; a training module, for inputting a first training sample generated based on a labeled first original image sample into the classification branch to perform classification prediction, obtain a classification loss function of the classification branch, and inputting any two second training samples generated based on an unlabeled second original image sample into the embedding branch to perform comparative prediction, obtain a comparative loss function of the embedding branch, and training the target model according to the classification loss function and the comparative loss function; inputting any two first training samples generated based on the labeled first original image sample into the embedding branch to perform comparative prediction, obtain a first comparative loss sub-function of the embedding branch; inputting any two second training samples generated based on the unlabeled second original image sample into the embedding branch to perform comparative prediction, obtain a second comparative loss sub-function of the embedding branch; and obtaining the comparative loss function of the embedding branch according to the first comparative loss sub-function and the second comparative loss sub-function.

[0009] In summary, the model training scheme provided by the embodiment of the present disclosure designs a semi-supervised model training method based on a dual-branch structure, which can combine labeled samples and unlabeled samples to perform model training tasks. It can not only reduce the data labeling cost, but also greatly expand the model training data set to improve the stability and generalization of the model prediction results. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present disclosure. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0011] Figure 1 Schematic diagram of the model training method according to the first embodiment of the present invention.

[0012] Figure 2 Schematic diagram of the model training method according to the second embodiment of the present disclosure.

[0013] Figure 3 Schematic diagram of the model training method according to the third embodiment of the present disclosure.

[0014] Figure 4 Schematic diagram of the flow of the model training method of the fourth embodiment of the present disclosure.

[0015] Figure 5 Schematic diagram of the model training method according to the fifth embodiment of the present disclosure.

[0016] Figure 6 Schematic diagram of the architecture of the model training device of the seventh embodiment of the present disclosure.

[0017] Component number

[0018] 600: Model training device; 602: Construction module; 604: Training module; 610: Target model; 612: Classification branch; 614: Embedding branch. DETAILED DESCRIPTION

[0019] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present disclosure should fall within the scope of protection of the embodiments of the present disclosure.

[0020] As mentioned in the background technology section, current model training mostly requires a large amount of labeled data to implement, resulting in high model training costs. In view of this, the present disclosure provides an improved model training solution that can reduce the dependence on labeled data during model training.

[0021] The following will describe in detail the implementation of each specific embodiment disclosed in conjunction with the accompanying drawings.

[0022] First embodiment

[0023] Figure 1 The following is a flow chart of the model training method according to the first embodiment of the present disclosure. As shown in the figure, this embodiment mainly includes the following steps:

[0024] Step S102: construct the classification branch and embedding branch of the target model.

[0025] Optionally, the target model is, for example, an image classification prediction model.

[0026] Optionally, the embedding branch may include two fully connected layers.

[0027] Alternatively, the classification branch may comprise a linear classifier.

[0028] Step S104: input the first training sample generated based on the labeled first original image sample into the classification branch to perform classification prediction, and obtain a classification loss function of the classification branch.

[0029] Optionally, multiple enhancement processes may be performed on the labeled first original image sample to obtain first training samples corresponding to each enhancement process.

[0030] In this embodiment, after performing each enhancement process on the labeled first original image sample, the first training samples obtained are not completely the same. Preferably, the first training samples generated are completely different.

[0031] Optionally, the classification branch can be used to perform classification prediction on the first training sample to obtain a predicted classification label of the first training sample, and based on the true classification label and the predicted classification label of the first training sample, a classification loss function of the classification branch can be obtained.

[0032] Step S106: Input any two second training samples generated based on the unlabeled second original image sample into the embedding branch to perform comparative prediction, and obtain a comparative loss function of the embedding branch.

[0033] Optionally, multiple enhancement processes may be performed on the unlabeled second original image sample to obtain second training samples corresponding to each enhancement process.

[0034] In this embodiment, after performing each enhancement process on the unlabeled second original image sample, the second training samples obtained may not be completely the same. Preferably, the second training samples generated are completely different.

[0035] Optionally, the embedding branch may be used to perform comparative prediction based on the two input second training samples to obtain a comparison result of the two second training samples, and a comparative loss function of the embedding branch may be obtained based on the comparison result.

[0036] In this embodiment, there is no limitation on the execution order of step S104 and step S106 , which may be executed sequentially or simultaneously.

[0037] Step S108: training the target model according to the classification loss function and the contrast loss function.

[0038] Specifically, the classification loss function of the classification branch and the contrast loss function of the embedding branch can be added together, and the target model is trained based on the summed loss function.

[0039] In summary, the model training method of this embodiment constructs a classification branch and an embedding branch, so as to use the classification branch to perform classification prediction for labeled training samples, and use the embedding branch to perform comparative prediction for unlabeled training samples. With this dual-branch model architecture design, labeled data and unlabeled data can be combined to train the target model, which not only reduces the cost of manual labeling of training data to reduce the cost of model training, but also can greatly expand the unlabeled training data to improve the stability and generalization of the model prediction results.

[0040] Second embodiment

[0041] Figure 2 The flowchart of the model training method of the second embodiment of the present disclosure is shown. This embodiment is a specific implementation plan of the above step S104. As shown in the figure, this embodiment mainly includes the following steps:

[0042] Step S202: Input the first training sample generated based on the first original image sample into the classification branch to perform classification prediction, and obtain a category prediction value of the first training sample.

[0043] Optionally, a convolutional neural network may be used to perform feature extraction on the first training sample to obtain first extracted features of the first training sample, so that the classification branch can perform classification prediction on the first training sample based on the first extracted features.

[0044] Step S204 : obtaining a classification loss function of a classification branch according to the category prediction value of the first training sample, the actual category of the first training sample, and a first preset loss function conversion rule.

[0045] In this embodiment, the first preset loss function conversion rule is expressed as:

[0046]

[0047] Among them, L class represents the classification loss function of the classification branch, i represents the first training sample of the i-th class, c represents the c-th class, and M represents the number of classes; y ic represents the true category of the i-th first training sample, where if the true category of the i-th first training sample is c, then y ic The value of is 1. If the true category of the first training sample of i is not c, then y ic The value of p is 0; ic Indicates the category prediction value that the i-th first training sample belongs to the c-th category.

[0048] Third embodiment

[0049] Figure 3 The flowchart of the model training method of the third embodiment of the present disclosure is shown. This embodiment mainly shows the specific implementation of the above step S106. As shown in the figure, this embodiment mainly includes the following steps:

[0050] Step S302: Input any two second training samples generated based on the second original image sample into the embedding branch to perform comparative prediction, and obtain a comparison result of the two second training samples.

[0051] Optionally, a convolutional neural network may be used to perform feature extraction on the two second training samples to obtain two second extracted features corresponding to the two second training samples, so that the embedding branch can perform comparative prediction on the two second training samples based on the two second extracted features.

[0052] Step S304: Obtain the sample comparison loss values ​​of the two second training samples according to the comparison results of the two second training samples and the second preset loss function conversion rule.

[0053] In this embodiment, the second preset loss function conversion rule is expressed as:

[0054]

[0055] Where L(i, j) represents the sample comparison loss value between the i-th second training sample and the j-th second training sample, k represents the k-th second training sample, and 2N represents the number of second training samples generated based on the second original image sample; S i,j represents the similarity value between the i-th second training sample and the j-th second training sample; S i,k represents the similarity value between the i-th second training sample and the k-th second training sample, where k is not equal to i.

[0056] Step S306: Based on the sample contrast loss value, obtain the contrast loss function of the embedding branch.

[0057] Fourth embodiment

[0058] Figure 4 The flowchart of the model training method of the fourth embodiment of the present disclosure is shown. This embodiment is an alternative implementation of the above step S106. As shown in the figure, this embodiment mainly includes the following steps:

[0059] Step S402: Input any two first training samples generated based on the labeled first original image sample into the embedding branch to perform contrast prediction, and obtain a first contrast loss sub-function of the embedding branch.

[0060] Specifically, the specific implementation means for obtaining the first contrast loss sub-function of the embedding branch based on the contrast prediction results of the two first training samples can refer to the various processing steps in the third embodiment above, which will not be repeated in this embodiment.

[0061] Step S404: Input any two second training samples generated based on the unlabeled second original image sample into the embedding branch to perform contrast prediction, and obtain a second contrast loss sub-function of the embedding branch.

[0062] Specifically, the specific implementation means for obtaining the second contrast loss sub-function of the embedding branch based on the contrast prediction results of the two second training samples can refer to the various processing steps in the third embodiment above, which will not be repeated in this embodiment.

[0063] Step S406: Obtain a contrast loss function of the embedding branch according to the first contrast loss sub-function and the second contrast loss sub-function.

[0064] Fifth embodiment

[0065] Figure 5 The flowchart of the model training method of the fifth embodiment of the present disclosure is shown. This embodiment is a specific implementation plan of the above step S108. As shown in the figure, this embodiment mainly includes the following steps:

[0066] Step S502: Obtain a sum loss function according to the classification loss function, the contrast loss function, and the preset function summation rule.

[0067] In this embodiment, the default function sum rule is expressed as:

[0068] L=λL class +(1-λ)L sim

[0069] Among them, L represents the sum loss function, λ is the weight parameter, and L class Represents the classification loss function of the classification branch, L sim represents the contrastive loss function of the embedding branch.

[0070] Step S504: training the target model according to the sum loss function.

[0071] In one embodiment, when the sum loss function converges to a stable value, it indicates that the training of the target model is completed.

[0072] In another embodiment, the number of training samples of the first training samples and the second training samples may be set, and when all the first training samples and the second training samples are predicted, the training of the target model is completed.

[0073] In this embodiment, when it is determined that the target model training is completed, the embedding branch can be removed, and the target model with the classification branch can be output for subsequent classification prediction reasoning.

[0074] Sixth embodiment

[0075] The sixth embodiment of the present disclosure provides a computer storage medium, in which instructions for executing the steps in the model training method described in any one of the first to fifth embodiments are stored.

[0076] Seventh embodiment

[0077] Figure 6 FIG. 6 is a schematic diagram showing the architecture of a model training device according to a seventh embodiment of the present disclosure. As shown in the figure, the model training device 600 according to the present embodiment includes: a construction module 602 and a training module 604 .

[0078] The construction module 602 is used to construct the classification branch 612 and the embedding branch 614 of the target model 610 .

[0079] The training module 604 is used to input the first training sample generated based on the labeled first original image sample into the classification branch 612 to perform classification prediction, obtain the classification loss function of the classification branch 612, and input any two second training samples generated based on the unlabeled second original image sample into the embedding branch 614 to perform comparative prediction, obtain the comparative loss function of the embedding branch 614, and train the target model 610 according to the classification loss function and the comparative loss function.

[0080] Optionally, the training module 604 is further used to perform multiple enhancement processes on the labeled first original image samples to obtain the first training samples corresponding to each enhancement process; and to perform multiple enhancement processes on the unlabeled second original image samples to obtain the second training samples corresponding to each enhancement process.

[0081] Optionally, after performing the enhancement processing on the labeled first original image samples for each time, the first training samples obtained are not completely the same, or are completely different.

[0082] Optionally, after performing the enhancement processing on the unlabeled second original image samples, the second training samples obtained are not completely the same, or are completely different.

[0083] Optionally, the training module 604 is further configured to input the first training sample generated based on the first original image sample into the classification branch 612 to perform classification prediction and obtain a category prediction value of the first training sample; and obtain the classification loss function of the classification branch 612 based on the category prediction value of the first training sample, the true category of the first training sample, and a first preset loss function conversion rule; the first preset loss function conversion rule is expressed as:

[0084]

[0085] Among them, the L class represents the classification loss function, i represents the i-th first training sample, c represents the c-th category, M represents the number of categories, and y icrepresents the true category of the i-th first training sample, wherein if the true category of the i-th first training sample is c, then y ic The value of is 1. If the true category of the i-th first training sample is not c, then y ic The value of p is 0, ic The category prediction value indicating that the i-th first training sample belongs to the c-th category.

[0086] Optionally, the training module 604 is further configured to input any two second training samples generated based on the second original image sample into the embedding branch 614 to perform comparative prediction, thereby obtaining a comparison result of the two second training samples; obtain sample comparative loss values ​​of the two second training samples based on the comparison result of the two second training samples and a second preset loss function conversion rule; and obtain the comparative loss function of the embedding branch 614 based on the sample comparative loss values; the second preset loss function conversion rule is expressed as:

[0087]

[0088] Wherein, L(i, j) represents the sample contrast loss value between the i-th second training sample and the j-th second training sample, k represents the k-th second training sample, 2N represents the number of second training samples generated based on the second original image sample; S i,j represents the similarity value between the i-th second training sample and the j-th second training sample; the S i,k represents the similarity value between the i-th second training sample and the k-th second training sample.

[0089] Optionally, the training module 604 is also used to input any two first training samples generated based on the labeled first original image samples into the embedding branch 614 to perform comparative prediction, and obtain a first comparative loss sub-function of the embedding branch 614; input any two second training samples generated based on the unlabeled second original image samples into the embedding branch 614 to perform comparative prediction, and obtain a second comparative loss sub-function of the embedding branch 614; and obtain the comparative loss function of the embedding branch 614 based on the first comparative loss sub-function and the second comparative loss sub-function.

[0090] Optionally, the training module 604 is further configured to obtain a sum loss function according to the classification loss function, the contrast loss function, and a preset function sum rule; and train the target model 610 according to the sum loss function; the preset function sum rule is expressed as:

[0091] L=λLclass +(1-λ)L sim

[0092] Wherein, L represents the sum loss function, λ is the weight parameter, and L class Represents the classification loss function, the L sim Denotes the contrast loss function.

[0093] Optionally, the training module 604 is also used to use a convolutional neural network to perform feature extraction on the first training sample to obtain the first extracted features of the first training sample, and to perform feature extraction on the two second training samples to obtain two second extracted features corresponding to the two second training samples; provide the classification branch 612 to perform classification prediction on the first training sample based on the first extracted features; and provide the embedding branch 614 to perform comparative prediction on the two second training samples based on the two second extracted features.

[0094] Optionally, the construction module 602 is further configured to remove the embedding branch 614 after the target model 610 is trained, and output the target model 610 having the classification branch 612 .

[0095] Optionally, the embedding branch 614 includes two fully connected layers.

[0096] In summary, the model training methods, devices, and computer storage media provided in the embodiments of the present disclosure design a dual-branch semi-supervised training mechanism that can simultaneously use labeled and unlabeled training data sets to perform model training tasks. This not only reduces the labeling cost of training data to reduce the model training cost, but also because unlabeled training data is easy to obtain, the amount of training data for the model can be greatly expanded, thereby ensuring the prediction effect and generalization of the model.

[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present disclosure.

Claims

1. A model training method, characterized in that: include: Construct the classification branch and embedding branch of the target model; Inputting the first training sample generated based on the first labeled original image sample into the classification branch to perform classification prediction, Obtaining a classification loss function of the classification branch; Inputting any two second training samples generated based on the unlabeled second original image sample into the embedding branch to perform contrastive prediction, thereby obtaining a contrastive loss function of the embedding branch; as well as Training the target model according to the classification loss function and the contrast loss function; Inputting any two first training samples generated based on the labeled first original image sample into the embedding branch to perform contrastive prediction, thereby obtaining a first contrastive loss sub-function of the embedding branch; Inputting any two second training samples generated based on the unlabeled second original image sample into the embedding branch to perform contrastive prediction, thereby obtaining a second contrastive loss sub-function of the embedding branch; The contrast loss function of the embedding branch is obtained according to the first contrast loss sub-function and the second contrast loss sub-function.

2. The model training method according to claim 1, characterized in that The method further comprises: Performing multiple enhancement processes on the labeled first original image samples to obtain first training samples corresponding to each of the enhancement processes; Perform multiple enhancement processes on the unlabeled second original image samples to obtain second training samples corresponding to each enhancement process.

3. The model training method according to claim 2, characterized in that After performing the enhancement processing on the first original image sample with the label, the first training samples obtained are not completely the same or are completely different; After performing the enhancement processing on the unlabeled second original image samples, the second training samples obtained are not completely the same, or are completely different.

4. The model training method according to claim 1, characterized in that Inputting the first training sample generated based on the labeled first original image sample into the classification branch to perform classification prediction, and obtaining the classification loss function of the classification branch includes: Inputting the first training sample generated based on the first original image sample into the classification branch to perform classification prediction, thereby obtaining a category prediction value of the first training sample; Obtaining the classification loss function of the classification branch according to the category prediction value of the first training sample, the true category of the first training sample, and a first preset loss function conversion rule; The first preset loss function conversion rule is expressed as: Among them, the L class represents the classification loss function, i represents the i-th first training sample, c represents the c-th category, M represents the number of categories, and y ic represents the true category of the i-th first training sample, wherein if the true category of the i-th first training sample is c, then y ic The value of is 1. If the true category of the i-th first training sample is not c, then y ic The value of p is 0, ic The category prediction value indicating that the i-th first training sample belongs to the c-th category.

5. The model training method according to claim 1, characterized in that Inputting any two second training samples generated based on the unlabeled second original image sample into the embedding branch to perform contrastive prediction, and obtaining the contrastive loss function of the embedding branch includes: Inputting any two second training samples generated based on the second original image sample into the embedding branch to perform comparative prediction, thereby obtaining a comparison result of the two second training samples; Obtaining sample comparison loss values ​​of the two second training samples according to the comparison result of the two second training samples and a second preset loss function conversion rule; Obtaining the contrast loss function of the embedding branch based on the sample contrast loss value; The second preset loss function conversion rule is expressed as: Wherein, L(i, j) represents the sample contrast loss value between the i-th second training sample and the j-th second training sample, k represents the k-th second training sample, 2N represents the number of second training samples generated based on the second original image sample; S i,j represents the similarity value between the i-th second training sample and the j-th second training sample; the S i,k represents the similarity value between the i-th second training sample and the k-th second training sample.

6. The model training method according to claim 1, characterized in that The training of the target model according to the classification loss function and the contrast loss function includes: Obtaining a sum loss function according to the classification loss function, the contrast loss function, and a preset function sum rule; Training the target model according to the sum loss function; The preset function sum rule is expressed as: L=λL class +(1-λ)L sim Wherein, L represents the sum loss function, λ is the weight parameter, and L class Represents the classification loss function, the L sim Denotes the contrast loss function.

7. The model training method according to claim 1, characterized in that The method further comprises: Performing feature extraction on the first training sample using a convolutional neural network to obtain a first extracted feature of the first training sample, and performing feature extraction on the two second training samples to obtain two second extracted features corresponding to the two second training samples; Providing the classification branch to perform classification prediction on the first training sample based on the first extracted feature; The embedding branch is provided to perform comparative prediction on the two second training samples based on the two second extracted features.

8. The model training method according to claim 1, characterized in that The method further comprises: After the target model training is completed, the embedding branch is removed, and the target model with the classification branch is output.

9. The model training method according to claim 1, characterized in that The embedding branch includes two fully connected layers.

10. A computer storage medium, characterized in that The computer storage medium stores instructions for executing each step in the model training method described in any one of claims 1 to 9.

11. A model training device, characterized in that: include: Construction module, used to build the classification branch and embedding branch of the target model; a training module, configured to input a first training sample generated based on a labeled first original image sample into the classification branch to perform classification prediction, thereby obtaining a classification loss function of the classification branch; and input any two second training samples generated based on an unlabeled second original image sample into the embedding branch to perform contrastive prediction, thereby obtaining a contrastive loss function of the embedding branch; and train the target model based on the classification loss function and the contrastive loss function, wherein any two first training samples generated based on the labeled first original image sample are input into the embedding branch to perform contrastive prediction, thereby obtaining a first contrastive loss sub-function of the embedding branch; Any two second training samples generated based on the unlabeled second original image samples are input into the embedding branch to perform contrast prediction to obtain a second contrast loss sub-function of the embedding branch; and the contrast loss function of the embedding branch is obtained according to the first contrast loss sub-function and the second contrast loss sub-function.

Citation Information

Patent Citations

  • Image segmentation model training method and device, computer equipment and storage medium

    CN113112509A