Semi-supervised model training method, image recognition method and device
By dividing the model into class groups, identifying the target group of unlabeled samples, and adjusting the loss weights, the model training process is optimized, solving the problem of low information classification accuracy of semi-supervised models in the field of image recognition, and achieving higher model precision and classification accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- MASHANG CONSUMER FINANCE CO LTD
- Filing Date
- 2022-03-31
- Publication Date
- 2026-04-17
AI Technical Summary
Existing semi-supervised models have low information classification accuracy in applications such as image recognition, mainly because the judgment conditions for unlabeled samples are simple and the loss weight coefficients are the same, resulting in low model training accuracy.
By dividing the samples into categories, the target group for unlabeled samples is determined. Based on the predicted probability subset of the group, the samples to retain pseudo-labels are determined and the loss weight coefficients are adjusted. Priority is given to learning the class distinction between groups, while in the later stages of training, the focus is on class distinction within groups.
This improved the accuracy of model parameters in semi-supervised models and enhanced the accuracy of information classification.
Smart Images

Figure CN116935146B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image recognition technology, and in particular to a training method for a semi-supervised model, an image recognition method, and an apparatus. Background Technology
[0002] With the rapid development of artificial intelligence technology, neural network models have also emerged. By iteratively training the model parameters based on a large amount of historical sample data, the neural network model can learn patterns from a large amount of historical sample data, thereby enabling intelligent recognition of new samples or prediction of the future.
[0003] However, due to the difficulty in obtaining a large amount of labeled sample data for certain specific application scenarios, and considering that the training process of semi-supervised models may be completed by using a small number of labeled samples and a large number of unlabeled samples, the application of semi-supervised models is becoming more and more widespread. However, for application fields such as image recognition and text recognition, there is a problem of low information classification accuracy when using existing semi-supervised models for classification. Summary of the Invention
[0004] The purpose of this application is to provide a training method, image recognition method, and apparatus for a semi-supervised model. By first determining the target group to which the target category of the unlabeled sample belongs, the target group corresponding to the unlabeled sample can be regarded as a whole. Based on the prediction probability subset corresponding to the target group, the loss weight coefficients of the unlabeled target samples that need to retain pseudo-labels and the unlabeled target samples with poor prediction performance between groups are determined. This allows for the targeted determination of the first loss function for each unlabeled target sample. It enables the prioritization of learning the distinction between categories between groups in the early stage of model training, and the focus on learning the distinction between categories within groups in the later stage of model training. The model parameters of the semi-supervised model trained in this way have higher accuracy, thereby improving the information classification accuracy when the model is used in subsequent applications.
[0005] To achieve the above technical solution, the embodiments of this application are implemented as follows:
[0006] Firstly, embodiments of this application provide a method for training a semi-supervised model, the method comprising:
[0007] Unlabeled samples from a preset training sample set are input into a semi-supervised model to be trained to obtain a set of predicted probabilities for each unlabeled sample; wherein, the set of predicted probabilities includes: a first predicted probability for each candidate category of the unlabeled sample after weak enhancement, and a second predicted probability for each candidate category of the unlabeled sample after strong enhancement.
[0008] For each unlabeled sample, in a pre-divided plurality of category groups, based on the first predicted probability of the unlabeled sample, the target group to which the target category of the unlabeled sample belongs is determined; wherein, the target category is the candidate category corresponding to the maximum value of the first predicted probability;
[0009] Based on the predicted probability subsets corresponding to each of the unlabeled samples, a plurality of target unlabeled samples that are determined to retain pseudo-labels and a first loss function corresponding to each of the target unlabeled samples are determined; wherein, the predicted probability subsets include: the first predicted probability and the second predicted probability under each candidate category in the target group corresponding to the unlabeled sample, a plurality of reference terms in the determination condition of the target unlabeled sample are related to a plurality of the first predicted probabilities corresponding to the target group, the loss weight coefficient corresponding to the target unlabeled sample is related to a plurality of the second predicted probabilities corresponding to the target group, and the first loss function is related to the loss weight coefficient;
[0010] Based on the first loss function of each of the target unlabeled samples, the model parameters of the semi-supervised model are iteratively trained to obtain the trained semi-supervised model.
[0011] Secondly, embodiments of this application provide an image recognition method, the method comprising:
[0012] Acquire the target image data to be identified;
[0013] The target image data is input into the trained semi-supervised model to obtain the image classification result of the target image data; wherein, the image classification result includes: the third predicted probability of the target image data under each candidate category, and the semi-supervised model is trained by the training method of the semi-supervised model described in any of the first aspects above.
[0014] Thirdly, embodiments of this application provide a training apparatus for a semi-supervised model, the apparatus comprising:
[0015] The first prediction module is configured to input unlabeled samples from a preset training sample set into a semi-supervised model to be trained, and obtain a set of predicted probabilities for each unlabeled sample; wherein, the set of predicted probabilities includes: a first predicted probability for each candidate category of the unlabeled sample after weak enhancement, and a second predicted probability for each candidate category of the unlabeled sample after strong enhancement.
[0016] The target group determination module is configured to, for each unlabeled sample, determine the target group to which the target category of the unlabeled sample belongs based on the first predicted probability of the unlabeled sample among a plurality of pre-divided category groups; wherein the target category is the candidate category corresponding to the maximum value of the first predicted probability;
[0017] The loss function determination module is configured to determine, based on a subset of predicted probabilities corresponding to each of the unlabeled samples, a plurality of target unlabeled samples that are determined to retain pseudo-labels and a first loss function corresponding to each of the target unlabeled samples; wherein, the subset of predicted probabilities includes: the first predicted probability and the second predicted probability under each candidate category in the target group corresponding to the unlabeled sample, a plurality of reference terms in the determination condition of the target unlabeled sample are related to a plurality of the first predicted probabilities corresponding to the target group, the loss weight coefficient corresponding to the target unlabeled sample is related to a plurality of the second predicted probabilities corresponding to the target group, and the first loss function is related to the loss weight coefficient;
[0018] The model training module is configured to iteratively train the model parameters of the semi-supervised model based on the first loss function of each of the target unlabeled samples, so as to obtain the trained semi-supervised model.
[0019] Fourthly, an image recognition device is provided in the embodiments of this application, the device comprising:
[0020] The image acquisition module is configured to acquire target image data to be identified.
[0021] An image recognition module is configured to input the target image data into the trained semi-supervised model to obtain an image classification result of the target image data; wherein the image classification result includes: the third predicted probability of the target image data under each candidate category, and the semi-supervised model is trained by the training method of the semi-supervised model described in any of the first aspects above.
[0022] Fifthly, an embodiment of this application provides a computer device, the device comprising:
[0023] A processor; and a memory arranged to store computer-executable instructions configured to be executed by the processor, the executable instructions including steps for performing the method as described in the first aspect.
[0024] In a sixth aspect, embodiments of this application provide a storage medium for storing computer-executable instructions that cause a computer to perform the steps described in the first aspect.
[0025] As can be seen, in this embodiment, unlabeled samples from a preset training sample set are input into the semi-supervised model to be trained, resulting in a set of predicted probabilities for each unlabeled sample. This set of predicted probabilities includes: a first predicted probability for each candidate category of the weakly enhanced unlabeled sample, and a second predicted probability for each candidate category of the strongly enhanced unlabeled sample. Then, for each unlabeled sample, based on the first predicted probability of the unlabeled sample within a pre-divided group of categories, the target group of the unlabeled sample is determined. Furthermore, based on the subset of predicted probabilities corresponding to the unlabeled sample, the target unlabeled sample that is judged to retain a pseudo-label and the first loss function of the target unlabeled sample are determined. This subset of predicted probabilities includes: the first and second predicted probabilities for each candidate category within the target group corresponding to the unlabeled sample. Finally, based on the first loss function corresponding to each target unlabeled sample, the model parameters of the semi-supervised model are iteratively trained to obtain the trained semi-supervised model. In other words, by first training all candidate categories based on the first predicted probability... The model determines the target category of unlabeled samples based on the probability of the unlabeled samples. This allows the model to identify the target group of the target category among multiple category groups. The target group of unlabeled samples is then treated as a whole, and the first loss function for unlabeled samples is determined based on the subset of predicted probabilities of the target group. Specifically, on the one hand, multiple reference terms in the determination criteria for unlabeled samples are related to multiple first predicted probabilities of the target group. That is, when determining whether to retain pseudo-labels of unlabeled samples based on the weakly enhanced output results of the samples (i.e., the first predicted probabilities of unlabeled samples under each candidate category in the target group), it considers not only the first predicted probability of the sample under the target category but also the first predicted probability of the sample under the non-target category in the target group. This allows samples with a relatively large sum of probabilities under all candidate categories in the target group to be retained and participate in the model loss calculation (i.e., samples with poor class distinction within the group are also retained). This achieves the goal of not focusing too much on class distinction within the group in the early stage of model training, but rather focusing on class distinction between groups.On the other hand, if the sum of the second predicted probabilities of the target unlabeled sample under each candidate category in the target group is relatively small, it indicates that the sum of the second predicted probabilities under other groups is relatively large. This means the semi-supervised model performs poorly in distinguishing between categories in the target unlabeled sample. Therefore, by associating the loss weight coefficient corresponding to the target unlabeled sample with multiple second predicted probabilities corresponding to the target group, the loss weight coefficient of the target unlabeled sample with poor inter-group category distinction can be increased. That is, based on the sample enhancement output (i.e., the second predicted probability of the unlabeled sample under each candidate category in the target group), different loss weight coefficients are set for the target unlabeled sample (i.e., focusing on learning the target unlabeled sample with poor inter-group category distinction), so as to prioritize learning samples with poor inter-group category distinction in the early stages of model training. In other words, both of these aspects can achieve priority learning of inter-group category distinction in the early stages of model training, and then focus on learning intra-group category distinction in the later stages of model training. This results in higher accuracy of the semi-supervised model parameters, thereby improving the information classification accuracy when the model is used subsequently. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in one or more of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 A schematic diagram of the first process for training a semi-supervised model provided in an embodiment of this application;
[0028] Figure 2 A schematic diagram of a second process for training a semi-supervised model provided in an embodiment of this application;
[0029] Figure 3 A schematic diagram of the third process for training a semi-supervised model provided in the embodiments of this application;
[0030] Figure 4 A schematic diagram illustrating the implementation principle of target group partitioning in the training method of the semi-supervised model provided in this application embodiment;
[0031] Figure 5a A schematic diagram of the initial semantic hierarchy structure in the training method of the semi-supervised model provided in the embodiments of this application;
[0032] Figure 5b A schematic diagram of the target semantic hierarchy in the training method of the semi-supervised model provided in the embodiments of this application;
[0033] Figure 6 A schematic diagram illustrating the implementation principle of the specific model training process in the training method of the semi-supervised model provided in the embodiments of this application;
[0034] Figure 7 A schematic flowchart illustrating the image recognition method provided in this application embodiment;
[0035] Figure 8 A schematic diagram of the module composition of a training device for a semi-supervised model provided in an embodiment of this application;
[0036] Figure 9 A schematic diagram of the structure of the device for semi-supervised model training provided in the embodiments of this application. Detailed Implementation
[0037] To enable those skilled in the art to better understand the technical solutions in one or more of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of one or more of this application, and not all embodiments. Based on the embodiments of one or more of this application, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of this application.
[0038] It should be noted that, unless otherwise specified, one or more embodiments and features described in this application can be combined with each other. The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0039] This application provides one or more embodiments of a semi-supervised model training method, image recognition method, and apparatus. The main inventive concept of this application is as follows: Considering that in the training process of a semi-supervised model, only unlabeled samples that meet the preset criteria for retaining pseudo-labels will participate in loss calculation and be substantially learned by the model, if the criterion is that the first predicted probability of an unlabeled sample in the target category is not less than a first preset threshold, then only unlabeled samples with a relatively high first predicted probability in a certain candidate category will be judged as samples that need to retain pseudo-labels and retained, and only then will loss calculation be performed. That is, the entire model training process focuses on the discrimination effect between the smallest candidate categories. Furthermore, in the process of calculating the loss value, the loss weight coefficient for each target unlabeled sample is the same, meaning that when adjusting model parameters based on the loss value... Treating all unlabeled target samples equally leads to low precision in the parameters of the trained semi-supervised model, resulting in low accuracy in information classification during subsequent model use. Therefore, this technical solution addresses this issue by introducing category grouping. It treats the target groups corresponding to unlabeled samples as a whole, and based on the predicted probability subsets corresponding to the target groups, determines the loss weight coefficients for unlabeled target samples that need to retain pseudo-labels and increases the loss weight coefficients for unlabeled target samples with poor prediction performance between groups. This allows for the targeted determination of the first loss function for each unlabeled target sample, enabling priority learning of inter-group category distinctions in the early stages of model training, and then focusing on learning intra-group category distinctions in the later stages. This results in higher precision in the parameters of the trained semi-supervised model, thereby improving the accuracy of information classification during subsequent model use.
[0040] Specifically, Figure 1 This is a schematic diagram of a first flowchart illustrating a training method for a semi-supervised model provided in one or more embodiments of this application. Figure 1 The methods in the code can be executed by the server, such as... Figure 1 As shown, the method includes at least the following steps:
[0041] S102, input the unlabeled samples from the preset training sample set into the semi-supervised model to be trained to obtain the prediction probability set of each unlabeled sample; wherein, the prediction probability set includes: the first prediction probability of the weakly enhanced unlabeled sample under each candidate category, and the second prediction probability of the strongly enhanced unlabeled sample under each candidate category.
[0042] Specifically, for an object recognition task, a corresponding preset training sample set is obtained. The preset training sample set includes a first number of labeled samples and a second number of unlabeled samples, with the second number being much larger than the first number. For example, if the object recognition task is an image recognition task, a first number of labeled image samples and a second number of unlabeled image samples are obtained. The labeled image samples include the sample image and the true category label of the sample image. The true category label is one of the candidate categories among multiple candidate categories associated with the image recognition task. As another example, if the object recognition task is a text recognition task, a first number of labeled text samples and a second number of unlabeled text samples are obtained. The labeled text samples include the sample text and the true category label of the sample text. The true category label is one of the candidate categories among multiple candidate categories associated with the text classification task.
[0043] Then, both labeled and unlabeled samples are input into the semi-supervised model to be trained, obtaining the prediction output of the semi-supervised model. This prediction output includes the prediction probability set corresponding to labeled samples and the prediction probability set corresponding to unlabeled samples. During the training process of the semi-supervised model, for unlabeled samples, weak augmentation is performed, outputting the first prediction probability of the weakly augmented unlabeled sample under each candidate category; and strong augmentation is performed, outputting the second prediction probability of the strongly augmented unlabeled sample under each candidate category. Then, a second loss function is determined based on the prediction probability set corresponding to labeled samples, and a first loss function is determined based on the prediction probability set corresponding to unlabeled samples. A semi-supervised loss function is determined based on the first and second loss functions, and then the model parameters are iteratively trained based on the semi-supervised loss function to obtain the trained semi-supervised model.
[0044] The process of determining the second loss function based on the predicted probability set corresponding to labeled samples can be found in the existing cross-entropy loss function for labeled samples. The process of iteratively training the model parameters based on the semi-supervised loss function to obtain the trained semi-supervised model can be found in the existing process of using gradient descent to backpropagate and fine-tune the model parameters, which will not be repeated here. The following details the specific implementation process of determining the first loss function based on the predicted probability set corresponding to unlabeled samples.
[0045] S104, for each unlabeled sample, in the pre-divided multiple category groups, based on the first predicted probability of the unlabeled sample, determine the target group to which the target category of the unlabeled sample belongs; wherein, the target category is the candidate category corresponding to the maximum value of the first predicted probability;
[0046] Specifically, before model training, the multiple candidate categories that the target recognition task needs to distinguish are divided into multiple category groups according to a preset grouping method. This can be done by calculating the semantic similarity between multiple candidate categories and then grouping them based on the semantic similarity, or by grouping them based on the semantic hierarchy between multiple candidate categories.
[0047] Then, during model training, based on the first predicted probability of unlabeled samples under all candidate categories, the candidate category with the highest first predicted probability is determined and designated as the target category; then the category group containing the target category is designated as the target group.
[0048] For example, multiple candidate categories associated with an object recognition task include:
[0049] ;
[0050] Correspondingly, the multiple candidate categories are divided into groups, resulting in n category groups, which include:
[0051] , … … ;
[0052] Correspondingly, if the target category is Then the target group to which the target category belongs is .
[0053] Next, after determining the target group corresponding to the unlabeled sample, the target group is treated as a whole, and the target unlabeled sample that is judged to retain the pseudo-label and the first loss function corresponding to the target unlabeled sample are determined through the following step S106.
[0054] S106, Based on the predicted probability subsets corresponding to each unlabeled sample, determine multiple target unlabeled samples that are judged to retain pseudo-labels and the first loss function corresponding to each target unlabeled sample; wherein, the predicted probability subset includes: the first and second predicted probabilities under each candidate category in the target group corresponding to the unlabeled sample, multiple reference terms in the judgment condition of the target unlabeled sample are related to multiple first predicted probabilities corresponding to the target group, the loss weight coefficient corresponding to the target unlabeled sample is related to multiple second predicted probabilities corresponding to the target group, and the first loss function is related to the loss weight coefficient;
[0055] Specifically, in determining the corresponding first loss function for each unlabeled sample, the target group corresponding to the unlabeled sample is regarded as a whole. Based on the multiple first predicted probabilities corresponding to the target group (i.e., multiple first predicted probabilities in the subset of predicted probabilities corresponding to the unlabeled sample), the target unlabeled sample that is determined to retain the pseudo-label is determined. That is, as long as the sum of the first probabilities obtained based on the multiple first predicted probabilities of the unlabeled sample under the target group meets the preset judgment condition, the unlabeled sample is determined to be the target unlabeled sample that retains the pseudo-label. In other words, not only are samples with a relatively high first predicted probability under the target category and a relatively low first predicted probability under other candidate categories (i.e., samples with good class distinction within the group) retained and used in the calculation of model loss, but also samples with a relatively low first predicted probability under the target category but a relatively high first predicted probability under non-target categories in the target group (i.e., samples with poor class distinction within the group) are retained and used in the calculation of model loss. This allows the model to focus on class distinction between groups rather than class distinction within groups in the early stage of model training.
[0056] Furthermore, based on multiple second predicted probabilities corresponding to the target group (i.e., multiple second predicted probabilities in the subset of predicted probabilities corresponding to unlabeled samples), the loss weight coefficients corresponding to each target unlabeled sample are determined. That is, among multiple target unlabeled samples, key learning samples (i.e., one target unlabeled sample assigned to the key learning sample set) are selected. These key learning samples are those whose sum of second probabilities obtained from multiple second predicted probabilities of the target unlabeled sample under the target group meets the preset selection conditions (i.e., samples with poor class distinction between groups are prioritized for learning). The loss weight coefficient of these key learning samples is increased. In other words, the loss weight coefficient of the key learning samples selected from multiple target unlabeled samples is higher than that of the non-key learning samples (i.e., one target unlabeled sample assigned to the non-key learning sample set), so as to encourage the model to focus on learning these unlabeled samples. This can achieve the goal of prioritizing the learning of samples with poor class distinction between groups in the early stage of model training.
[0057] In specific implementation, the first reference term in the determination condition of the target unlabeled sample is related to the first predicted probability of the target category, and the second reference term is related to the sum of the weighted probability values of the first predicted probabilities of non-target categories in the target group. The weighted probability value is the product of the sum of the first predicted probabilities of non-target categories and the preset adjustment factor. The preset adjustment factor of the first predicted probability of non-target categories in the target group corresponding to the unlabeled sample is negatively correlated with the current training round number, that is, the preset adjustment factor decreases as the current training round number increases. Furthermore, if the loss weight coefficient of the non-key learning samples in the multiple target unlabeled samples is regarded as a constant, then the loss weight coefficient of the key learning samples in the multiple target unlabeled samples is negatively correlated with the current training round number, that is, the loss weight coefficient of the key learning samples decreases as the current training round number increases.
[0058] Specifically, during model training, whether determining the target unlabeled samples to retain pseudo-labels or determining the loss weight coefficients corresponding to each target unlabeled sample, it is necessary to know the target group to which the target unlabeled sample belongs. Therefore, if the preset network layers in the semi-supervised model can be used to determine the target group to which the target unlabeled sample belongs based on multiple preset category groups, the first attribute information of the pre-divided multiple category groups is used as the input information of the semi-supervised model. The first attribute information includes the correspondence between the name identifiers of all category groups and the name identifiers of at least one candidate category contained in the corresponding category group. If the preset processing module outside the semi-supervised model determines the target group to which the target unlabeled sample belongs based on multiple preset category groups, the second attribute information of the target group is used as the input information of the semi-supervised model. The second attribute information includes the correspondence between the name identifiers of the target category group and the name identifiers of each candidate category contained in the target category group. In other words, during model training, the information input to the semi-supervised model includes not only unlabeled samples but also group attribute information (such as the first attribute information or the second attribute information mentioned above).
[0059] Specifically, it is still based on the target category. The target group is For example, the predicted probability subset corresponding to the target group includes:
[0060] (i.e., the first predicted probability of an unlabeled sample in each candidate category within the target group)
[0061] as well as (i.e., the second predicted probability of an unlabeled sample in each candidate category within the target group).
[0062] in, Indicates unlabeled samples In non-target categories The first predicted probability, Indicates unlabeled samples In target category The first predicted probability, Indicates unlabeled samples In non-target categories The second predicted probability, Indicates unlabeled samples In target category The second predicted probability.
[0063] Specifically, based on the target group to which the unlabeled sample belongs, multiple first predicted probabilities are used. The determination of unlabeled target samples that are identified as retaining false labels is based on multiple reference items in the criteria for determining unlabeled target samples. Related;
[0064] Based on multiple second prediction probabilities corresponding to the target group to which the target unlabeled sample belongs. Determine the loss weight coefficients corresponding to each target unlabeled sample, that is, the loss weight coefficients corresponding to the target unlabeled samples and... Related.
[0065] S108. Based on the first loss function corresponding to each target unlabeled sample, the model parameters of the above semi-supervised model are iteratively trained to obtain the trained semi-supervised model.
[0066] Specifically, based on the first loss function corresponding to each unlabeled target sample, a first total loss function is obtained. This first total loss function can be obtained by summing the first loss functions corresponding to multiple unlabeled target samples, i.e., by weighted summing the preset unlabeled cross-entropy loss functions corresponding to multiple unlabeled samples. The weight coefficients of the preset unlabeled cross-entropy loss functions are the loss weight coefficients corresponding to each unlabeled target sample. A second total loss function is obtained based on the second loss function corresponding to each labeled sample. This second total loss function can be obtained by summing the second loss functions corresponding to multiple labeled samples, i.e., by summing the preset labeled cross-entropy loss functions corresponding to multiple labeled samples. Then, based on the first and second total loss functions, a semi-supervised loss function is determined. Based on the first predicted probability distribution and true class label corresponding to labeled samples, the second predicted probability distribution and pseudo-label (i.e., target class) corresponding to unlabeled samples, and the semi-supervised loss function, a semi-supervised loss value is determined. Finally, using the stochastic gradient descent method, based on the semi-supervised loss value, the model parameters of the semi-supervised model to be trained are iteratively trained to obtain the trained semi-supervised model.
[0067] The process of iteratively training the model parameters based on the semi-supervised loss function to obtain the trained semi-supervised model can be found in the existing process of using gradient descent to backpropagate and fine-tune the model parameters, which will not be elaborated here.
[0068] In this embodiment, the target category corresponding to the unlabeled sample is first determined based on the first predicted probability among all candidate categories to identify the target group containing the target category among multiple category groups. Then, the target group corresponding to the unlabeled sample is treated as a whole, and the first loss function corresponding to the unlabeled sample is determined based on the subset of predicted probabilities corresponding to the target group. Specifically, on the one hand, multiple reference terms in the determination condition of the target unlabeled sample are related to multiple first predicted probabilities corresponding to the target group. That is, when determining whether to retain the pseudo-label of the unlabeled sample based on the weak enhancement output result of the sample (i.e., the first predicted probability of the unlabeled sample under each candidate category in the target group) (i.e., only samples determined to retain pseudo-labels will participate in the model loss calculation), not only the first predicted probability of the sample under the target category is considered, but also the first predicted probability of the sample under non-target categories in the target group is considered. This can retain samples with a relatively large sum of probabilities under all candidate categories in the target group and participate in the model loss calculation (i.e., samples with poor class distinction within the group are also retained), so as to achieve the goal of not focusing too much on the distinction between classes within the group in the early stage of model training, but focusing on the distinction between classes between groups. On the other hand, if the sum of the second predicted probabilities of the target unlabeled sample under each candidate category in the target group is relatively small, it indicates that the sum of the second predicted probabilities under other groups is relatively large. The semi-supervised model is not good at distinguishing between the categories of the target unlabeled sample in the inter-group classification. Therefore, by associating the loss weight coefficient corresponding to the target unlabeled sample with multiple second predicted probabilities corresponding to the target group, the loss weight coefficient of the target unlabeled sample with poor inter-group classification can be increased. That is, at the same time, based on the sample enhancement output (i.e., the second predicted probability of the unlabeled sample under each candidate category in the target group), different loss weight coefficients are set for the target unlabeled sample (i.e., focusing on learning the target unlabeled sample with poor inter-group classification), so as to focus on learning the sample with poor inter-group classification in the early stage of model training. In other words, through these two aspects, it is possible to prioritize learning the inter-group classification in the early stage of model training, and then focus on learning the intra-group classification in the later stage of model training. The model parameters of the semi-supervised model trained in this way are more accurate, thereby improving the information classification accuracy when the model is used in the future.
[0069] Among them, the multiple reference items in the above-mentioned determination criteria for unlabeled target samples may include: a first reference item related to the first predicted probability under the target category, and a second reference item related to the first predicted probability under the non-target category in the target group.
[0070] Specifically, as the model parameters are iteratively trained, i.e., as the number of training epochs increases, the focus shifts from distinguishing between categories in the early stages of training to distinguishing within categories in the later stages. Therefore, if the current training epoch is less than or equal to the target training epoch, the second reference term is positively correlated with the preset adjustment factor, and the preset adjustment factor is negatively correlated with the current training epoch. If the current training epoch is greater than the target training epoch, the second reference term is zero. The target training epoch is less than the total number of training epochs. As the number of training epochs increases, the preset adjustment factor gradually decreases, causing the reference proportion of the second reference term to gradually decrease. This results in the first reference term (i.e., the first predicted probability under the target category) being the primary factor in determining whether an unlabeled sample is classified as a sample with a retained pseudo-label in the later stages of training. After a certain number of training epochs are reached, the second reference term becomes zero.
[0071] In practical implementation, the first reference item is The second reference term and the preset adjustment factor, and at least one first predicted probability in the non-target category of the target group. Specifically, the second reference term can be the product of a predicted probability summation term and a preset adjustment factor, wherein the predicted probability summation term is the sum of at least one first predicted probability under the non-target category in the target group. .
[0072] The aforementioned loss weight coefficients are related to the sample group to which the target unlabeled sample belongs. Different sample groups correspond to their own loss weight coefficients. If the number of training rounds in the current round is less than or equal to the target number of training rounds, then different sample groups correspond to different loss weight coefficients. If the number of training rounds in the current round is greater than the target number of training rounds, then different sample groups can correspond to the same loss weight coefficient, that is, the loss weight coefficients of each target unlabeled sample are the same. The sample grouping is obtained by grouping the target unlabeled samples based on multiple second prediction probabilities corresponding to the target group. The aforementioned first loss function is obtained based on the loss weight coefficients corresponding to the target unlabeled samples and the preset unlabeled cross-entropy loss function.
[0073] In practice, if the number of training rounds in the current round is greater than the target number of training rounds, the loss weight coefficients of the unlabeled samples of each target are the same, and the unlabeled samples of each target can continue to be grouped. However, in order to further improve the model training efficiency and reduce the amount of information processing during the model training process, if the number of training rounds in the current round is greater than the target number of training rounds, the sample grouping can be stopped, that is, the above-mentioned key learning sample selection process can be stopped. In other words, if the number of training rounds in the current round is less than or equal to the target number of training rounds, the loss weight coefficients corresponding to the unlabeled samples of the target are related to the multiple second prediction probabilities corresponding to the target group. If the number of training rounds in the current round is greater than the target number of training rounds, the loss weight coefficients corresponding to the unlabeled samples of the target are the same, that is, the loss weight coefficients corresponding to the unlabeled samples of the target are not related to the multiple second prediction probabilities corresponding to the target group.
[0074] In practice, sample grouping is based on the sum of multiple second predicted probabilities corresponding to the target group. This was obtained by grouping the unlabeled target samples. express Belongs to the target group Each candidate category;
[0075] Specifically, the above sample grouping can include: a set of key learning samples and a set of non-key learning samples, wherein, Unlabeled target samples that are less than or equal to a certain preset threshold can be grouped into a key learning sample set. Unlabeled target samples exceeding a certain preset threshold can be grouped into a non-key training sample set. Specifically, if the current training round is less than or equal to the target training round, the loss weight coefficient for each unlabeled target sample in the key training sample set is greater than the loss weight coefficient for each unlabeled target sample in the non-key training sample set. If the current training round is greater than the target training round, the loss weight coefficient for each unlabeled target sample in the key training sample set is equal to the loss weight coefficient for each unlabeled target sample in the non-key training sample set; that is, the loss weight coefficients for all unlabeled target samples are the same.
[0076] Furthermore, as the model parameters are iteratively trained—that is, as the number of training epochs increases—it is necessary to gradually shift from focusing on class differentiation between groups in the early stages of model training to focusing on class differentiation within groups in the later stages. Therefore, it is necessary to reduce the difference between the loss weight coefficients corresponding to the key learning sample set and the loss weight coefficients corresponding to the non-key learning sample set. In other words, the increase in the loss weight coefficients for the target unlabeled samples in the key learning sample set should be gradually reduced. Therefore, the loss weight coefficients corresponding to the non-key learning sample set can be preset fixed values. And if the number of training epochs in the current round is less than or equal to the target number of training epochs, then the loss weight coefficients for the key learning sample set... The corresponding loss weight coefficient is negatively correlated with the number of training epochs. That is, as the number of training epochs increases, the loss weight coefficient corresponding to the key learning sample set gradually decreases, so that the difference between the loss weight coefficient corresponding to the target unlabeled sample in the key learning sample set and the loss weight coefficient corresponding to the target unlabeled sample in the non-key learning sample set gradually decreases. If the number of training epochs is greater than the target number of training epochs, the loss weight coefficient corresponding to the key learning sample set is equal to the above-mentioned preset fixed value. In other words, after the current training epoch reaches a certain number of model training epochs, the loss weight coefficient of each target unlabeled sample is the preset fixed value, that is, the loss weight coefficient of each target unlabeled sample is the same.
[0077] Specifically, regarding the process of determining the first loss function, S106 above, based on the predicted probability subsets corresponding to each unlabeled sample, determines the multiple target unlabeled samples that are judged to retain false labels and the first loss function corresponding to each target unlabeled sample, which specifically includes:
[0078] Step 1: Based on the multiple first prediction probabilities in the predicted probability subset corresponding to each unlabeled sample, determine the multiple target unlabeled samples that are judged to retain pseudo-labels.
[0079] Specifically, the multiple first predicted probabilities in the predicted probability subset corresponding to each unlabeled sample include: the first predicted probability of the unlabeled sample under the target category, and the first predicted probability under each non-target category in the target group. That is, based on the first predicted probability under the target category and the first predicted probability under the non-target category in the target group, it is jointly determined whether the unlabeled sample is judged as a target unlabeled sample with retained pseudo-label. If so, the unlabeled sample participates in the calculation of model loss; otherwise, the unlabeled sample will not participate in the calculation of model loss.
[0080] In practical implementation, step one above, identifying multiple unlabeled target samples that are determined to retain false labels, may specifically include:
[0081] For each unlabeled sample, a first probability sum is determined based on multiple first prediction probabilities in the predicted probability subset corresponding to the unlabeled sample; wherein, the first probability sum is the sum of the weighted probability values of the first prediction probability of the target category and the first prediction probability of the non-target category in the target group, and the weighted probability value is the product of the sum of the first prediction probabilities of the non-target category in the target group and a preset adjustment factor.
[0082] If the sum of the first probabilities is greater than or equal to the first preset threshold, then the unlabeled sample is determined to be the target unlabeled sample.
[0083] If the sum of the first probabilities is less than the first preset threshold, then the unlabeled sample is determined to be a non-target unlabeled sample and will not be included in the calculation of the model loss.
[0084] For example, the multiple first predicted probabilities in the subset of predicted probabilities corresponding to unlabeled samples, i.e., the multiple first predicted probabilities corresponding to the target group, are:
[0085] ;
[0086] Correspondingly, the criteria for retaining pseudo-labeled samples (i.e., the criteria for retaining unlabeled target samples) can be:
[0087] ,
[0088] in, Indicates unlabeled samples In target category The first predicted probability, This indicates the preset adjustment factor. express Belongs to the target group Except for target categories Other candidate categories (i.e., non-target categories), i.e.
[0089] ;
[0090] This represents the sum of the first probabilities mentioned above. This represents the weighted probability value mentioned above. This represents the probability threshold used to constrain whether to retain pseudo-labels, i.e., the first preset threshold.
[0091] It should be noted that different preset adjustment factors can be set for the first predicted probabilities of multiple non-target categories in the target group, or the same preset adjustment factor can be set. The specific setting can be adaptively adjusted according to actual needs. Considering that as the number of training rounds increases, reducing the preset adjustment factor can gradually make the model focus on the distinction of categories within the group in the later stages of training, in order to simplify the formula, the above judgment condition is illustrated by setting the same preset adjustment factor for the first predicted probabilities of multiple non-target categories in the target group. However, the formula of the judgment condition shown above does not limit the scope of protection of this application. That is, as long as the first predicted probabilities of each candidate category in the target group are considered in the process of judging the samples that retain pseudo-labels, they are all within the scope of protection of this application.
[0092] Step 2: Based on the multiple second prediction probabilities in the predicted probability subset corresponding to each target unlabeled sample, determine the key learning sample set and non-key learning sample set among the multiple target unlabeled samples.
[0093] Step 3: Determine the first value as the loss weight coefficient of each target unlabeled sample in the above-mentioned key learning sample set, and determine the second value as the loss weight coefficient of each target unlabeled sample in the above-mentioned non-key learning sample set; wherein, if the number of training rounds in this round is less than or equal to the target number of training rounds, then the first value is greater than the second value, and the target number of training rounds is less than the total number of training rounds.
[0094] Specifically, the multiple second predicted probabilities in the predicted probability subset corresponding to each unlabeled sample include: the second predicted probability of the unlabeled sample under the target category, and the second predicted probability under each non-target category in the target group. That is, since only samples determined to retain pseudo-labels will participate in the model loss calculation, for each target unlabeled sample, based on its second predicted probability under the target category and the second predicted probability under each non-target category in the target group, it is determined whether the target unlabeled sample needs to be focused on learning. If yes, it means that after strong enhancement for the target unlabeled sample, the model's effect on class differentiation between groups is not good, and the target unlabeled sample is identified as a key learning sample. If no, it means that after strong enhancement for the target unlabeled sample, the model's effect on class differentiation between groups is relatively good, and the target unlabeled sample is identified as a non-key learning sample.
[0095] Then, different loss weight coefficients were set for key learning samples and non-key learning samples, and the loss weight coefficient of key learning samples was greater than that of non-key learning samples. In other words, not all target unlabeled samples with pseudo-labels were treated equally, but the loss weight coefficient of samples with poor inter-group classification performance was increased.
[0096] In practical implementation, step two above, which involves determining the set of key learning samples and the set of non-key learning samples from multiple unlabeled target samples, may specifically include:
[0097] For each unlabeled sample, a second probability sum is determined based on multiple second prediction probabilities in the predicted probability subset corresponding to the unlabeled sample; wherein, the second probability sum is the sum of the second prediction probability of the target category and the second prediction probability of the non-target category in the target group;
[0098] If the sum of the second predicted probabilities is less than or equal to the second preset threshold, then the above target unlabeled samples will be assigned to the key learning sample set.
[0099] If the sum of the above second predicted probabilities is greater than the second preset threshold, then the above target unlabeled samples will be classified into the non-key learning sample set.
[0100] For example, the multiple second predicted probabilities in the predicted probability subset corresponding to the unlabeled sample, i.e., the multiple second predicted probabilities corresponding to the target group, are:
[0101] ;
[0102] Correspondingly, the selection criteria for key learning samples can be:
[0103] ,
[0104] in, express Belongs to the target group Each candidate category, i.e.
[0105] That is, the sum of the second probability mentioned above. This represents the probability threshold used to filter out samples that do not perform well in class differentiation between groups during the early stages of model training; it is the second preset threshold.
[0106] It should be noted that different screening weighting coefficients can be set for the second predicted probabilities of multiple candidate categories in the target group. For example, different screening weighting coefficients can be set for the second predicted probabilities of the target category and non-target category in the target group, or the same screening weighting coefficient can be set. The specific setting can be adjusted adaptively according to actual needs. In order to simplify the formula, the above screening conditions are illustrated by setting the same screening weighting coefficient for the second predicted probabilities of multiple candidate categories in the target group (i.e., setting the screening weighting coefficient to 1). However, the formula of the screening conditions shown above does not limit the scope of protection of this application. That is, as long as the second predicted probabilities of each candidate category in the target group are considered in the process of screening key learning samples, it is within the scope of protection of this application.
[0107] Step 4: Based on the aforementioned loss weight coefficients and the preset unlabeled cross-entropy loss function corresponding to each target unlabeled sample, determine the first loss function corresponding to each target unlabeled sample.
[0108] Specifically, the first loss function for the target unlabeled sample can be the product of the loss weight coefficient corresponding to the target unlabeled sample and the preset unlabeled cross-entropy loss function; for example, the preset unlabeled cross-entropy loss function can be:
[0109]
[0110] in, This indicates an indicator function, which is defined if and only if the condition within the parentheses is true. ,otherwise That is, for the target unlabeled sample, That is, it participates in the model loss calculation, for non-target unlabeled samples. That is, it does not participate in the model loss calculation. That is The default unlabeled cross-entropy loss function at that time. unlabeled samples The corresponding second prediction probability distribution, where, This indicates the unlabeled sample after strong enhancement processing. This refers to unlabeled samples after strong enhancement processing. The output predicted probability, ( ) represents calculating the first prediction probability. The location of the largest (i.e., the pseudo-label, or the target category).
[0111] Furthermore, as the model parameters are iteratively trained, i.e., as the number of training epochs increases, it is necessary to gradually shift from focusing on class differentiation between groups in the early stages of model training to focusing on class differentiation within groups in the later stages. On the one hand, it is necessary to tighten the aforementioned criteria for retaining pseudo-labeled samples, i.e., gradually reduce the involvement of the first predicted probability of non-target categories in the target group, so that in the later stages of model training, the first predicted probability under the target category mainly determines whether an unlabeled sample is judged as a sample retaining a pseudo-label. Therefore, the preset adjustment factor in the aforementioned criteria can be gradually reduced. Based on this, to ensure the smoothness of the adjustment of the preset adjustment factor, a linear decreasing adjustment method can be used to gradually reduce the preset adjustment factor. Therefore, the process of determining the preset adjustment factor used in this round of model training, before determining the sum of the first probabilities based on the multiple first prediction probabilities in the predicted probability subset corresponding to the unlabeled sample, also includes:
[0112] (1) For the first round of model training, the first preset value is determined as the preset adjustment factor used in this round of model training;
[0113] Specifically, the first preset value can be set according to actual needs. To simplify the adjustment complexity, the first preset value can be set to 1, which is the preset adjustment factor. In other words, when the first round of model training is based on unlabeled samples, the above-mentioned criterion for retaining pseudo-labeled samples can be:
[0114] ,Right now ;
[0115] In other words, for the first round of model training, based on multiple first prediction probabilities corresponding to the target group, it is determined whether to classify the unlabeled samples as target unlabeled samples with retained pseudo-labels.
[0116] (2) For non-first round model training, according to the first decreasing adjustment method, based on the number of training rounds, the target number of training rounds and the first preset value of the above semi-supervised model, the preset adjustment factor used for this round of model training is determined.
[0117] Specifically, if the preset adjustment factor corresponds to the first round of model training Therefore, in the case of non-first-round model training based on unlabeled samples, the above-mentioned criterion for retaining pseudo-labeled samples can be:
[0118] ;
[0119] In other words, for non-first-round model training, the criteria used to constrain the retention of pseudo-labeled samples are... Furthermore, as the number of training rounds of the model increases, The value of gradually decreases.
[0120] For example, the decreasing formula (1) corresponding to the first decreasing adjustment method mentioned above can be:
[0121]
[0122] in, express Take the maximum value between 0 and 0. The first item 1 in the table represents the first preset value (i.e., the preset adjustment factor used in the first round of training). ), Indicates the number of training rounds in this round. This represents the target number of training epochs. The target number of training epochs can be either the total number of training epochs minus 1, or a specified number of training epochs. The specified number of training epochs is less than the total number of training epochs. The difference between the total number of training epochs and the specified number of training epochs is the preset number of epochs P. P is greater than 2, meaning that during a certain number of epochs (not the last epoch) in the later stages of model training, the preset adjustment factor will begin to be adjusted. Setting it to 0 means that the decision criteria used in the later stages of model training, from t=T+1 to the last round, are all set to 0. .
[0123] It should be noted that the target number of training rounds... For the case where the total number of training rounds is reduced by 1, the above decreasing formula (1) can be: In other words, in the final round of model training, the preset adjustment factor is set to 0, meaning that all decision criteria used in the final round of model training are... Furthermore, the decreasing formula (1) shown above is only a relatively simple linear decreasing adjustment method. In practical applications, the preset adjustment factor can be set according to actual needs. The deceleration rate is decreasing, therefore, the above-mentioned decreasing formula (1) does not constitute a limitation on the scope of protection of this application.
[0124] Furthermore, as the model parameters are iterated and trained (i.e., as the number of training epochs increases), the focus needs to shift from distinguishing between categories in the early stages of training to distinguishing within categories in the later stages. On the other hand, it's necessary to reduce the difference in loss weight coefficients between key and non-key learning samples, i.e., gradually decreasing the increase in loss weight coefficients for key learning samples. In other words, in the later stages of training, when adjusting model parameters based on the loss value, all unlabeled samples gradually become treated equally. Therefore, by setting the loss weight coefficients for non-key learning samples to a fixed value, the loss weight coefficients for key learning samples can be gradually reduced. Therefore, to ensure the smoothness of the adjustment of the loss weight coefficients, a linear decreasing adjustment method can be adopted to gradually reduce the loss weight coefficients of the key learning samples selected in each round of model training. Therefore, the loss weight coefficients for the key learning samples used in this round of model training are determined by the value of . The determination process, in step three above, before determining the first value as the loss weight coefficient of each target unlabeled sample in the aforementioned key learning sample set, and before determining the second value as the loss weight coefficient of each target unlabeled sample in the aforementioned non-key learning sample set, further includes:
[0125] (1) For the first round of model training, the second preset value is determined to be the first value mentioned above, and the third preset value is determined to be the second value mentioned above; wherein, the third preset value is the preset fixed value mentioned above.
[0126] Specifically, both the second and third preset values can be set according to actual needs. To simplify the adjustment complexity, for the first round of model training on unlabeled samples, the second preset value can be set to 2 (i.e., the first value, focusing on learning the loss weight coefficients corresponding to the samples). The third preset value is set to 1 (i.e., the second value, the loss weight coefficient corresponding to non-key learning samples), meaning the loss weight coefficient for non-key learning samples is 1, and the loss weight coefficient for key learning samples is... ;
[0127] In other words, when the first round of model training is based on unlabeled samples, the loss weight coefficient for the key learning samples selected in the first round is set to 2, and the loss weight coefficient for the non-key learning samples in the target unlabeled samples is set to 1.
[0128] (2) For non-first round model training, the third preset value is determined as the second value, and the first value is determined according to the second decreasing adjustment method based on the current training round number, target training round number and the second preset value of the semi-supervised model.
[0129] Specifically, if the loss weight coefficient for non-key learning samples (i.e., the second value mentioned above, which is also equal to the third preset value mentioned above) is kept constant at 1, then when training the model based on unlabeled samples in the non-first round, the loss weight coefficient for the key learning samples selected in this round is gradually reduced. The value of (i.e., the first value mentioned above, which is less than the second preset value mentioned above) is ε < 2, which means that as the number of training rounds of the model increases, the difference between the loss weight coefficients between the key learning samples and non-key learning samples selected for this round of model training gradually decreases.
[0130] For example, the decreasing formula (2) corresponding to the second decreasing adjustment method mentioned above can be:
[0131]
[0132] in, Indicates in Take the maximum value between 1 and 0. The first term 2 in the table represents the second preset value (i.e., the loss weight coefficient of the key learning samples used in the first round of training). ), Indicates the number of training rounds in this round. This represents the target number of training epochs. The target number of training epochs can be the total number of training epochs minus 1, or a specified number of training epochs. The specified number of training epochs is less than the total number of training epochs. The difference between the total number of training epochs and the specified number of training epochs is the preset number of epochs P, where P is greater than 2. This means that during a certain number of epochs (not the last epoch) in the later stages of model training, the loss weight coefficients will begin to be adjusted. Setting it to 1 means that during the later stages of model training, from t=T+1 to the last round, the loss weight coefficient for all unlabeled target samples is 1.
[0133] It should be noted that the target number of training rounds... For the case where the total number of training rounds is reduced by 1, the above decreasing formula (2) can be: In the final round of model training, the focus will be on learning the loss weight coefficients of the samples. Setting it to 1 means that all unlabeled target samples are treated equally in the last round of model training; in addition, the decreasing formula (2) shown above is only a relatively simple linear decreasing adjustment method. In actual application, the loss weight coefficient can be set according to actual needs. The deceleration rate is decreasing, therefore, the above-mentioned decreasing formula (2) does not constitute a limitation on the scope of protection of this application.
[0134] Specifically, as the model parameters are iterated and trained, that is, as the number of training rounds increases, the preset adjustment factor is gradually reduced according to the first decreasing adjustment method. For example, Decrease from 1 to 0, when At that time, the above-mentioned criteria for retaining pseudo-labels are: ;when At that time, the above-mentioned criteria for retaining pseudo-labels are: ;
[0135] Furthermore, following the second decreasing adjustment method, the loss weight coefficients corresponding to the key learning samples selected for this round of model training are gradually reduced. (That is, the first value mentioned above, which is less than the second preset value mentioned above). For example, the loss weight coefficient corresponding to non-key learning samples (that is, the second value mentioned above, which is equal to the third preset value mentioned above) is set to 1 and kept unchanged, while the loss weight coefficient corresponding to key learning samples is set to 1 and kept less than the second preset value mentioned above. When the value decreases from 2 to 1, When the loss weight coefficient for non-key learning samples is 1, the loss weight coefficient for key learning samples is 2; when At that time, the loss weight coefficient for all unlabeled target samples is 1.
[0136] In the embodiments provided in this application, as the number of model training rounds increases, on the one hand, the preset adjustment factor is gradually reduced. That is, gradually reduce the above judgment conditions. The aforementioned adjustment coefficients, which gradually reduce the involvement of the first predicted probability of non-target categories in the target group, cause the model training to gradually shift towards using the first predicted probability of the target category to determine whether an unlabeled sample is classified as a sample retaining a false label. This allows the model to gradually focus on class differentiation within the group as the number of training epochs reaches a certain threshold. On the other hand, by gradually reducing the loss weight coefficients of key learning samples... This means that while keeping the loss weight coefficients of non-key learning samples unchanged, the difference between the loss weight coefficients of key learning samples and non-key learning samples is gradually reduced. In other words, when adjusting model parameters based on the loss value in the later stages of model training, all target unlabeled samples are gradually treated equally. This also means that when the number of training rounds reaches a certain value, the distinction between categories within the group is gradually taken into account.
[0137] Furthermore, during model training, whether determining which unlabeled target samples to retain pseudo-labels or selecting key learning samples from multiple unlabeled target samples, it is necessary to determine the target group to which the corresponding target category belongs for each unlabeled sample. Therefore, it is necessary to first divide multiple candidate categories into groups. Figure 2 As shown, in S102 above, before inputting the unlabeled samples from the preset training sample set into the semi-supervised model to be trained to obtain the predicted probability set of each unlabeled sample, the following steps are also included:
[0138] S110, identify multiple candidate categories associated with the target recognition task;
[0139] Specifically, the aforementioned candidate categories are the multiple categories that the target recognition task needs to distinguish. If the target recognition task is an image recognition task, for example, classifying the objects contained in the target image, the corresponding candidate categories could include: dog, cat, car, ship, etc. Or, if it is classifying the types of facial expressions of people contained in the target image, the corresponding candidate categories could include: happy, excited, sad, melancholy, etc. If the target recognition task is a text recognition task, for example, classifying the potential emotional types expressed by the target text field, the corresponding candidate categories could include: excited, questioning, angry, etc.
[0140] S112, Based on the semantic information of each of the above candidate categories, the above candidate categories are divided into groups to obtain multiple category groups.
[0141] Specifically, based on the semantic information of each candidate category, multiple candidate categories with similar semantics are grouped into one category group, while candidate categories with significant semantic differences from other candidate categories are grouped into a separate category group. In other words, each category group can contain multiple candidate categories or only one candidate category.
[0142] In practice, when dividing multiple candidate categories into multiple category groups, one approach is to calculate the semantic similarity between multiple candidate categories and then group them based on the semantic similarity to obtain multiple category groups; alternatively, one approach is to group multiple candidate categories based on the semantic hierarchy between them to obtain multiple category groups.
[0143] Specifically, the aforementioned target recognition task may include: an image recognition task; correspondingly, in S110 above, determining multiple candidate categories associated with the target recognition task specifically includes:
[0144] Step 1: Identify the multiple image categories associated with the image recognition task described above;
[0145] Step two: Determine the above image categories as the above candidate categories.
[0146] Specifically, the aforementioned candidate categories are the multiple image categories that the image recognition task needs to distinguish. For example, in an image recognition task that classifies objects contained in a target image, the corresponding multiple image categories may include: dog, cat, car, ship, etc.
[0147] Specifically, considering that image recognition tasks typically rely solely on single visual modal information for iterative training of semi-supervised models—that is, inputting unlabeled sample images into the semi-supervised model for iterative training—the embodiments provided in this application precisely address the lack of guidance information provided by single visual modal information for semi-supervised model training. Therefore, in addition to using visual modal information, semantic modal information is also utilized. That is, while visual modal information is used during model training, semantic modal information is also used as auxiliary information. Specifically, the target group corresponding to the unlabeled sample determined based on semantic information is regarded as a whole, and the first loss function corresponding to the unlabeled sample is determined based on the predicted probability subset corresponding to the target group. This allows for a later focus on learning the distinction between categories within the group during model training, enriching the guidance information provided for semi-supervised model training and thus improving the accuracy of the model parameters of the trained image recognition model from different perspectives.
[0148] Among them, the process of classifying categories and groups, such as Figure 3As shown, in S112 above, based on the semantic information of each of the above candidate categories, the above multiple candidate categories are grouped to obtain multiple category groups, specifically including:
[0149] S1122, Based on the preset semantic lexicon and the semantic information of each candidate category, an initial semantic hierarchy structure containing the above-mentioned multiple candidate categories is extracted; wherein, the initial semantic hierarchy structure includes: at least one root node, multiple child nodes and multiple leaf nodes, each leaf node is used to represent a candidate category; each child node is used to represent a hypernym corresponding to the candidate category, and the root node is used to represent the minimum hypernym of the target minimum hypernym, which is the minimum hypernym farthest from the leaf node among the minimum hypernyms of multiple candidate categories.
[0150] Specifically, the aforementioned pre-defined semantic lexicon can be the English semantic database WordNet, or other existing semantic lexicons representing the semantic hierarchy between words; the process of constructing the initial semantic hierarchy structure may include:
[0151] Step 1: Search for each candidate category in the pre-defined semantic lexicon, and treat each candidate category as a leaf node; and...
[0152] Step two: For each candidate category, search the pre-defined semantic lexicon for the first-level hypernym (i.e., the lowest hypernym of the candidate category) and the first-level information of the first-level hypernym; and based on this first-level information, treat each first-level hypernym as a child node in its corresponding level position; and,
[0153] Step 3: For each candidate category, search for the second-level superordinate words of the candidate category in the preset semantic lexicon (i.e., the smallest superordinate word of the first-level superordinate words of the candidate category and the second-level information corresponding to the second-level superordinate words; and based on the second-level information, treat each second-level superordinate word as a child node in the corresponding level position;
[0154] Step 4: Based on the secondary superordinate words of each candidate category, determine the child node containing the highest-level secondary superordinate word as the root node;
[0155] Step 5: For each candidate category, if the second-level superordinate word of the candidate category is not located at the target root node (i.e., the root node of the tree structure where the candidate category is located), then sequentially search the M-level superordinate word of the candidate category and the hierarchical information corresponding to the M-level superordinate word in the preset semantic lexicon; and based on the hierarchical information corresponding to the M-level superordinate word, treat each M-level superordinate word as a child node in the corresponding hierarchical position.
[0156] Where M is a positive integer and The K-level hypernyms of the candidate categories are located at the target root node, that is, the third-level hypernyms of the candidate categories are determined sequentially up to the last one. Level M hypernyms, until the final determined M-level hypernym reaches the target root node;
[0157] For example, if the candidate category is automobile and the corresponding target root node is tool, then the first-level superordinate term of the candidate category is motor vehicle, the second-level superordinate term of the candidate category is self-propelled vehicle, and the third-level superordinate term of the candidate category is tool. In this case, K=3, that is, the minimum superordinate term of automobile is motor vehicle, the minimum superordinate term of motor vehicle is self-propelled vehicle, and the minimum superordinate term of self-propelled vehicle is tool (i.e., reaching the target root node).
[0158] For example, if the candidate category is cat and the corresponding target root node is chordate, then the first-level superordinate term of the candidate category is felid, the second-level superordinate term is carnivore, the third-level superordinate term is placental mammal, the fourth-level superordinate term is mammal, the fifth-level superordinate term is vertebrate, and the sixth-level superordinate term is chordate. In this case, K=6, meaning the least significant superordinate term of cat is felid, the least significant superordinate term of felid is carnivore, the least significant superordinate term of carnivore is placental mammal, the least significant superordinate term of placental mammal is mammal, the least significant superordinate term of mammal is vertebrate, and the least significant superordinate term of vertebrate is chordate (i.e., reaching the target root node).
[0159] Step six: Based on the leaf nodes, child nodes, and root nodes obtained in steps one to five above, the initial semantic hierarchy structure is obtained.
[0160] S1124, Based on the above initial semantic hierarchy structure and the first preset constraint, construct a target semantic hierarchy structure for multiple candidate categories; wherein, the target semantic hierarchy structure includes multiple candidate groups, and the first preset constraint is used to constrain the least common hypernym corresponding to the multiple candidate groups respectively;
[0161] In specific implementation, S1124 above, based on the initial semantic hierarchy structure and the first preset constraint condition, constructs a target semantic hierarchy structure for multiple candidate categories, specifically including:
[0162] Step 1: For each category combination, based on the initial semantic hierarchy structure described above, determine the least common hypernym of the two candidate categories in the category combination; wherein, each category combination includes two candidate categories, and the child node containing the least common hypernym is the common child node farthest from the target root node, which is the root node of the branch containing the candidate category;
[0163] Step 2: Based on the aforementioned least common superordinate words and the first preset constraint, construct a target semantic hierarchy structure for multiple candidate categories. That is, after determining the least common superordinate words of each pair of candidate categories, group the multiple candidate categories based on the least common superordinate words and the first preset constraint to obtain a preliminary group division result (i.e., the target semantic hierarchy structure). This preliminary group division result includes multiple candidate groups finally divided based on the first preset constraint. Next, determine the final group division result based on the multiple candidate groups through the following step S1126. This final group division result includes multiple category groups finally divided based on the second preset constraint.
[0164] Specifically, the first preset constraint can include: the candidate group to which the candidate category belongs is the least common superordinate word that is farthest from the root node among at least one least common superordinate word corresponding to the candidate category. The at least one least common superordinate word corresponding to the candidate category includes: the least common superordinate words corresponding to multiple category combinations that contain the candidate category. Therefore, the first preset constraint can be used to constrain the least common superordinate words corresponding to the multiple candidate groups that are finally divided.
[0165] Specifically, each pair of candidate categories is combined into a category combination, that is, all candidate categories are combined in pairs to obtain multiple category combinations; based on the above initial semantic hierarchy structure, the least common superordinate word corresponding to each category combination is determined;
[0166] For each candidate category, determine at least one least common hypernym corresponding to that candidate category, and among the at least one least common hypernym, determine the target least common hypernym that is farthest from the root node;
[0167] At least one candidate category with the same target minimum common superordinate term is assigned to a candidate group, resulting in multiple candidate groups, thus obtaining the target semantic hierarchy structure; if there are no other candidate categories with the same target minimum common superordinate term as a certain candidate category, then that candidate category is assigned to a separate candidate group.
[0168] For example, multiple candidate categories associated with the target recognition task include: car, truck, ship, and airplane. Correspondingly, multiple category combinations include: car-truck, car-ship, car-airplane, truck-ship, truck-airplane, ship-airplane; specifically, the least common superordinate term for the category combination (car-truck) is "motor vehicle," the least common superordinate term for the category combination (car-ship) is "tool," the least common superordinate term for the category combination (car-airplane) is "tool," and the least common superordinate term for the category combination (truck-ship) is "tool." The common superordinate term is "tool," and the least common superordinate term corresponding to the category combination (ship-airplane) is "vehicle." Therefore, the target least common superordinate term corresponding to the candidate category "car" is "motor vehicle," the target least common superordinate term corresponding to the candidate category "truck" is "motor vehicle," the target least common superordinate term corresponding to the candidate category "ship" is "vehicle," and the target least common superordinate term corresponding to the candidate category "airplane" is "vehicle." Thus, it can be concluded that "car" and "truck" are classified into one candidate group (motor vehicle), and "ship" and "airplane" are classified into another candidate group (vehicle).
[0169] In other words, based on the first preset constraint, the multiple candidate groups can ensure that the least common superordinate word of each candidate category is assigned to the candidate group is the least common superordinate word of at least one least common superordinate word of that candidate category that is farthest from the root node.
[0170] Furthermore, in practical implementation, to simplify the construction process of the target semantic hierarchy, when there are multiple root nodes, candidate categories under different root nodes will not be grouped into one group. Therefore, for each root node f, multiple candidate categories corresponding to that root node f can be determined, meaning that candidate categories from different root nodes will not be grouped into one candidate category combination. Then, for each root node f, based on the multiple candidate category combinations corresponding to that root node f, Z is obtained. f There are several candidate groups, and the multiple candidate groups in the target semantic hierarchy are Z corresponding to each root node. f A set of candidate groups.
[0171] S1126, Based on the above target semantic hierarchy structure, determine multiple category groups containing multiple candidate categories.
[0172] Specifically, after constructing the target semantic hierarchy, considering that the larger the hierarchical span between categories, the easier it is to distinguish between categories, a second pre-defined constraint is needed to balance the difficulty of distinguishing between categories learned during model training. This constraint ensures that the maximum hierarchical distance between the multiple category groups is less than a certain pre-defined threshold, thus making the semantics between the category groups sufficiently similar. For example, the second pre-defined constraint could be that the hierarchical distance between the child node containing the least common superordinate word and its corresponding root node is greater than a certain threshold x; or it could be that the hierarchical distance between at least one branch under the child node containing the least common superordinate word and its leaf node is less than a certain threshold y. Where y equals 1, then at least one branch under the child node containing the least common superordinate word is a leaf node.
[0173] It should be noted that the above-mentioned second preset constraint can be set according to actual needs; in addition, the above-mentioned variables x and y are any natural numbers, and their values can also be set according to actual needs, which does not constitute a limitation on the scope of protection of this application.
[0174] In the embodiments provided in this application, considering that if multiple candidate categories are grouped based on semantic similarity, a semantic similarity threshold needs to be set to group candidate categories with semantic similarity greater than the threshold into a single category group, the accuracy of setting the semantic similarity threshold directly affects the accuracy of the final category group division, and thus affects the accuracy of subsequently determining target unlabeled samples and key learning samples. To address this issue, considering that the semantic hierarchy relationship between words in the existing preset semantic lexicon is constructed based on the hierarchical relationship between words, it reflects to a certain extent that multiple semantically similar subordinate words have a hierarchical relationship with a certain superior word, that is, multiple subordinate words connected to the same superior word have a hierarchical relationship. Semantic similarity allows for the division of multiple category groups based on a pre-defined semantic lexicon without requiring the calculation of semantic similarity between each pair of candidate categories. This also ensures that the semantic similarity between multiple candidate categories within each category group is greater than a certain pre-defined threshold. Therefore, it is preferable to use a semantic hierarchical structure to group multiple candidate categories. This involves fully utilizing the existing pre-defined semantic lexicon to construct a semantic hierarchical structure for multiple candidate categories, thereby dividing multiple candidate categories into multiple category groups. This eliminates the need to calculate semantic similarity between candidate categories or set a pre-defined semantic similarity threshold, improving the accuracy of category group division and consequently enhancing the accuracy of subsequently identifying target unlabeled samples and key learning samples.
[0175] Specifically, regarding the process of determining the final multiple category groups based on the target semantic hierarchy, S1126 above, based on the aforementioned target semantic hierarchy, determines multiple category groups containing multiple candidate categories, specifically including:
[0176] For each candidate group in the target semantic hierarchy, determine whether the least common hypernym corresponding to the candidate group satisfies the second preset constraint condition;
[0177] If the conditions are met, then the multiple candidate categories in the above alternative groups will be divided into one category group;
[0178] If the conditions are not met, at least one candidate category in the above candidate groups will be divided into N category groups, where N represents the number of candidate categories contained in the candidate group and N is an integer greater than or equal to 1.
[0179] Specifically, the second preset constraint may include: the hierarchical distance between the child node containing the least common superordinate term and the corresponding root node is greater than the third preset threshold (i.e., constraint 1), and / or at least one branch under the child node containing the least common superordinate term is a leaf node (i.e., constraint 2).
[0180] Among them, constraint 1 can be understood as limiting the minimum common superordinate word corresponding to the final category group to be sufficiently deep in the target semantic hierarchy, that is, close enough to the hierarchical distance of the candidate categories, so as to ensure that the semantic similarity between multiple candidate categories in the category group is greater than a certain preset threshold. Constraint 2 can be understood as limiting the minimum common superordinate word corresponding to the final category group to have no branch child nodes between it and the candidate categories it contains. Considering that if there are branch child nodes, the candidate categories may be classified into the branch child nodes, that is, the candidate categories have the possibility of more detailed classification, so as to avoid multiple candidate categories in the category group not being fully classified.
[0181] In a specific instance, such as Figure 4 As shown, taking object recognition as an image recognition task as an example, a schematic diagram of the implementation principle of grouping multiple image categories is given, specifically:
[0182] (1) Determine the multiple image categories that the image recognition task needs to distinguish; the multiple image categories include: category 1 to category 10;
[0183] (2) Based on the preset semantic lexicon and the category names of each image category, extract the initial hierarchical semantic structure containing categories 1 to 10; specifically, if the 10 image categories include: car, truck, ship, airplane, cat, dog, monkey, deer, horse, bird; the corresponding initial hierarchical semantic structure is as follows: Figure 5a As shown, the bottom 10 leaf nodes are used to represent each image category, and the top 2 root nodes are used to represent the two major categories corresponding to the 10 image categories, namely the tool category and the chordate category. There are multiple levels of child nodes between the bottom and top.
[0184] (3) Based on the above initial semantic hierarchy structure, determine the least common superordinate words of each pair of candidate categories; then, based on the above least common superordinate words and the first preset constraint, construct a target hierarchical semantic structure containing categories 1 to 10; wherein, the target hierarchical semantic structure includes multiple candidate groups, and the first preset constraint is used to constrain the least common superordinate words corresponding to the multiple candidate groups respectively; Figure 5a Based on this, and considering the presence of two root nodes, multiple category combinations can be obtained for each root node. Specifically, for the root node "tools," the corresponding multiple first-category combinations include: car-truck, car-ship, car-airplane, truck-ship, truck-airplane, and ship-airplane; among them, the least common superordinate term for the category combination (car-truck) is "motor vehicle," the least common superordinate term for the category combination (car-ship) is "tool," the least common superordinate term for the category combination (car-airplane) is "tool," and the least common superordinate term for the category combination (truck-ship) is "tool." The least common superordinate term for the category combination (truck-airplane) is "tool," and the least common superordinate term for the category combination (ship-airplane) is "vehicle." Therefore, the target least common superordinate term for the candidate category "car" is "motor vehicle," the target least common superordinate term for the candidate category "truck" is "motor vehicle," the target least common superordinate term for the candidate category "ship" is "vehicle," and the target least common superordinate term for the candidate category "airplane" is "vehicle." Thus, "car" and "truck" are grouped into one candidate group (motor vehicle), and "ship" and "airplane" are grouped into another candidate group (vehicle).
[0185] For the root node "Chordates", the corresponding multiple second-category combinations include: cat-dog, cat-monkey, cat-deer, cat-horse, cat-bird, dog-monkey, dog-deer, dog-horse, dog-bird, monkey-deer, monkey-horse, monkey-bird, deer-horse, deer-bird, and horse-bird. Among these, the least common superordinate term for the category combination (cat-dog) is carnivore; for the category combination (cat-monkey), it is placental mammal; for the category combination (cat-deer), it is placental mammal; for the category combination (cat-horse), it is placental mammal; and for the category combination (cat-bird), it is vertebrate. Similarly, the least common superordinate terms for other category combinations are determined, which will not be elaborated here. Therefore, the target minimum... The common superordinate term is "carnivorous animal." The minimum common superordinate term for the candidate category "dog" is "carnivorous animal," for the candidate category "monkey" it is "placental mammal," for the candidate category "deer" it is "ungulate," for the candidate category "horse" it is "ungulate," and for the candidate category "bird" it is "vertebrate." Therefore, classifying "cat" and "dog" into one candidate group (carnivorous animals), "deer" and "horse" into another candidate group (ungulates), and classifying "monkey" into a separate candidate group (placental mammal) and "bird" into another separate candidate group (vertebrates) results in the following target semantic hierarchy: Figure 5b As shown, the multiple candidate groups in the target hierarchical semantic structure are: motor vehicles (cars, trucks), aircraft (ships, airplanes), carnivores (cats, dogs), placental mammals (monkeys), ungulates (deer, horses), and vertebrates (birds).
[0186] (4) Based on the above target semantic hierarchy and the second preset constraint, determine the multiple category groups obtained in the final division;
[0187] Specifically, taking a concrete implementation as an example, if the aforementioned second preset constraint condition can include: the hierarchical distance between the child node containing the least common superordinate term and the corresponding root node is greater than or equal to 2 (i.e., constraint condition 1), and at least one branch under the child node containing the least common superordinate term is a leaf node (i.e., constraint condition 2); specifically, for the candidate group - aircraft (ships, airplanes), since the hierarchical distance between the child node containing the least common superordinate term "aircraft" and the corresponding root node "tool" in the candidate group is less than 2, it does not meet constraint condition 1, so ships and airplanes are respectively regarded as two different category groups; for the candidate group - placental mammals (monkeys) Since the least common superordinate term "placental mammal" in the candidate group "monkey" has two branches under its child node: "carnivorous animals" and "ungulates", it does not meet constraint condition 2. Therefore, monkeys are treated as a separate category group. For the candidate group "vertebrates (birds)", since the hierarchical distance between the child node of the least common superordinate term "vertebrates" and the corresponding root node "chordates" in the candidate group "birds" is less than 2, it does not meet constraint condition 1. Furthermore, since the child node of the least common superordinate term "vertebrates" in the candidate group "birds" has a branch called "mammals", it also does not meet constraint condition 2. Therefore, birds are also treated as a separate category group.
[0188] Therefore, the final output of multiple category groups for categories 1 to 10 includes: Group 1 - Motor vehicles (cars, trucks), Group 2 (ships), Group 3 (airplanes), Group 4 - Carnivores (cats, dogs), Group 5 (monkeys), Group 6 - Ungulates (deer, horses), and Group 7 (birds); among them, motor vehicles, ships, airplanes, carnivores, monkeys, ungulates, and birds belong to inter-group categories, while cars, trucks, ships, airplanes, cats, dogs, monkeys, deer, horses, and birds belong to intra-group categories.
[0189] Specifically, regarding the process of updating model parameters based on the loss function, in S108 above, the model parameters of the semi-supervised model are iteratively trained based on the first loss function corresponding to each target unlabeled sample to obtain the trained semi-supervised model, which specifically includes:
[0190] Step 1: Determine the semi-supervised loss function based on the first loss function of each target unlabeled sample and the second loss function corresponding to each labeled sample in the preset training sample set.
[0191] Step 2: Based on the semi-supervised loss function mentioned above, iteratively train the model parameters of the semi-supervised model to obtain the trained semi-supervised model.
[0192] Specifically, based on the first loss function corresponding to each target unlabeled sample, the first total loss function is obtained. For example, for each round of model training, the loss weight coefficient for non-key learning samples in the target unlabeled samples is 1, and the loss weight coefficient for key learning samples is... Correspondingly, the first total loss function can be:
[0193]
[0194] in, Indicates the number of unlabeled samples. Indicates the sample number. This represents the loss weight coefficient for the key learning samples. This indicates a preset adjustment factor in the criteria for retaining pseudo-labels. These are the criteria for determining unlabeled samples of the target mentioned above. These are the selection criteria for the key learning samples mentioned above. This is the aforementioned preset unlabeled cross-entropy loss function. The specific meanings of each parameter in the first total loss function can be found in the above-mentioned details, and will not be repeated here.
[0195] Among them, for key learning samples, namely The corresponding first loss function is:
[0196] ;
[0197] For non-key learning samples, i.e. The corresponding first loss function is:
[0198] ;
[0199] Furthermore, based on the second loss function corresponding to each labeled sample, a second total loss function is obtained, which can be:
[0200]
[0201] in, This indicates the number of labeled samples. Indicates the sample number. This indicates the actual labels of the labeled samples. This represents the predicted probability distribution corresponding to labeled samples, where, This represents unlabeled samples after weak enhancement processing. This refers to unlabeled samples after strong enhancement processing. The output predicted probability, This indicates that a pre-defined label cross-entropy loss function is used.
[0202] Then, based on the first and second total loss functions mentioned above, the semi-supervised loss function is determined, that is, the semi-supervised loss function is:
[0203]
[0204] Specifically, based on the aforementioned semi-supervised loss function, the first prediction result output by the semi-supervised model to be trained for unlabeled samples (i.e., the prediction probability set of the unlabeled samples), and the second prediction result output for labeled samples, the semi-supervised loss value can be calculated, and then the model parameters can be iteratively adjusted based on the semi-supervised loss value.
[0205] Step two above, which involves iteratively training the model parameters of the semi-supervised model based on the semi-supervised loss function to obtain the trained semi-supervised model, specifically includes:
[0206] Based on the semi-supervised loss function described above, the total loss value of the semi-supervised model is calculated; where the total loss value is the sum of the first loss value corresponding to each unlabeled sample of the target and the second loss value corresponding to each labeled sample.
[0207] Specifically, for each unlabeled sample, and Substituting the values into the first loss function corresponding to the unlabeled sample in the semi-supervised loss function, we obtain the first loss value; and, for each labeled sample, we... and Substituting the values into the second loss function corresponding to the labeled sample in the semi-supervised loss function, we obtain the second loss value, and then obtain the total loss value of the semi-supervised model.
[0208] Using the stochastic gradient descent method, based on the total loss value mentioned above, the model parameters of the semi-supervised model are adjusted to obtain the semi-supervised model with updated parameters.
[0209] If the training result of this round of model training meets the preset model training termination condition, then the updated semi-supervised model is determined as the trained semi-supervised model; wherein, the preset model training termination condition includes: the number of training rounds in this round is equal to the total number of training rounds, or the above semi-supervised loss function converges;
[0210] If the model training results in this round do not meet the preset model training termination condition, the updated semi-supervised model will be selected as the semi-supervised model to be trained in the next round of model training until the preset model training termination condition is met.
[0211] Specifically, the process of optimizing and adjusting model parameters can be found in existing implementations of adjusting model parameters using stochastic gradient descent, which will not be elaborated here.
[0212] Furthermore, after the semi-supervised model is trained, it can be used to classify the image to be classified, thereby obtaining the corresponding predicted category. Specifically, the target image data to be identified is obtained; the target image data is input into the trained semi-supervised model to obtain the image classification result of the target image data; wherein, the image classification result includes: the third predicted probability of the target image data under each candidate category, and the candidate category corresponding to the maximum value of the third predicted probability can be determined as the predicted category of the target image data.
[0213] In a specific embodiment, taking an image recognition application scenario as an example, the aforementioned semi-supervised model is an image recognition model, such as... Figure 6 As shown, the training process of the image recognition model specifically includes:
[0214] Obtain a preset image sample set; wherein, the preset image sample set includes multiple unlabeled image samples and multiple labeled image samples;
[0215] Unlabeled image samples are input into a semi-supervised model to be trained to obtain a first prediction result, and labeled image samples are input into a semi-supervised model to be trained to obtain a second prediction result; wherein, the first prediction result includes a first prediction probability under candidate categories for weakly enhanced unlabeled image samples, and a second prediction probability under each candidate category for strongly enhanced unlabeled image samples.
[0216] Based on the second prediction result and the true label of each labeled image sample, the second loss value corresponding to each labeled image sample is calculated; the calculation process of the second loss value is described in the relevant content above, and will not be repeated here.
[0217] For each unlabeled image sample, based on the first predicted probability of the unlabeled image sample, the candidate category corresponding to the maximum value of the first predicted probability is determined as the target category of the unlabeled image sample;
[0218] Among the pre-divided multiple category groups, determine the target group to which the target category of the unlabeled image sample belongs;
[0219] Determine the preset adjustment factor corresponding to this round of model training. If this round of model training is the first round of model training, then If this round of model training is not the first round of model training, then ;
[0220] Based on the multiple first prediction probabilities corresponding to the above target groups and the above judgment conditions The target unlabeled image samples that were determined to retain false labels were identified.
[0221] Based on the multiple second prediction probabilities corresponding to the above target groups and the above screening conditions Identify key learning samples from multiple unlabeled image samples of targets;
[0222] Determine the loss weight coefficients for the key learning samples in this round of model training. In this case, the loss weight coefficient for non-key learning samples remains unchanged at 1. If this round of model training is the first round of model training, then... If this round of model training is not the first round of model training, then ;
[0223] Based on the loss weight coefficients corresponding to each target unlabeled sample, the preset unlabeled cross-entropy loss function, and the first prediction result mentioned above, the first loss value of the target unlabeled image sample is calculated.
[0224] Based on the first loss value of each target unlabeled image sample, the sum of the first loss values is obtained, and based on the second loss value of each labeled image sample, the sum of the second loss values is obtained;
[0225] Based on the sum of the first loss value and the sum of the second loss value, the total loss value of the semi-supervised model is obtained; using the stochastic gradient descent method, the model parameters of the semi-supervised model are adjusted based on the total loss value to obtain the semi-supervised model with updated parameters.
[0226] If the model training results in this round meet the preset model training termination conditions, then the updated semi-supervised model will be determined as the trained semi-supervised model.
[0227] If the model training results in this round do not meet the preset model training termination condition, the updated semi-supervised model will be determined as the semi-supervised model to be trained in the next round of model training until the preset model training termination condition is met.
[0228] Furthermore, regarding the application process of the semi-supervised model, the target image to be classified is input into the trained semi-supervised model to obtain the predicted category of the target image.
[0229] The training method of the semi-supervised model in this application embodiment first determines the target category corresponding to the unlabeled sample based on the first predicted probability among all candidate categories, thereby determining the target group to which the target category belongs among multiple category groups. Then, the target group corresponding to the unlabeled sample is regarded as a whole, and the first loss function corresponding to the unlabeled sample is determined based on the subset of predicted probabilities corresponding to the target group. Specifically, on the one hand, multiple reference terms in the determination condition of the target unlabeled sample are related to multiple first predicted probabilities corresponding to the target group. That is, when determining whether to retain the pseudo-label of the unlabeled sample based on the weak enhancement output result of the sample (i.e., the first predicted probability of the unlabeled sample under each candidate category in the target group) (i.e., only samples determined to retain pseudo-labels will participate in the model loss calculation), not only the first predicted probability of the sample under the target category is considered, but also the first predicted probability of the sample under non-target categories in the target group is considered. In this way, samples with a relatively large sum of probabilities under all candidate categories in the target group can be retained to participate in the model loss calculation (i.e., samples with poor class distinction within the group are also retained), so as to avoid over-focusing on the group in the early stage of model training. Instead of focusing on intra-class distinctions, the focus is on distinguishing between inter-group categories. On the other hand, if the sum of the second predicted probabilities of a target unlabeled sample under each candidate category in the target group is small, it indicates that the sum of the second predicted probabilities under other groups is large. This means the semi-supervised model performs poorly in distinguishing between inter-group categories for that target unlabeled sample. Therefore, by associating the loss weight coefficient corresponding to the target unlabeled sample with multiple second predicted probabilities corresponding to the target group, the loss weight coefficient for the target unlabeled sample with poor inter-group category distinction can be increased. Simultaneously, based on the sample enhancement output (i.e., the second predicted probabilities of the unlabeled sample under each candidate category in the target group), different loss weight coefficients are set for the target unlabeled sample (i.e., focusing on learning the target unlabeled sample with poor inter-group category distinction), so as to prioritize learning samples with poor inter-group category distinction in the early stages of model training. In other words, both of these aspects enable priority learning of inter-group category distinction in the early stages of model training. This results in higher accuracy of the model parameters in the trained semi-supervised model, thereby improving the information classification accuracy when the model is used subsequently.
[0230] Corresponding to the above Figures 1 to 6 The training method for the semi-supervised model described herein, based on the same technical concept, also provides an image recognition method in this application. Figure 7 This is a schematic flowchart of an image recognition method provided in an embodiment of this application, such as... Figure 7 As shown, the method includes:
[0231] S702, acquire the target image data to be identified;
[0232] S704, The above target image data is input into the trained semi-supervised model to obtain the image classification result of the target image data; wherein, the image classification result includes: the third predicted probability of the target image data under each candidate category;
[0233] The semi-supervised model trained above is obtained by iteratively training the model parameters of the initial semi-supervised model based on the first loss function of each target unlabeled sample. The target unlabeled samples are selected from multiple unlabeled samples in a preset training sample set based on preset judgment conditions. Each unlabeled sample corresponds to a prediction probability set, which is obtained by inputting the unlabeled sample into the semi-supervised model to be trained in the current round. The prediction probability set includes: the first prediction probability output for the weakly enhanced unlabeled sample under each candidate category, and the second prediction probability output for the strongly enhanced unlabeled sample under each candidate category.
[0234] The target group of the unlabeled samples mentioned above is the category group in which the target category of the unlabeled sample belongs among the pre-divided multiple category groups. The target category is the candidate category corresponding to the maximum value of the first predicted probability of the unlabeled sample under each candidate category. Each unlabeled sample corresponds to a subset of predicted probabilities, which includes the first predicted probability and the second predicted probability under each candidate category in the target group corresponding to the unlabeled sample. The subset of predicted probabilities is used to determine multiple target unlabeled samples that are judged to retain pseudo-labels and the first loss function corresponding to each target unlabeled sample in the preset training sample set.
[0235] The aforementioned preset judgment conditions include multiple reference items that are related to multiple first predicted probabilities corresponding to the target group of the unlabeled sample, the first loss function corresponding to the target unlabeled sample and the loss weight coefficient, and the loss weight coefficient corresponding to the target unlabeled sample and the target group to which the unlabeled sample belongs and the multiple second predicted probabilities.
[0236] Specifically, the target image data is input into the semi-supervised model trained as described above, and image recognition is performed on the target image data to obtain the image recognition result. In specific implementation, the semi-supervised model trained as described above can be used as an image classification model. The target image data is input into the semi-supervised model trained as described above, and image classification is performed on the target image data to obtain the image classification result. The image classification result includes: the third predicted probability of the target image data under each candidate category. Based on the above image classification result, the candidate category corresponding to the maximum value of the third predicted probability is determined as the predicted category of the target image data.
[0237] Among them, the semi-supervised model trained above is composed of the above Figures 1 to 7The semi-supervised model trained using the provided training method is described above. For details on the training process, please refer to the above content, which will not be repeated here.
[0238] The image recognition method in this embodiment uses a semi-supervised model that, during the model training phase, introduces the division of category groups, treating the target group corresponding to the unlabeled sample as a whole. Based on the predicted probability subset corresponding to the target group, it determines the loss weight coefficients for unlabeled target samples that need to retain pseudo-labels and increases the loss weight coefficients for unlabeled target samples with poor prediction performance between groups. This allows for the targeted determination of the first loss function for each unlabeled target sample. It enables the model to prioritize learning the distinction between categories between groups in the early stage of model training, and then focus on learning the distinction between categories within groups in the later stage of model training. This results in higher accuracy of the model parameters of the semi-supervised model. Based on this, subsequent classification of target image data using this semi-supervised model can improve the classification accuracy of the target image data to its category.
[0239] Corresponding to the above Figures 1 to 6 Based on the same technical concept, the training method for the semi-supervised model described in this application also provides a training apparatus for a semi-supervised model. Figure 8 This is a schematic diagram of the module composition of a training device for a semi-supervised model provided in an embodiment of this application. The device is used to perform… Figures 1 to 6 The training method for the semi-supervised model is described, such as... Figure 8 As shown, the device includes:
[0240] The first prediction module 802 is configured to input unlabeled samples from a preset training sample set into a semi-supervised model to be trained, thereby obtaining a set of predicted probabilities for each unlabeled sample; wherein, the set of predicted probabilities includes: a first predicted probability for each candidate category of the unlabeled sample after weak enhancement, and a second predicted probability for each candidate category of the unlabeled sample after strong enhancement.
[0241] The target group determination module 804 is configured to, for each unlabeled sample, determine the target group to which the target category of the unlabeled sample belongs based on the first predicted probability of the unlabeled sample among a plurality of pre-divided category groups; wherein the target category is the candidate category corresponding to the maximum value of the first predicted probability;
[0242] The loss function determination module 806 is configured to determine, based on the predicted probability subsets corresponding to each of the unlabeled samples, a plurality of target unlabeled samples that are determined to retain pseudo-labels and a first loss function corresponding to each of the target unlabeled samples; wherein, the predicted probability subset includes: the first predicted probability and the second predicted probability under each candidate category in the target group corresponding to the unlabeled sample, a plurality of reference terms in the determination condition of the target unlabeled sample are related to a plurality of the first predicted probabilities corresponding to the target group, the loss weight coefficient corresponding to the target unlabeled sample is related to a plurality of the second predicted probabilities corresponding to the target group, and the first loss function is related to the loss weight coefficient;
[0243] The model training module 808 is configured to iteratively train the model parameters of the semi-supervised model based on the first loss function of each of the target unlabeled samples to obtain the trained semi-supervised model.
[0244] The training device for the semi-supervised model in this embodiment first determines the target category of the unlabeled sample based on the first predicted probability among all candidate categories, thereby determining the target group to which the target category belongs among multiple category groups. Then, the target group corresponding to the unlabeled sample is regarded as a whole, and the first loss function corresponding to the unlabeled sample is determined based on the subset of predicted probabilities corresponding to the target group. Specifically, on the one hand, multiple reference terms in the determination condition of the target unlabeled sample are related to multiple first predicted probabilities corresponding to the target group. That is, when determining whether to retain the pseudo-label of the unlabeled sample based on the weak enhancement output result of the sample (i.e., the first predicted probability of the unlabeled sample under each candidate category in the target group) (i.e., only samples determined to retain pseudo-labels will participate in the model loss calculation), not only the first predicted probability of the sample under the target category is considered, but also the first predicted probability of the sample under non-target categories in the target group is considered. In this way, samples with a relatively large sum of probabilities under all candidate categories in the target group can be retained to participate in the model loss calculation (i.e., samples with poor class distinction within the group are also retained), so as to achieve the goal of not overly focusing on the distinction of classes within the group in the early stage of model training, but focusing on On the one hand, the model focuses on distinguishing between categories within groups. On the other hand, if the sum of the second predicted probabilities of the target unlabeled sample under each candidate category in the target group is relatively small, it indicates that the sum of the second predicted probabilities under other groups is relatively large. This means the semi-supervised model is not effective at distinguishing between categories within groups for the target unlabeled sample. Therefore, by associating the loss weight coefficient corresponding to the target unlabeled sample with multiple second predicted probabilities corresponding to the target group, the loss weight coefficient of the target unlabeled sample with poor inter-group category distinction can be increased. Simultaneously, based on the sample enhancement output (i.e., the second predicted probability of the unlabeled sample under each candidate category in the target group), different loss weight coefficients are set for the target unlabeled sample (i.e., focusing on learning the target unlabeled sample with poor inter-group category distinction), so as to prioritize learning samples with poor inter-group category distinction in the early stages of model training. In other words, both of these aspects enable priority learning of inter-group category distinction in the early stages of model training, followed by a focus on learning intra-group category distinction in the later stages. This results in higher accuracy of the semi-supervised model parameters, thereby improving the accuracy of information classification when the model is used subsequently.
[0245] It should be noted that the embodiments of the training device for semi-supervised models in this application and the embodiments of the training method for semi-supervised models in this application are based on the same inventive concept. Therefore, the specific implementation of this embodiment can be referred to the implementation of the corresponding training method for semi-supervised models mentioned above, and the repeated parts will not be described again.
[0246] Corresponding to the above Figure 7Based on the same technical concept, the image recognition method described in this application also provides an image apparatus method, which includes:
[0247] The image acquisition module is configured to acquire target image data to be identified.
[0248] An image recognition module is configured to input the target image data into the trained semi-supervised model to obtain an image classification result of the target image data; wherein, the image classification result includes: the third predicted probability of the target image data under each candidate category, and the semi-supervised model is composed of the above... Figures 1 to 7 The training was conducted using the provided training methods. Please refer to the above content for the specific training process, which will not be repeated here.
[0249] Specifically, the target image data is input into the semi-supervised model trained as described above, and image recognition is performed on the target image data to obtain the image recognition result. In specific implementation, the semi-supervised model trained as described above can be used as an image classification model. The target image data is input into the semi-supervised model trained as described above, and image classification is performed on the target image data to obtain the image classification result. The image classification result includes: the third predicted probability of the target image data under each candidate category. Based on the above image classification result, the candidate category corresponding to the maximum value of the third predicted probability is determined as the predicted category of the target image data.
[0250] The image recognition device in this embodiment uses a semi-supervised model that, during the model training phase, introduces the division of category groups, treating the target group corresponding to the unlabeled sample as a whole. Based on the predicted probability subset corresponding to the target group, it determines the loss weight coefficients for unlabeled target samples that need to retain pseudo-labels and increases the loss weight coefficients for unlabeled target samples with poor prediction performance between groups. This allows for the targeted determination of the first loss function for each unlabeled target sample. It enables the prioritization of learning the distinction between categories between groups in the early stage of model training, and then focuses on learning the distinction between categories within groups in the later stage of model training. This results in higher accuracy of the model parameters of the semi-supervised model. Based on this, subsequent classification of target image data using this semi-supervised model can improve the classification accuracy of the target image data to its category.
[0251] It should be noted that the embodiments of the image recognition device in this application and the embodiments of the semi-supervised model training method in this application are based on the same inventive concept. Therefore, the specific implementation of this embodiment can be referred to the implementation of the corresponding semi-supervised model training method mentioned above, and the repeated parts will not be described again.
[0252] Furthermore, corresponding to the above Figures 1 to 6Based on the same technical concept, this application also provides a computer device for executing the above-described semi-supervised model training method, such as... Figure 9 As shown.
[0253] Computer devices can vary significantly due to differences in configuration or performance. They may include one or more processors 901 and memory 902, with memory 902 storing one or more application programs or data. Memory 902 can be temporary or persistent storage. The application programs stored in memory 902 may include one or more modules (not shown), each module including a series of computer-executable instructions for the computer device. Furthermore, processor 901 may be configured to communicate with memory 902 and execute the series of computer-executable instructions stored in memory 902 on the computer device. The computer device may also include one or more power supplies 903, one or more wired or wireless network interfaces 904, one or more input / output interfaces 905, one or more keyboards 906, etc.
[0254] In one specific embodiment, the semi-computer device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for use in the computer device, and is configured to be executed by one or more processors. The one or more programs include computer-executable instructions for performing the following:
[0255] Unlabeled samples from a preset training sample set are input into a semi-supervised model to be trained to obtain a set of predicted probabilities for each unlabeled sample; wherein, the set of predicted probabilities includes: a first predicted probability for each candidate category of the unlabeled sample after weak enhancement, and a second predicted probability for each candidate category of the unlabeled sample after strong enhancement.
[0256] For each unlabeled sample, in a pre-divided plurality of category groups, based on the first predicted probability of the unlabeled sample, the target group to which the target category of the unlabeled sample belongs is determined; wherein, the target category is the candidate category corresponding to the maximum value of the first predicted probability;
[0257] Based on the predicted probability subsets corresponding to each of the unlabeled samples, a plurality of target unlabeled samples that are determined to retain pseudo-labels and a first loss function corresponding to each of the target unlabeled samples are determined; wherein, the predicted probability subsets include: the first predicted probability and the second predicted probability under each candidate category in the target group corresponding to the unlabeled sample, a plurality of reference terms in the determination condition of the target unlabeled sample are related to a plurality of the first predicted probabilities corresponding to the target group, the loss weight coefficient corresponding to the target unlabeled sample is related to a plurality of the second predicted probabilities corresponding to the target group, and the first loss function is related to the loss weight coefficient;
[0258] Based on the first loss function of each of the target unlabeled samples, the model parameters of the semi-supervised model are iteratively trained to obtain the trained semi-supervised model.
[0259] The computer device in this embodiment first determines the target category of the unlabeled sample based on a first predicted probability among all candidate categories, thereby determining the target group to which the target category belongs among multiple category groups. Then, it treats the target group corresponding to the unlabeled sample as a whole and determines the first loss function corresponding to the unlabeled sample based on a subset of the predicted probabilities corresponding to the target group. Specifically, on the one hand, multiple reference terms in the determination condition of the target unlabeled sample are related to multiple first predicted probabilities corresponding to the target group. That is, when determining whether to retain the pseudo-label of the unlabeled sample based on the weak enhancement output result of the sample (i.e., the first predicted probability of the unlabeled sample under each candidate category in the target group) (i.e., only samples determined to retain pseudo-labels will participate in the model loss calculation), it considers not only the first predicted probability of the sample under the target category, but also the first predicted probability of the sample under non-target categories in the target group. This allows samples with a relatively large sum of probabilities under all candidate categories in the target group to be retained and participate in the model loss calculation (i.e., samples with poor class distinction within the group are also retained). This achieves the goal of not overly focusing on class distinction within the group in the early stage of model training, but rather focusing on the group as a whole. On the one hand, the model distinguishes between categories; on the other hand, if the sum of the second predicted probabilities of the target unlabeled sample under each candidate category in the target group is relatively small, it means that the sum of the second predicted probabilities under other groups is relatively large. The semi-supervised model does not perform well in distinguishing between categories in the target unlabeled sample. Therefore, by associating the loss weight coefficient corresponding to the target unlabeled sample with multiple second predicted probabilities corresponding to the target group, the loss weight coefficient of the target unlabeled sample with poor inter-group category distinction can be increased. That is, at the same time, based on the sample enhancement output (i.e., the second predicted probability of the unlabeled sample under each candidate category in the target group), different loss weight coefficients are set for the target unlabeled sample (i.e., focus on learning the target unlabeled sample with poor inter-group category distinction), so as to focus on learning samples with poor inter-group category distinction in the early stage of model training. In other words, through these two aspects, it is possible to prioritize learning the distinction between categories in the early stage of model training, and then focus on learning the distinction between categories within the group in the later stage of model training. The model parameters of the semi-supervised model trained in this way are more accurate, thereby improving the information classification accuracy when the model is used in the future.
[0260] It should be noted that the embodiments concerning computer devices in this application and the embodiments concerning training methods for semi-supervised models in this application are based on the same inventive concept. Therefore, the specific implementation of this embodiment can be referred to the implementation of the corresponding training methods for semi-supervised models mentioned above, and the repeated parts will not be described again.
[0261] Furthermore, corresponding to the above Figures 1 to 6Based on the same technical concept, this application also provides a storage medium for storing computer-executable instructions. In one specific embodiment, the storage medium can be a USB flash drive, optical disc, hard disk, etc. When the computer-executable instructions stored in the storage medium are executed by a processor, they can achieve the following process:
[0262] Unlabeled samples from a preset training sample set are input into a semi-supervised model to be trained to obtain a set of predicted probabilities for each unlabeled sample; wherein, the set of predicted probabilities includes: a first predicted probability for each candidate category of the unlabeled sample after weak enhancement, and a second predicted probability for each candidate category of the unlabeled sample after strong enhancement.
[0263] For each unlabeled sample, in a pre-divided plurality of category groups, based on the first predicted probability of the unlabeled sample, the target group to which the target category of the unlabeled sample belongs is determined; wherein, the target category is the candidate category corresponding to the maximum value of the first predicted probability;
[0264] Based on the predicted probability subsets corresponding to each of the unlabeled samples, a plurality of target unlabeled samples that are determined to retain pseudo-labels and a first loss function corresponding to each of the target unlabeled samples are determined; wherein, the predicted probability subsets include: the first predicted probability and the second predicted probability under each candidate category in the target group corresponding to the unlabeled sample, a plurality of reference terms in the determination condition of the target unlabeled sample are related to a plurality of the first predicted probabilities corresponding to the target group, the loss weight coefficient corresponding to the target unlabeled sample is related to a plurality of the second predicted probabilities corresponding to the target group, and the first loss function is related to the loss weight coefficient;
[0265] Based on the first loss function of each of the target unlabeled samples, the model parameters of the semi-supervised model are iteratively trained to obtain the trained semi-supervised model.
[0266] When the computer-executable instructions stored in the storage medium in this embodiment are executed by the processor, the target category corresponding to the unlabeled sample is first determined based on the first predicted probability among all candidate categories to determine the target group to which the target category belongs among multiple category groups. Then, the target group corresponding to the unlabeled sample is regarded as a whole, and the first loss function corresponding to the unlabeled sample is determined based on the subset of predicted probabilities corresponding to the target group. Specifically, on the one hand, multiple reference terms in the determination condition of the target unlabeled sample are related to multiple first predicted probabilities corresponding to the target group. That is, when determining whether to retain the pseudo-label of the unlabeled sample based on the weak enhancement output result of the sample (i.e., the first predicted probability of the unlabeled sample under each candidate category in the target group) (i.e., only samples determined to retain pseudo-labels will participate in the model loss calculation), not only the first predicted probability of the sample under the target category is considered, but also the first predicted probability of the sample under the non-target category in the target group is considered. In this way, samples with a relatively large sum of probabilities under all candidate categories in the target group can be retained to participate in the model loss calculation (i.e., samples with poor class distinction within the group are also retained), so as not to overemphasize the distinction between classes within the group in the early stage of model training. Instead of focusing on the overall classification, the model prioritizes the distinction between categories within groups. On the other hand, if the sum of the second predicted probabilities of a target unlabeled sample under each candidate category in the target group is small, it indicates that the sum of the second predicted probabilities under other groups is large. This means the semi-supervised model performs poorly in distinguishing between categories within groups for that target unlabeled sample. Therefore, by associating the loss weight coefficient corresponding to the target unlabeled sample with multiple second predicted probabilities corresponding to the target group, the loss weight coefficient for the target unlabeled sample with poor inter-group classification performance can be increased. Simultaneously, based on the sample enhancement output (i.e., the second predicted probabilities of the unlabeled sample under each candidate category in the target group), different loss weight coefficients are set for the target unlabeled sample (i.e., focusing on learning the target unlabeled sample with poor inter-group classification performance). This allows for prioritizing the learning of samples with poor inter-group classification performance in the early stages of model training. In other words, both of these aspects enable prioritizing the learning of inter-group classification in the early stages of model training, while focusing on learning intra-group classification in the later stages. This results in higher accuracy of the semi-supervised model parameters, thereby improving the accuracy of information classification when the model is used subsequently.
[0267] In another specific embodiment, the computer-executable instructions stored in the aforementioned storage medium, when executed by a processor, can also achieve the following process:
[0268] Acquire the target image data to be identified;
[0269] The target image data is input into the trained semi-supervised model to obtain the image classification result of the target image data; wherein, the image classification result includes: the third predicted probability of the target image data under each candidate category.
[0270] When the computer-executable instructions stored in the storage medium in this embodiment are executed by the processor, the semi-supervised model used in the model training phase introduces the division of category groups, treats the target group corresponding to the unlabeled sample as a whole, and determines the loss weight coefficients of the target unlabeled samples that need to retain pseudo-labels and increase the loss weight coefficients of the target unlabeled samples with poor prediction performance between groups based on the predicted probability subset corresponding to the target group. This allows for the targeted determination of the first loss function for each target unlabeled sample, enabling priority learning of the distinction between categories between groups in the early stage of model training, and then focusing on learning the distinction between categories within groups in the later stage of model training. The model parameters of the semi-supervised model trained in this way have higher accuracy. Based on this, subsequent classification processing of target image data using this semi-supervised model can improve the classification accuracy of the target image data to which it belongs.
[0271] It should be noted that the embodiments concerning storage media in this application and the embodiments concerning training methods for semi-supervised models in this application are based on the same inventive concept. Therefore, the specific implementation of this embodiment can be referred to the implementation of the corresponding training methods for semi-supervised models mentioned above, and the repeated parts will not be described again.
[0272] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0273] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0274] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0275] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0276] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0277] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0278] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0279] Computer-readable media include both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0280] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0281] The embodiments of this application can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. One or more embodiments of this application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can reside in local and remote computer storage media, including storage devices.
[0282] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0283] The above description is merely an embodiment of this document and is not intended to limit the scope of this document. Various modifications and variations can be made to this document by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this document should be included within the scope of the claims of this document.
Claims
1. A training method for a semi-supervised model, characterized in that, The method includes: Unlabeled image samples from a preset training sample set are input into a semi-supervised model to be trained to obtain a set of predicted probabilities for each unlabeled image sample; wherein, the set of predicted probabilities includes: a first predicted probability for each candidate category for the weakly enhanced unlabeled image sample, and a second predicted probability for each candidate category for the strongly enhanced unlabeled image sample. For each unlabeled image sample, based on the first predicted probability of the unlabeled image sample, the target group to which the target category of the unlabeled image sample belongs is determined among a plurality of pre-divided category groups; wherein, the target category is the candidate category corresponding to the maximum value of the first predicted probability; Based on the predicted probability subsets corresponding to each of the unlabeled image samples, a plurality of target unlabeled image samples that are determined to retain false labels and a first loss function corresponding to each of the target unlabeled image samples are determined; wherein, the predicted probability subsets include: the first predicted probability and the second predicted probability under each candidate category in the target group corresponding to the unlabeled image sample, a plurality of reference terms in the determination conditions of the target unlabeled image sample are related to a plurality of the first predicted probabilities corresponding to the target group, the loss weight coefficient corresponding to the target unlabeled image sample is related to a plurality of the second predicted probabilities corresponding to the target group, and the first loss function is related to the loss weight coefficient; Based on the first loss function of each of the target unlabeled image samples, the model parameters of the semi-supervised model are iteratively trained to obtain a trained semi-supervised model for image recognition.
2. The method according to claim 1, characterized in that, The plurality of reference terms include: a first reference term related to a first predicted probability under the target category, and a second reference term related to a first predicted probability under a non-target category in the target group.
3. The method according to claim 2, characterized in that, If the number of training rounds in this round is less than or equal to the target number of training rounds, then the second reference term is positively correlated with the preset adjustment factor, and the preset adjustment factor is negatively correlated with the number of training rounds in this round. If the current training round number is greater than the target training round number, then the second reference term is zero, wherein the target training round number is less than the total training round number.
4. The method according to claim 1, characterized in that, The loss weight coefficient is related to the sample group in which the target unlabeled image sample is located. Different sample groups correspond to their respective loss weight coefficients. The sample grouping is obtained by grouping the target unlabeled image samples based on multiple second prediction probabilities corresponding to the target group. The first loss function is obtained based on the loss weight coefficients corresponding to the target unlabeled image samples and the preset unlabeled cross-entropy loss function.
5. The method according to claim 4, characterized in that, The sample grouping includes: a set of key learning samples and a set of non-key learning samples; Wherein, if the number of training rounds in this round is less than or equal to the target number of training rounds, then the loss weight coefficient corresponding to the key learning sample set is greater than the loss weight coefficient corresponding to the non-key learning sample set, and the target number of training rounds is less than the total number of training rounds.
6. The method according to claim 5, characterized in that, The loss weight coefficient corresponding to the non-key learning sample set is a preset fixed value, and if the number of training rounds in this round is less than or equal to the target number of training rounds, then the loss weight coefficient corresponding to the key learning sample set is negatively correlated with the number of training rounds in this round. If the current training round number is greater than the target training round number, then the loss weight coefficient corresponding to the key learning sample set is equal to the preset fixed value.
7. The method according to claim 1, characterized in that, The step of determining multiple target unlabeled image samples that are judged to retain false labels and the first loss function corresponding to each of the target unlabeled image samples based on the predicted probability subsets corresponding to each of the unlabeled image samples includes: Based on multiple first prediction probabilities in the predicted probability subsets corresponding to each of the unlabeled image samples, multiple target unlabeled image samples that are determined to retain pseudo-labels are identified. Based on multiple second prediction probabilities in the prediction probability subset corresponding to each of the target unlabeled image samples, a set of key learning samples and a set of non-key learning samples are determined among the multiple target unlabeled image samples. The first value is determined as the loss weight coefficient of each target unlabeled image sample in the key learning sample set, and the second value is determined as the loss weight coefficient of each target unlabeled image sample in the non-key learning sample set; wherein, if the number of training rounds in this round is less than or equal to the target number of training rounds, then the first value is greater than the second value, and the target number of training rounds is less than the total number of training rounds; Based on the loss weight coefficients and the preset unlabeled cross-entropy loss function corresponding to each of the target unlabeled image samples, the first loss function corresponding to each of the target unlabeled image samples is determined.
8. The method according to claim 7, characterized in that, The step of determining multiple target unlabeled image samples that are judged to retain false labels based on multiple first prediction probabilities in the predicted probability subsets corresponding to each of the unlabeled image samples includes: For each unlabeled image sample, a first probability sum is determined based on multiple first prediction probabilities in the predicted probability subset corresponding to the unlabeled image sample; wherein, the first probability sum is the sum of the weighted probability values of the first prediction probability of the target category and the first prediction probability of the non-target category in the target group, and the weighted probability value is the product of the sum of the first prediction probabilities of the non-target categories and a preset adjustment factor. If the sum of the first probabilities is greater than or equal to the first preset threshold, then the unlabeled image sample is determined to be the target unlabeled image sample.
9. The method according to claim 7, characterized in that, The step of determining a set of key learning samples and a set of non-key learning samples from the multiple sets of second prediction probabilities in the subset of prediction probabilities corresponding to each of the target unlabeled image samples includes: For each unlabeled image sample, a second probability sum is determined based on multiple second prediction probabilities in the predicted probability subset corresponding to the unlabeled image sample; wherein, the second probability sum is the sum of the second prediction probability of the target category and the second prediction probability of the non-target category in the target group; If the sum of the second predicted probabilities is less than or equal to the second preset threshold, then the target unlabeled image sample is assigned to the key learning sample set; If the sum of the second predicted probabilities is greater than the second preset threshold, then the target unlabeled image sample is classified into the non-key learning sample set.
10. The method according to claim 8, characterized in that, Before determining the sum of the first probabilities based on multiple first predicted probabilities in the subset of predicted probabilities corresponding to the unlabeled image samples, the method further includes: For the first round of model training, the first preset value is determined as the preset adjustment factor used in this round of model training; For non-first rounds of model training, the preset adjustment factor used in this round of model training is determined according to the first decreasing adjustment method, based on the number of training rounds of the semi-supervised model, the target number of training rounds, and the first preset value.
11. The method according to claim 7, characterized in that, Before determining the first value as the loss weight coefficient of each of the target unlabeled image samples in the key learning sample set, and before determining the second value as the loss weight coefficient of each of the target unlabeled image samples in the non-key learning sample set, the method further includes: For the first round of model training, the second preset value is determined to be the first value, and the third preset value is determined to be the second value; For non-first rounds of model training, the third preset value is determined as the second value, and the first value is determined according to the second decreasing adjustment method, based on the current training round number, the target training round number, and the second preset value of the semi-supervised model.
12. The method according to claim 1, characterized in that, Before inputting unlabeled image samples from a pre-defined training sample set into the semi-supervised model to be trained to obtain the predicted probability set for each unlabeled image sample, the method further includes: Identify multiple candidate categories associated with the target recognition task; Based on the semantic information of each candidate category, the multiple candidate categories are grouped to obtain multiple category groups.
13. The method according to claim 12, characterized in that, The target recognition task includes: an image recognition task, wherein determining multiple candidate categories associated with the target recognition task includes: Identify multiple image categories associated with the image recognition task; The plurality of image categories are determined as the plurality of candidate categories.
14. The method according to claim 12, characterized in that, Based on the semantic information of each candidate category, the multiple candidate categories are grouped to obtain multiple category groups, including: Based on a preset semantic lexicon and the semantic information of each candidate category, an initial semantic hierarchy structure containing the multiple candidate categories is extracted; wherein, the initial semantic hierarchy structure includes: at least one root node, multiple child nodes and multiple leaf nodes, and each leaf node is used to represent one of the candidate categories; Based on the initial semantic hierarchy structure and the first preset constraint, a target semantic hierarchy structure for the multiple candidate categories is constructed; wherein, the target semantic hierarchy structure includes multiple candidate groups, and the first preset constraint is used to constrain the least common hypernym corresponding to the multiple candidate groups respectively; Based on the target semantic hierarchy, multiple category groups containing the multiple candidate categories are determined.
15. The method according to claim 14, characterized in that, The construction of the target semantic hierarchy structure for the multiple candidate categories based on the initial semantic hierarchy structure and the first preset constraints includes: For each category combination, based on the initial semantic hierarchy, the least common hypernym of the category combination is determined; wherein, the category combination includes two candidate categories, and the child node corresponding to the least common hypernym is the common child node farthest from the root node; Based on the least common hypernym and the first preset constraint, a target semantic hierarchy structure for the multiple candidate categories is constructed.
16. The method according to claim 15, characterized in that, The first preset constraint includes: the candidate group to which each candidate category belongs is the least common superordinate word that is farthest from the root node among at least one least common superordinate word corresponding to that candidate category; Wherein, the at least one least common superordinate term includes: the least common superordinate term corresponding to each of the multiple category combinations containing the candidate category.
17. The method according to claim 14, characterized in that, The step of determining multiple category groups containing the multiple candidate categories based on the target semantic hierarchy includes: For each candidate group in the target semantic hierarchy, determine whether the least common hypernym corresponding to the candidate group satisfies the second preset constraint condition; If the conditions are met, then the multiple candidate categories in the alternative groups are divided into one category group; If the condition is not met, at least one of the candidate categories in the candidate groups will be divided into N category groups, where N represents the number of candidate categories contained in the candidate groups and N is an integer greater than or equal to 1.
18. The method according to claim 17, characterized in that, in, The second preset constraint conditions include: the hierarchical distance between the child node containing the least common superordinate term and the corresponding root node is greater than a third preset threshold, and / or at least one branch under the child node containing the least common superordinate term is a leaf node.
19. The method according to claim 1, characterized in that, The semi-supervised model is iteratively trained based on the first loss function of each of the target unlabeled image samples to obtain the trained semi-supervised model, including: A semi-supervised loss function is determined based on the first loss function of each unlabeled image sample of the target and the second loss function corresponding to each labeled image sample in the preset training sample set. Based on the semi-supervised loss function, the model parameters of the semi-supervised model are iteratively trained to obtain the trained semi-supervised model.
20. The method according to claim 19, characterized in that, The step of iteratively training the model parameters of the semi-supervised model based on the semi-supervised loss function to obtain the trained semi-supervised model includes: Based on the semi-supervised loss function, the total loss value of the semi-supervised model is calculated; wherein, the total loss value is the sum of the first loss value corresponding to each of the target unlabeled image samples and the second loss value corresponding to each of the labeled image samples; Using the stochastic gradient descent method, the model parameters of the semi-supervised model are adjusted based on the total loss value to obtain the semi-supervised model with updated parameters; If the model training result of this round meets the preset model training termination condition, then the updated semi-supervised model is determined as the trained semi-supervised model; wherein, the preset model training termination condition includes: the number of training rounds in this round is equal to the total number of training rounds, or the semi-supervised loss function converges; If the model training results in this round do not meet the preset model training termination condition, the updated semi-supervised model will be determined as the semi-supervised model to be trained in the next round of model training, until the preset model training termination condition is met.
21. An image recognition method, characterized in that, The method includes: Acquire the target image data to be identified; The target image data is input into the trained semi-supervised model to obtain the image classification result of the target image data; wherein, the image classification result includes: the third predicted probability of the target image data under each candidate category, and the semi-supervised model is trained by the training method of the semi-supervised model according to any one of claims 1-20.
22. A training device for a semi-supervised model, comprising: The first prediction module is configured to input unlabeled image samples from a preset training sample set into a semi-supervised model to be trained, and obtain a set of prediction probabilities for each unlabeled image sample; wherein, the set of prediction probabilities includes: a first prediction probability for each candidate category output for the weakly enhanced unlabeled image sample, and a second prediction probability for each candidate category output for the strongly enhanced unlabeled image sample. The target group determination module is configured to, for each unlabeled image sample, determine the target group to which the target category of the unlabeled image sample belongs based on the first predicted probability of the unlabeled image sample among a plurality of pre-divided category groups; wherein the target category is the candidate category corresponding to the maximum value of the first predicted probability; The loss function determination module is configured to determine, based on a subset of predicted probabilities corresponding to each of the unlabeled image samples, multiple target unlabeled image samples that are determined to retain false labels and a first loss function corresponding to each of the target unlabeled image samples; wherein, the subset of predicted probabilities includes: the first predicted probability and the second predicted probability under each candidate category in the target group corresponding to the unlabeled image sample, multiple reference terms in the determination condition of the target unlabeled image sample are related to multiple first predicted probabilities corresponding to the target group, the loss weight coefficient corresponding to the target unlabeled image sample is related to multiple second predicted probabilities corresponding to the target group, and the first loss function is related to the loss weight coefficient; The model training module is configured to iteratively train the model parameters of the semi-supervised model based on the first loss function of each of the target unlabeled image samples, so as to obtain a trained semi-supervised model for image recognition.
23. An image recognition device, characterized in that, The device includes: The image acquisition module is configured to acquire target image data to be identified. An image recognition module is configured to input the target image data into the trained semi-supervised model to obtain an image classification result of the target image data; wherein the image classification result includes: the third predicted probability of the target image data under each candidate category, and the semi-supervised model is trained by the training method of the semi-supervised model according to any one of claims 1-20.
24. A computer device, characterized in that, The device includes: Processor; and A memory configured to store computer-executable instructions configured to be executed by the processor, the executable instructions including steps for performing the method as described in any one of claims 1-20 or claim 21.
25. A storage medium, characterized in that, The storage medium is used to store computer-executable instructions that cause the computer to perform the method as described in any one of claims 1-20 or claim 21.
Citation Information
Patent Citations
Semi-supervised learning image classification method based on group representation features
CN113408652A
Model optimization method and device
CN114037876A