Semi-supervised image recognition method based on adaptive contrastive learning
By adopting the semi-supervised method of adaptive contrast learning in image recognition tasks, using the adaptive threshold and class-aware module/distance-aware module to process samples with different confidence levels, the problems of insufficient utilization of unsupervised data and uneven distribution of data are solved, which significantly improves the accuracy of image recognition and the robustness of the model.
Patent Information
- Application Number
- CN202510066177.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2045-01-16
AI Technical Summary
The existing technology cannot fully utilize unsupervised data in image recognition tasks, resulting in a small amount of training sample data and low model robustness. At the same time, data distribution in different categories is uneven, resulting in insufficient data volume of categories with small sample size, difficulty in learning key features, and insufficient generalization capabilities of the obtained neural network model.
The semi-supervised image recognition method based on adaptive contrast learning is adopted. By setting an adaptive threshold, unlabeled samples with different confidence scores are classified and processed. The class perception module and the distance perception module are used to process samples with high and low confidence levels respectively, making full use of unsupervised data to solve the problem of uneven data distribution.
It effectively improves the accuracy of image recognition, makes full use of unsupervised data, solves the problem of uneven distribution of data in different categories, and improves the robustness and generalization capabilities of the model.
Smart Images

Figure CN119478591B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to image recognition technology, and in particular to a semi-supervised image recognition method based on adaptive contrast learning. Background Art
[0002] With the rapid growth of data volume and the continuous improvement of hardware technology, machine learning, especially deep learning algorithms, is becoming more and more popular in various fields and is widely used in practical scenarios. With its powerful automatic feature extraction capabilities, deep learning has greatly promoted technological progress in image recognition, natural language processing, speech recognition and other fields. Feature engineering has long been an important research direction in machine learning, which focuses on building features from raw data. In addition, feature engineering is usually domain-specific and requires manual extraction. Once a new feature is proposed and performs well, it will become a trend for many years. Deep learning algorithms imitate the work of the human brain and automatically extract the most effective features through the network. These algorithms include a hierarchical structure of data representation, where high-level features can be extracted from the last layer of the network, and low-level features can be extracted from lower layers.
[0003] Deep learning has achieved remarkable success in the field of image recognition. The efficiency of image recognition tasks depends largely on how well the input data is represented. However, considering the complex conditions of reality, labeled data is difficult to obtain, but samples without category labels are relatively easy to obtain. Obviously, after considering the labeling cost issue, we can find that compared with the total amount of data, the proportion of labeled data is relatively small. Therefore, in supervised learning image recognition tasks, only labeled data samples are used during learning, but in practical applications we must rely on samples of unlabeled data to make decisions. This requires us to take into account the possible unlabeled samples during the training process. In the image recognition task of supervised learning, a large amount of accurate, independent, and evenly distributed training data is usually required to train a robust model. However, the difficulty and time-consuming nature of processing training data lead to high costs for obtaining labeled data. Even if these labeled samples are obtained, the trained model is difficult to reflect the real situation due to their limited number. Secondly, if only a small portion of the total data samples are trained, the large proportion of unlabeled samples will be wasted and the full use will not be achieved. The most important thing is that the distribution of data in different categories is uneven, which may lead to insufficient data for categories with small sample sizes, making it difficult to learn key features and obtain neural network models with good generalization ability. This results in a lack of recognition effect of supervised learning algorithms. Therefore, only when unlabeled data is fully considered can the decision boundary be clarified and the true distribution of data be determined. The addition of unlabeled data will assist in training more robust image recognition models when there are fewer labels or labels are completely removed, and even outperform supervised cases.
[0004] In summary, the main problems of image recognition technology in related technologies are: (1) It is unable to fully utilize unsupervised data, resulting in a small amount of training sample data and low robustness of the trained model. (2) The data of different categories in the training dataset are unevenly distributed, resulting in insufficient data for categories with small sample sizes, making it difficult to learn key features and insufficient generalization ability of the obtained neural network model. Summary of the invention
[0005] In view of the above problems in the prior art, the present invention provides a semi-supervised image recognition method based on adaptive contrastive learning. By setting an adaptive threshold, unlabeled samples with different confidence scores are classified and processed, which can make full use of unsupervised data, solve the problem of uneven distribution of data of different categories, and effectively improve the accuracy of image recognition. The method includes:
[0006] The collected image dataset is divided into labeled samples and unlabeled samples. The labeled samples are weakly enhanced to obtain weakly enhanced labeled samples, and the unlabeled samples are weakly enhanced to obtain weakly enhanced unlabeled samples. The unlabeled samples are strongly enhanced twice to obtain strongly enhanced unlabeled samples I and strongly enhanced unlabeled samples II.
[0007] The weakly enhanced labeled samples are input into a pre-trained feature encoder to obtain feature predictions of the weakly enhanced labeled samples, and a supervised loss function is calculated based on the feature predictions of the weakly enhanced labeled samples.
[0008] The weakly enhanced unlabeled samples, strongly enhanced unlabeled samples I and strongly enhanced unlabeled samples II are respectively input into a pre-trained feature encoder to obtain feature predictions of weakly enhanced unlabeled samples, feature predictions and feature embeddings of strongly enhanced unlabeled samples I, and feature embeddings of strongly enhanced unlabeled samples II, and an adaptive threshold is calculated based on the feature predictions of weakly enhanced labeled samples and the feature predictions of weakly enhanced unlabeled samples.
[0009] The weakly enhanced unlabeled sample feature prediction is compared with the adaptive threshold. If the weakly enhanced unlabeled sample feature prediction is greater than or equal to the adaptive threshold, an unsupervised loss function is calculated based on the weakly enhanced unlabeled sample feature prediction and the strongly enhanced unlabeled sample I feature prediction, and the class-aware matrix is used to process the weakly enhanced unlabeled sample feature prediction whose confidence is greater than or equal to the adaptive threshold. The class-aware loss function is calculated by combining the strongly enhanced unlabeled sample I feature prediction and feature embedding and the strongly enhanced unlabeled sample II feature embedding.
[0010] If the feature prediction of the weakly enhanced unlabeled sample is lower than the adaptive threshold, the weakly enhanced unlabeled sample whose feature prediction is lower than the adaptive threshold is placed in the distance perception module for processing to obtain the distance perception loss function.
[0011] The supervised loss function, unsupervised loss function, class-aware loss function, and distance-aware loss function are added together to obtain a complete total loss function, the total loss function is used to train a machine learning model, and the machine learning model is applied to recognize an input image.
[0012] Preferably, the weak data enhancement processing for the labeled samples is specifically performed by using a random cropping algorithm; the weak data enhancement processing for the unlabeled samples is specifically performed by using a random horizontal flipping algorithm; the strong data enhancement processing for the unlabeled samples is performed twice, both times using Randaugment algorithm.
[0013] Preferably, the supervised loss function is calculated based on the weakly enhanced labeled sample feature prediction, specifically:
[0014] ,
[0015] ,
[0016] ,
[0017] in, is a supervised loss function, is the pseudo label loss function and is the soft label loss function, represents the batch size of labeled samples, represents the cross entropy loss, Indicates weakly enhanced labeled sample feature prediction, represents the i-th weakly enhanced labeled sample, represents the label of the i-th weakly enhanced labeled sample, represents the category-based soft label, represents the output of the feature encoder, softmax is the activation function.
[0018] Preferably, the adaptive threshold specifically includes:
[0019] ,
[0020] ,
[0021] ,
[0022] In the formula, represents the t-th iteration adaptive threshold, c represents the c-th class label, represents the local threshold containing labeled samples, represents the global threshold composed of the average confidence of unlabeled samples, represents the number of label samples of the cth category, represents the number of weakly enhanced labeled samples, Indicates the indicator symbol, Indicates weakly enhanced labeled sample feature prediction, Indicated by The pseudo-label obtained by conversion, C represents the number of label classes, represents the batch size of unlabeled samples, represents the momentum decay of the exponential moving average, Represents weakly enhanced unlabeled sample feature prediction.
[0023] Preferably, the unsupervised loss function is calculated based on the weakly enhanced unlabeled sample feature prediction and the strongly enhanced unlabeled sample I feature prediction, and specifically includes:
[0024] ,
[0025] ,
[0026] ,
[0027] in, is the unsupervised loss function, represents the batch size of unlabeled data, Indicates the indicator symbol, represents weakly enhanced unlabeled sample feature prediction, represents the adaptive threshold, represents the cross entropy loss, Indicated by The pseudo-label obtained by conversion, represents the strongly enhanced unlabeled sample I feature prediction, and They represent weakly enhanced unlabeled samples and strongly enhanced unlabeled samples I respectively.
[0028] Preferably, the method of using the class-aware matrix to process the feature prediction of the weakly enhanced unlabeled samples with a confidence greater than or equal to the adaptive threshold, combining the feature prediction and feature embedding of the strongly enhanced unlabeled samples I and the feature embedding of the strongly enhanced unlabeled samples II, and calculating the class-aware loss function specifically includes:
[0029] First, obtain the affinity matrix S of the strongly enhanced unlabeled sample II feature embedding, the elements of the affinity matrix S are:
[0030] ,
[0031] in, , Indicates that two products of the same batch use the same RandAugment The algorithm parameters are square normalized low-dimensional embedding of strongly enhanced samples, N represents the batch size, represents the temperature coefficient;
[0032] Then, the class-aware contrast matrix M is used for calculation, and the elements of the class-aware contrast matrix M are expressed as follows:
[0033] ,
[0034] in, , They are respectively represented as the maximum values of the weakly enhanced labeled sample feature prediction and the strongly enhanced labeled sample feature prediction, represents the adaptive threshold;
[0035] Finally, the class perception loss function is calculated according to the affinity matrix S and the class perception contrast matrix M:
[0036] The class-aware loss function is specifically:
[0037] ,
[0038] ,
[0039] in, represents the cross entropy loss, N represents the batch size, represents the view index of other images of the same category with the same confidence level, represents the temperature coefficient, Indicates The square normalized low-dimensional embeddings of other samples with the same confidence level, Indicates that the same sample has undergone another different RandAugment The feature embedding obtained after strong enhancement of the algorithm parameters, Indicates an indicator symbol.
[0040] Furthermore, the weakly enhanced unlabeled samples whose feature predictions are lower than the adaptive threshold are placed in the distance perception module for processing, specifically:
[0041] First, the feature encoder is used to extract the features of weakly enhanced unlabeled samples to predict the features of samples below the adaptive threshold, randomly select the central feature, and calculate the distance between the central feature and other features;
[0042] Secondly, according to the distance between the samples and the feature prediction of the weakly enhanced labeled samples, positive and negative weights are assigned to the features of the samples whose feature prediction of the weakly enhanced unlabeled samples is lower than the adaptive threshold;
[0043] Finally, calculate the distance-aware loss function ,
[0044] ,
[0045] in, represents the model parameters, , Represent the positive weight and negative weight of the feature respectively, represents the selected central feature prediction, , represents the weakly enhanced labeled sample feature prediction and the weakly enhanced unlabeled sample feature prediction, represents a hyperparameter.
[0046] Furthermore, the distance is calculated as follows:
[0047] ,
[0048] in, and Represent the central feature and other features respectively.
[0049] Furthermore, the new positive weights and negative weights are assigned to the features of the weakly enhanced unlabeled sample whose feature prediction is lower than the adaptive threshold sample as follows:
[0050] ,
[0051] in, , represents the new feature positive weight and feature negative weight, Indicates weakly enhanced labeled sample feature prediction, represents the distance between the features, means sorting positive weights in reverse order.
[0052] The present invention sets an adaptive threshold according to the recognition difficulty of different categories of images and the current learning state of the model. The threshold is then used to process data of different confidence levels using a class perception module and a distance perception module. For samples with higher confidence levels, the class perception module is used to classify samples of the same category and learn the original fine label information of the image. For samples with low confidence levels, the distance perception module is used to distinguish between positive and negative sets through different distances, and effective features are learned as much as possible when the classification boundary is fuzzy. The present invention can make full use of unsupervised data, solve the problem of uneven distribution of data of different categories, and effectively improve the accuracy of image recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 Schematic diagram of the basic flow of the method of the embodiment of the present invention.
[0054] Figure 2 This is a principle block diagram of the semi-supervised image recognition method based on adaptive contrastive learning. DETAILED DESCRIPTION
[0055] The content of the present invention is further described in detail below in conjunction with specific implementation cases, but the implementation method of the present invention is not limited thereto.
[0056] Specifically, this embodiment uses facial expression recognition as an example to describe the semi-supervised image recognition method based on adaptive contrastive learning of the present invention. It should be noted that the present invention can be extended to other image recognition tasks, the only difference being that the data sources during construction are different.
[0057] like Figure 1 and Figure 2 As shown, the semi-supervised image recognition method based on adaptive contrast learning in the embodiment of the present invention includes:
[0058] Step 1: Divide the collected image dataset into labeled samples and unlabeled samples, perform weak data enhancement on the labeled samples to obtain weakly enhanced labeled samples, perform weak data enhancement on the unlabeled samples to obtain weakly enhanced unlabeled samples, and perform strong data enhancement twice on the unlabeled samples to obtain strongly enhanced unlabeled samples I and strongly enhanced unlabeled samples II.
[0059] Specifically, the dataset containing 7 different types of expressions is divided into labeled samples With unlabeled samples , the data enhancement samples are obtained by inputting the data enhancement module, the random cropping algorithm is used for weak data enhancement processing of labeled samples, the random horizontal flipping algorithm is used for weak data enhancement processing of unlabeled samples, and the random horizontal flipping algorithm is used for weak data enhancement processing. Randaugment The algorithm performs strong data enhancement processing to obtain data enhancement samples. Figure 2 In the figure, WA represents weak data enhancement and SA represents strong data enhancement.
[0060] Step 2: Input the weakly enhanced labeled sample into a pre-trained feature encoder to obtain feature predictions of the weakly enhanced labeled sample, and calculate a supervised loss function based on the feature predictions of the weakly enhanced labeled sample.
[0061] This example uses the ResNet-18 network pre-trained on the MS-Celeb-1M face recognition dataset as the backbone network of the entire model to extract sample features.
[0062] The supervised loss function described By pseudo label loss and soft label loss The specific calculation is as follows:
[0063] ,
[0064] ,
[0065] ,
[0066] in, represents the batch size of labeled samples, represents the cross entropy loss, Indicates weakly enhanced labeled sample feature prediction, represents the i-th weakly enhanced labeled sample, represents the label of the i-th weakly enhanced labeled sample, represents the category-based soft label, Represents the output of the model.
[0067] Step 3: Input the weakly enhanced unlabeled samples, strongly enhanced unlabeled samples I and strongly enhanced unlabeled samples II into the pre-trained feature encoder respectively to obtain the feature prediction of the weakly enhanced unlabeled samples, the feature prediction and feature embedding of the strongly enhanced unlabeled samples I, and the feature embedding of the strongly enhanced unlabeled samples II, and calculate the adaptive threshold according to the feature prediction of the weakly enhanced labeled samples and the feature prediction of the weakly enhanced unlabeled samples.
[0068] The adaptive threshold is calculated based on the prediction of the sample data , as follows:
[0069] ,
[0070] in, represents the t-th iteration adaptive threshold, c represents the c-th class label, represents the local threshold containing labeled samples, represents the global threshold composed of the average confidence of unlabeled samples. The latter two are calculated as follows:
[0071] ,
[0072] ,
[0073] in, represents the number of label samples of the cth category, represents the number of weakly enhanced labeled samples, Indicates the indicator symbol, Indicates weakly enhanced labeled sample feature prediction, Indicated by The converted hard "one-hot" label, C represents the number of label classes, represents the batch size of unlabeled samples, represents the momentum decay of the exponential moving average (EMA), Represents the predicted probability of weakly enhanced unlabeled sample features.
[0074] Step 4: Compare the weakly enhanced unlabeled sample feature prediction with the adaptive threshold. If the weakly enhanced unlabeled sample feature prediction is greater than or equal to the adaptive threshold, calculate the unsupervised loss function according to the weakly enhanced unlabeled sample feature prediction and the strongly enhanced unlabeled sample I feature prediction, and use the category-aware matrix to process the weakly enhanced unlabeled sample feature prediction whose confidence is greater than or equal to the adaptive threshold. Combine the strongly enhanced unlabeled sample I feature prediction and feature embedding and the strongly enhanced unlabeled sample II feature embedding to calculate the category-aware loss function.
[0075] The method uses the category perception matrix to process the feature prediction of the weakly enhanced unlabeled samples whose confidence is greater than or equal to the adaptive threshold, combines the feature prediction and feature embedding of the strongly enhanced unlabeled samples I and the feature embedding of the strongly enhanced unlabeled samples II, and calculates the category perception loss function, specifically including:
[0076] First, an affinity matrix S is obtained according to the feature embedding of the strongly enhanced unlabeled sample I and the feature embedding of the strongly enhanced unlabeled sample II. The elements of the affinity matrix S are:
[0077] ,
[0078] in, , Indicates that two products of the same batch use the same RandAugment The algorithm parameters are square normalized low-dimensional embedding of strongly enhanced samples, N represents the batch size, represents the temperature coefficient;
[0079] Then, the class-aware contrast matrix M is calculated and the useless information is filtered using the class-aware function. The elements of the class-aware contrast matrix M are expressed as follows:
[0080] ,
[0081] in, , It is expressed as the maximum value of the feature prediction of the weakly enhanced unlabeled sample and the maximum value of the feature prediction of the strongly enhanced unlabeled sample I. represents the adaptive threshold;
[0082] Finally, the class perception loss function is calculated according to the affinity matrix S and the class perception contrast matrix M:
[0083] The class-aware loss function is specifically:
[0084] ,
[0085] ,
[0086] in, represents the cross entropy loss, N represents the batch size, represents the view index of other images of the same category with the same confidence level, represents the temperature coefficient, Indicates the strongly enhanced unlabeled sample I and samples have the same confidence level as other samples embedding, Indicates the first The samples were subjected to another RandAugment The feature embedding obtained after strong enhancement of the algorithm parameters, Indicates an indicator symbol.
[0087] Step 5: If the feature prediction of the weakly enhanced unlabeled sample is lower than the adaptive threshold, the weakly enhanced unlabeled sample whose feature prediction is lower than the adaptive threshold is placed in the distance perception module for processing to obtain the distance perception loss function.
[0088] First, the feature encoder is used to extract the weakly enhanced unlabeled sample features to predict the features of samples below the adaptive threshold, randomly select the central feature, and calculate the distance K between the central feature and other features;
[0089] Secondly, according to the distance K and the feature prediction of the weakly enhanced labeled samples, positive weights and negative weights are assigned to the features of the weakly enhanced unlabeled samples whose feature prediction is lower than the adaptive threshold sample;
[0090] Finally, calculate the distance-aware loss function ,
[0091] ,
[0092] in, represents the model parameters, , Represent the positive weight and negative weight of the feature respectively, represents the selected central feature prediction, , represents the weakly enhanced labeled sample feature prediction and the weakly enhanced unlabeled sample feature prediction, represents a hyperparameter.
[0093] The inter-distance K is calculated as follows:
[0094] ,
[0095] in, and Represent the central feature and other features respectively.
[0096] Furthermore, the new positive weights and negative weights are assigned to the features of the weakly enhanced unlabeled sample whose feature prediction is lower than the adaptive threshold sample as follows:
[0097] ,
[0098] in, , represents the new feature positive weight and feature negative weight, Indicates weakly enhanced labeled sample feature prediction, represents the distance between the features, means sorting positive weights in reverse order.
[0099] Step six: Add the supervised loss function, unsupervised loss function, class-aware loss function, and distance-aware loss function to obtain a complete total loss function, use the total loss function to train a machine learning model, and apply the machine learning model to recognize the input image.
[0100] The present invention sets an adaptive threshold according to the recognition difficulty of different categories of images and the current learning state of the model. The threshold is then used to process data of different confidence levels using a class perception module and a distance perception module. For samples with higher confidence levels, the class perception module is used to classify samples of the same category and learn the original fine label information of the image. For samples with low confidence levels, the distance perception module is used to distinguish between positive and negative sets through different distances, and effective features are learned as much as possible when the classification boundary is fuzzy. The present invention can make full use of unsupervised data, solve the problem of uneven distribution of data of different categories, and effectively improve the accuracy of image recognition.
Claims
1. A semi-supervised image recognition method based on adaptive contrastive learning, characterized in that: The method comprises: The collected image dataset is divided into labeled samples and unlabeled samples. Weak data enhancement is performed on labeled samples to obtain weakly enhanced labeled samples, and weak data enhancement is performed on unlabeled samples to obtain weakly enhanced unlabeled samples. Strong data enhancement is performed twice on unlabeled samples to obtain strongly enhanced unlabeled samples I and strongly enhanced unlabeled samples II. Inputting the weakly enhanced labeled sample into a pre-trained feature encoder to obtain a feature prediction of the weakly enhanced labeled sample, and calculating a supervised loss function according to the feature prediction of the weakly enhanced labeled sample; Input the weakly enhanced unlabeled samples, the strongly enhanced unlabeled samples I and the strongly enhanced unlabeled samples II into the pre-trained feature encoder respectively, obtain the feature prediction of the weakly enhanced unlabeled samples, the feature prediction and feature embedding of the strongly enhanced unlabeled samples I, and the feature embedding of the strongly enhanced unlabeled samples II, and calculate the adaptive threshold according to the feature prediction of the weakly enhanced labeled samples and the feature prediction of the weakly enhanced unlabeled samples; Compare the weakly enhanced unlabeled sample feature prediction with the adaptive threshold, and if the weakly enhanced unlabeled sample feature prediction is greater than or equal to the adaptive threshold, calculate the unsupervised loss function according to the weakly enhanced unlabeled sample feature prediction and the strongly enhanced unlabeled sample I feature prediction, and use the class-aware matrix to process the weakly enhanced unlabeled sample feature prediction whose confidence is greater than or equal to the adaptive threshold, combine the strongly enhanced unlabeled sample I feature prediction and feature embedding and the strongly enhanced unlabeled sample II feature embedding, and calculate the class-aware loss function; If the feature prediction of the weakly enhanced unlabeled sample is lower than the adaptive threshold, the weakly enhanced unlabeled sample whose feature prediction is lower than the adaptive threshold is placed in the distance perception module for processing to obtain the distance perception loss function; The supervised loss function, unsupervised loss function, class-aware loss function, and distance-aware loss function are added together to obtain a complete total loss function, the total loss function is used to train a machine learning model, and the machine learning model is applied to recognize an input image.
2. The semi-supervised image recognition method based on adaptive contrastive learning according to claim 1, characterized in that: The weak data enhancement processing for the labeled samples is specifically performed by using a random cropping algorithm; the weak data enhancement processing for the unlabeled samples is specifically performed by using a random horizontal flipping algorithm; the strong data enhancement processing for the unlabeled samples is performed twice, both times using Randaugment algorithm.
3. The semi-supervised image recognition method based on adaptive contrastive learning according to claim 1, characterized in that: The supervised loss function is calculated based on the weakly enhanced labeled sample feature prediction, specifically: , , , in, is a supervised loss function, is the pseudo label loss function and is the soft label loss function, represents the batch size of labeled samples, represents the cross entropy loss, Indicates weakly enhanced labeled sample feature prediction, represents the i-th weakly enhanced labeled sample, represents the label of the i-th weakly enhanced labeled sample, represents the category-based soft label, represents the output of the feature encoder, softmax is the activation function.
4. The semi-supervised image recognition method based on adaptive contrastive learning according to claim 1, characterized in that: The adaptive threshold specifically includes: , , , In the formula, represents the t-th iteration adaptive threshold, c represents the c-th class label, represents the local threshold containing labeled samples, represents the global threshold composed of the average confidence of unlabeled samples, represents the number of c-th class label samples, represents the number of weakly enhanced labeled samples, Indicates the indicator symbol, Indicates weakly enhanced labeled sample feature prediction, Indicated by The pseudo-label obtained by conversion, C represents the number of label classes, represents the batch size of unlabeled samples, represents the momentum decay of the exponential moving average, Represents weakly enhanced unlabeled sample feature prediction.
5. The semi-supervised image recognition method based on adaptive contrastive learning according to claim 1, characterized in that: The unsupervised loss function is calculated based on the weakly enhanced unlabeled sample feature prediction and the strongly enhanced unlabeled sample I feature prediction, and the specific package is: , , , in, is the unsupervised loss function, represents the batch size of unlabeled data, Indicates the indicator symbol, represents weakly enhanced unlabeled sample feature prediction, represents the adaptive threshold, represents the cross entropy loss, Indicated by The pseudo-label obtained by conversion, represents the strongly enhanced unlabeled sample I feature prediction, and They represent weakly enhanced unlabeled samples and strongly enhanced unlabeled samples I respectively.
6. The semi-supervised image recognition method based on adaptive contrastive learning according to claim 1, characterized in that: The method uses the category perception matrix to process the feature prediction of the weakly enhanced unlabeled samples whose confidence is greater than or equal to the adaptive threshold, combines the feature prediction and feature embedding of the strongly enhanced unlabeled samples I and the feature embedding of the strongly enhanced unlabeled samples II, and calculates the category perception loss function, specifically including: First, obtain the affinity matrix S of the strongly enhanced unlabeled sample II feature embedding, the elements of the affinity matrix S are: , in, , Indicates that two products of the same batch use the same RandAugment The algorithm parameters are square normalized low-dimensional embedding of strongly enhanced samples, N represents the batch size, represents the temperature coefficient; Then, the class-aware contrast matrix M is used for calculation, and the elements of the class-aware contrast matrix M are expressed as follows: , in, , It is expressed as the maximum value of the feature prediction of the weakly enhanced unlabeled sample and the maximum value of the feature prediction of the strongly enhanced unlabeled sample I. represents the adaptive threshold; Finally, the class perception loss function is calculated according to the affinity matrix S and the class perception contrast matrix M: The class-aware loss function is specifically: , , in, represents the cross entropy loss, N represents the batch size, represents the view index of other images of the same category with the same confidence level, represents the temperature coefficient, Indicates the strongly enhanced unlabeled sample I and samples have the same confidence level as other samples embedding, Indicates the first The samples were subjected to another RandAugment The feature embedding obtained after strong enhancement of the algorithm parameters, Indicates an indicator symbol.
7. The semi-supervised image recognition method based on adaptive contrastive learning according to claim 1, characterized in that: The weakly enhanced unlabeled samples whose feature predictions are lower than the adaptive threshold are placed in the distance perception module for processing, specifically: First, the feature encoder is used to extract the features of weakly enhanced unlabeled samples to predict the features of samples below the adaptive threshold, randomly select the central feature, and calculate the distance between the central feature and other features; Secondly, according to the distance between the samples and the feature prediction of the weakly enhanced labeled samples, positive and negative weights are assigned to the features of the samples whose feature prediction of the weakly enhanced unlabeled samples is lower than the adaptive threshold; Finally, calculate the distance-aware loss function , , in, represents the model parameters, , Represent the positive weight and negative weight of the feature respectively, represents the selected central feature prediction, , represents the weakly enhanced labeled sample feature prediction and the weakly enhanced unlabeled sample feature prediction, Represents a hyperparameter.
8. The semi-supervised image recognition method based on adaptive contrastive learning according to claim 7, characterized in that: The inter-distance is calculated as follows: , in, and Represent the central feature and other features respectively.
9. The semi-supervised image recognition method based on adaptive contrastive learning according to claim 7, characterized in that: The new positive weight and negative weight are assigned to the features of the weakly enhanced unlabeled sample feature predictions that are lower than the adaptive threshold sample as follows: , in, , represents the new feature positive weight and feature negative weight, Indicates weakly enhanced labeled sample feature prediction, represents the distance between the features, means sorting positive weights in reverse order.
Citation Information
Patent Citations
Method for carrying out semi-supervised learning by using self-adaptive double thresholds
CN114842294A
Machine learning method for multi-agent online evolution learning
CN114898124A