Image classification method and electronic device

CN115965828BActive Publication Date: 2026-09-08HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110529942.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-14
Publication Date
2026-09-08
Estimated Expiration
2041-05-14

AI Technical Summary

Technical Problem

而对于SSL而言,只有少量的数据拥有类别的标签,分类效果较差

Benefits of technology

[0054] In the image classification method and electronic device provided in this application embodiment, feature extraction is performed on a supervised training set and an unsupervised test set by an encoder to obtain a first low-dimensional feature of the supervised training set in the hidden space and a second low-dimensional feature of the unsupervised test set in the hidden space; a central prototype vector for each category is obtained based on the first low-dimensional feature; the similarity between the second low-dimensional feature and the central prototype vector is obtained based on the central prototype vector and the second low-dimensional feature; positive samples are selected from the first low-dimensional features corresponding to the category with the highest similarity; and an image classification model is obtained by comparing and learning the positive samples with the unsupervised test set. This application embodiment introduces contrastive learning into the field of semi-supervised learning, enabling data classification with a small number of labels and achieving good classification results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115965828B_ABST
    Figure CN115965828B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a kind of image classification method and electronic equipment.The technical scheme provided in the embodiment of the present application is that the feature of supervised training set and unsupervised test set is extracted by encoder, the first low-dimensional feature of the supervised training set in hidden layer space and the second low-dimensional feature of the unsupervised test set in the hidden layer space are obtained;According to the first low-dimensional feature, the center prototype vector of each category is obtained;According to the center prototype vector and the second low-dimensional feature, the similarity of the second low-dimensional feature and the center prototype vector is obtained;According to the similarity, positive sample is selected out;By comparing learning between the positive sample and the unsupervised test set, an image classification model is obtained.The embodiment of the present application introduces contrast learning into the field of semi-supervised learning, which can classify a small amount of labeled data and achieve good classification effect.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] This application relates to the field of computer technology, and more particularly to an image classification method and electronic device. [Background Technology]

[0002] With the development of modern storage and hardware technologies, the amount of data available for training is becoming increasingly abundant. However, data labeling has always been a labor-intensive task. Taking classification tasks as an example, labeling all samples for each category would undoubtedly increase manual costs significantly.

[0003] Semi-supervised learning (SSL) has attracted increasing attention in recent years because it allows training networks with limited labeled data to improve model performance, while providing access to large amounts of unlabeled data. Traditional neural network-based image classification problems compare the network's predicted output with the true labels of samples, calculate the error between the two, backpropagate the error using the gradient of the error with respect to the network weights, update the network model's parameters, and repeat this process until the model converges. However, with SSL, only a small amount of data has class labels, resulting in poor classification performance. [Summary of the Invention]

[0004] In view of this, embodiments of this application provide an image classification method and an electronic device, which, by introducing contrastive learning into the field of semi-supervised learning, can classify data using a small number of labels and achieve good classification results.

[0005] In a first aspect, embodiments of this application provide an image classification method, the method comprising:

[0006] The encoder extracts features from the supervised training set and the unsupervised test set to obtain the first low-dimensional features of the supervised training set in the hidden space and the second low-dimensional features of the unsupervised test set in the hidden space.

[0007] The central prototype vector of each category is obtained based on the first low-dimensional feature;

[0008] The similarity between the second low-dimensional feature and the central prototype vector is obtained based on the central prototype vector and the second low-dimensional feature.

[0009] Positive samples are selected based on the similarity.

[0010] An image classification model is obtained by comparing the positive samples with the unsupervised test set.

[0011] In one possible implementation, the supervised training set includes a small amount of labeled data; the unsupervised test set includes unlabeled data.

[0012] In one possible implementation, obtaining the center prototype vector for each category based on the first low-dimensional feature specifically includes:

[0013] The first low-dimensional feature is expanded to include a variety of sample categories using a prototype fusion module to obtain a fusion training set.

[0014] The center prototype vector for each category is obtained by calculating the average value of the third low-dimensional feature of the hybrid training set in the low-dimensional space.

[0015] In one possible implementation, selecting positive samples based on the similarity specifically includes:

[0016] Positive samples are selected from the third low-dimensional features corresponding to the category with the highest similarity.

[0017] In one possible implementation, obtaining the similarity between the second low-dimensional feature and the central prototype vector based on the central prototype vector and the second low-dimensional feature specifically includes:

[0018] The similarity between the second low-dimensional feature and the central prototype vector is calculated by using a similarity calculation formula.

[0019] In one possible implementation, the similarity calculation formula includes:

[0020]

[0021] Among them, s i,j For the aforementioned similarity, z i Let z be the central prototype vector. j This is the second low-dimensional feature; or, z i For the second low-dimensional feature, z j The central prototype vector.

[0022] In one possible implementation, the step of comparing the positive samples with the unsupervised test set to obtain an image classification model specifically includes:

[0023] The positive samples are compared with the unsupervised test set by contrastive learning of the error function to obtain the image classification model.

[0024] In one possible implementation, the contrastive learning error function includes:

[0025]

[0026] in, To compare the learning error, k + For positive samples, k - For negative samples, s p For the similarity between the positive samples, s n The similarity between the positive and negative samples is given by m, where m is the discrimination boundary coefficient, γ = 1 / τ, τ is the temperature coefficient, and α is the similarity between the positive and negative samples. p These are adaptive coefficients.

[0027] On the other hand, embodiments of this application provide an electronic device, including a processor and a memory, wherein the memory is used to store a computer program, the computer program including program instructions, and when the processor executes the program instructions, the electronic device performs the following steps:

[0028] The encoder extracts features from the supervised training set and the unsupervised test set to obtain the first low-dimensional features of the supervised training set in the hidden space and the second low-dimensional features of the unsupervised test set in the hidden space.

[0029] The central prototype vector of each category is obtained based on the first low-dimensional feature;

[0030] The similarity between the second low-dimensional feature and the central prototype vector is obtained based on the central prototype vector and the second low-dimensional feature.

[0031] Positive samples are selected based on the similarity.

[0032] An image classification model is obtained by comparing the positive samples with the unsupervised test set.

[0033] In one possible implementation, the supervised training set includes a small amount of labeled data; the unsupervised test set includes unlabeled data.

[0034] In one possible implementation, when the processor executes the program instructions, the electronic device performs the following steps:

[0035] The step of obtaining the center prototype vector for each category based on the first low-dimensional feature specifically includes:

[0036] The first low-dimensional feature is expanded to include a variety of sample categories using a prototype fusion module to obtain a fusion training set.

[0037] The center prototype vector for each category is obtained by calculating the average value of the third low-dimensional feature of the hybrid training set in the low-dimensional space.

[0038] In one possible implementation, when the processor executes the program instructions, the electronic device performs the following steps:

[0039] The step of selecting positive samples based on the similarity specifically includes:

[0040] Positive samples are selected from the third low-dimensional features corresponding to the category with the highest similarity.

[0041] In one possible implementation, when the processor executes the program instructions, the electronic device performs the following steps:

[0042] The step of obtaining the similarity between the second low-dimensional feature and the central prototype vector based on the central prototype vector and the second low-dimensional feature specifically includes:

[0043] The similarity between the second low-dimensional feature and the central prototype vector is calculated by using a similarity calculation formula.

[0044] In one possible implementation, the similarity calculation formula includes:

[0045]

[0046] Among them, s i,j For the aforementioned similarity, z i Let z be the central prototype vector. j This is the second low-dimensional feature; or, z i For the second low-dimensional feature, z j The central prototype vector.

[0047] In one possible implementation, when the processor executes the program instructions, the electronic device performs the following steps:

[0048] The step of comparing and learning the positive samples with the unsupervised test set to obtain the image classification model specifically includes:

[0049] The positive samples are compared with the unsupervised test set by contrastive learning of the error function to obtain the image classification model.

[0050] In one possible implementation, the contrastive learning error function includes:

[0051]

[0052] in, To compare the learning error, k + For positive samples, k - For negative samples, s pFor the similarity between the positive samples, s n The similarity between the positive and negative samples is given by m, where m is the discrimination boundary coefficient, γ = 1 / τ, τ is the temperature coefficient, and α is the similarity between the positive and negative samples. p These are adaptive coefficients.

[0053] On the other hand, embodiments of this application provide a computer-readable storage medium storing a computer program, the computer program including program instructions that, when requested to be run by a computer, cause the computer to perform the method described above.

[0054] In the image classification method and electronic device provided in this application embodiment, feature extraction is performed on a supervised training set and an unsupervised test set by an encoder to obtain a first low-dimensional feature of the supervised training set in the hidden space and a second low-dimensional feature of the unsupervised test set in the hidden space; a central prototype vector for each category is obtained based on the first low-dimensional feature; the similarity between the second low-dimensional feature and the central prototype vector is obtained based on the central prototype vector and the second low-dimensional feature; positive samples are selected from the first low-dimensional features corresponding to the category with the highest similarity; and an image classification model is obtained by comparing and learning the positive samples with the unsupervised test set. This application embodiment introduces contrastive learning into the field of semi-supervised learning, enabling data classification with a small number of labels and achieving good classification results. [Attached Image Description]

[0055] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0056] Figure 1 This is a schematic diagram of a semi-supervised learning method based on consistency regularization.

[0057] Figure 2 This is a schematic diagram of a semi-supervised learning method based on pseudo-labels;

[0058] Figure 3 This is a schematic diagram of a semi-supervised learning method based on class-cooperative training;

[0059] Figure 4 This is a schematic diagram of an unsupervised method based on contrastive learning.

[0060] Figure 5 This is a schematic diagram of the process of a traditional semi-supervised learning method.

[0061] Figure 6 An architecture diagram of an image classification system provided in one embodiment of this application;

[0062] Figure 7 for Figure 6 A schematic diagram of a prototype hybrid module;

[0063] Figure 8 A flowchart illustrating an image classification method provided in one embodiment of this application;

[0064] Figure 9 for Figure 8 The flowchart shows the specific process of obtaining the central prototype vector of each category based on the first low-dimensional feature.

[0065] Figure 10 This is a schematic diagram illustrating the effect of the prototype hybrid module.

[0066] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

Detailed Implementation Methods

[0067] To better understand the technical solution of this application, the embodiments of this application will be described in detail below with reference to the accompanying drawings.

[0068] It should be understood that the described embodiments are merely some, not all, of the embodiments in this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.

[0069] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. The singular forms “a,” “the,” and “the” used in the embodiments of this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.

[0070] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0071] First, some of the terms used in the embodiments of this application will be explained to facilitate understanding by those skilled in the art.

[0072] 1. Convolutional Neural Network (CNN). A CNN is a type of feedforward neural network, typically composed of multiple convolutional layers, pooling layers, and fully connected layers. CNNs achieve weight sharing, requiring fewer parameters and significantly reducing network complexity.

[0073] 2. Cross Entropy. Cross entropy is an important concept in information theory, primarily used to measure the difference between two probability distributions. If p and q represent the true probability distribution and the false probability distribution, respectively, then the cross entropy can be expressed as:

[0074]

[0075] 3. Pseudo-labels. Pseudo-labels are a commonly used technique in semi-supervised learning. Specifically, it refers to using the model's predictions of the data as class labels for the next round of supervised learning.

[0076] 4. Contrastive Learning. Contrastive learning is a novel unsupervised learning method. Specifically, during model training, it involves bringing different augmented versions of the same sample closer together in terms of features while distancing them from other samples.

[0077] Secondly, the relevant technologies of the image classification method involved in the embodiments of this application will be explained so that those skilled in the art can understand them.

[0078] Related technology 1: Semi-supervised image classification based on consistency regularization.

[0079] The unifying idea of ​​consistency regularization is that, for the same input, even with a small disturbance, the model's predicted output should be the same. Semi-supervised learning methods based on consistency regularization, such as... Figure 1 As shown, for a given training data set, two augmented versions are generated through two different random data augmentations. These two augmented versions are then passed to the network model to be trained, yielding two predicted values. The difference between the two predicted values ​​is calculated; this difference is called the unsupervised error. If the training data consists of partially labeled training data, the error between the sample labels and the network predictions is calculated using the traditional method; this error is called the supervised error. The sum of the unsupervised and supervised errors is used as the total error to update the network parameters.

[0080] However, consistency regularization has certain limitations in practical applications because label error plays a significant role in the data training process. Therefore, semi-supervised image classification methods based on consistency regularization cannot achieve the desired results in extreme cases with few labeled data, such as when each category has only a few labeled images and the image features are complex, and the model lacks robustness.

[0081] Related technology 2: Semi-supervised learning method based on pseudo-labels.

[0082] like Figure 2 As shown, the semi-supervised learning method based on pseudo-labeling technology includes the following three steps:

[0083] Step 1: Train the model using labeled data.

[0084] Step 2: Use the trained model to predict the labels of the unlabeled data and generate pseudo-labeled data.

[0085] Step 3: Retrain the model using both the pseudo-labeled dataset and the labeled dataset to generate the final model.

[0086] Finally, the final model is used to make a final prediction on the test data, and the process is iterated until the final model converges.

[0087] Pseudo-labeling is a simple semi-supervised learning method. Essentially, it's a supervised learning process where most of the training labels are replaced with the model's predictions from the previous training iteration. This simple approach can help alleviate overfitting on datasets with few labels, but relying solely on this method cannot achieve high performance; the model's classification performance remains low.

[0088] Related technology 3: Semi-supervised learning method based on collaborative training.

[0089] Collaborative training is a divergence-based approach that assumes each data point can be classified from different perspectives, resulting in different classifiers. These classifiers, trained from different perspectives, are then used to classify unlabeled samples. Finally, the most reliable unlabeled samples are selected and added to the training set. Figure 3 As shown. Because these classifiers are trained from different perspectives, they can complement each other, thereby improving classification accuracy, just as different perspectives can lead to a better understanding of things. When specifically applying class co-training, the data must have two sufficiently redundant views that satisfy conditional independence. "Sufficient" means that each view contains enough information to generate the optimal learner; for any one view, the other is "redundant." Furthermore, these two views are conditionally independent for class labels.

[0090] Although semi-supervised learning methods based on co-training have a solid theoretical foundation, they face some challenges in practical applications. For example, when using multiple models to co-train a network, it is difficult to ensure that different networks have different perspectives; furthermore, excessive repetition can cause the two networks to become consistent during training, which not only fails to achieve good results but also wastes computational resources and results in parameter redundancy.

[0091] Related Technology 4: Unsupervised learning methods based on contrastive learning.

[0092] Unlike other traditional semi-supervised methods, contrastive learning-based unsupervised learning methods do not require any labels on the data during training; they are trained solely on the data itself. For example... Figure 4 As shown, for a training data x, it is augmented twice, namely data augmentation 1 and data augmentation 2. Then, in a batch of training data, only the data itself and its augmented version are treated as belonging to the same category, while the remaining data are treated as belonging to different categories for training. This can result in a good pre-trained weight model.

[0093] Contrastive learning classifies each category by treating only the current sample and its various augmented versions as positive samples. However, for large datasets, each category contains a large number of samples with rich features, and data augmentation alone is insufficient to simulate the diversity of features within a sample category.

[0094] Traditional SSL's general process is based on pseudo-labels and consistency regularization. The core idea of ​​traditional SSL is to train a model using limited labeled data and predict pseudo-labels for unlabeled samples. For example... Figure 5 As shown, in the general workflow of traditional SSL, images with high-confidence predictions are selected for retraining, using a soft-labeled prediction distribution. To avoid homogenization in SSL, i.e., using the same samples for prediction and retraining, data augmentation is widely used and has proven particularly effective when combined with consistency regularization, as consistency regularization can compensate for differences between different augmentations of the same sample. In SSL, network optimization is typically achieved by minimizing the cross-entropy loss between the prediction and target distributions as part of fully supervised learning. However, some researchers have pointed out that this cross-entropy loss is not robust to noisy labels, which is unavoidable in semi-supervised learning. This is especially true for large-scale datasets like ImageNet, where the limited number of labeled samples cannot well represent a specific category, resulting in limited performance gains for cross-entropy-based semi-supervised methods.

[0095] Further findings reveal that the goal of unsupervised learning is to learn feature representations without labeled samples. Recent advances in unsupervised representation learning have yielded significant progress, particularly in contrastive learning. In contrastive learning, each image and its enhancements are simply treated as a separate class; features between different image transformations are brought closer together, while all other instances are treated as negations and pushed apart. Contrastive learning-based methods have been shown to outperform supervised counterparts on some downstream tasks, such as classification and detection. However, due to the lack of labeled priors, contrastive learning-based methods still suffer from slow convergence and conflicting optimization objectives, limiting their generalization performance.

[0096] In summary, the image classification methods in related technologies perform poorly for SSL data with only a small amount of data having category labels.

[0097] To address the aforementioned technical problems, embodiments of this application provide an image classification method and an electronic device.

[0098] See Figure 6 , Figure 6 This is an architecture diagram of an image classification system provided in an embodiment of this application.

[0099] like Figure 6 As shown, in the positive sample selection stage of this application embodiment, the supervised training set consisting of a small amount of labeled data and the unsupervised test set consisting of unlabeled data are first passed through an encoder to obtain the first low-dimensional feature of the supervised training set in the hidden space and the second low-dimensional feature of the unsupervised test set in the hidden space. The distance from each second low-dimensional feature to each category center is calculated by the similarity formula, thereby selecting the category that is closest to the second low-dimensional feature and selecting samples from this category as positive samples.

[0100] Figure 7 for Figure 6 A schematic diagram of the prototype hybrid module. In the prototype hybrid module, the robustness of calculating class centers is also enhanced using the nearest neighbor approach. This is achieved by mixing the label data with several second-lowest-dimensional features closest to the class to obtain a hybrid training set. For example... Figure 7 As shown, the prototype fusion module makes the computation of the class space more robust by mixing the K nearest second low-dimensional features of each class in the hidden space with the supervised data during the training process to obtain a fusion training set. The prototype fusion module can make the sample centers calculated with a small number of labels more representative and closer to the true class centers, thereby improving the accuracy of selecting positive samples.

[0101] In comparative learning, this application embodiment introduces adaptive coefficients and boundary coefficients to enable the original positive samples and the positive samples selected by nearest neighbors to be trained together, thereby further improving performance.

[0102] like Figure 6 As shown, this embodiment of the application selects semantically similar positive samples for unlabeled data by calculating the similarity between a small amount of labeled data and unlabeled data in the hidden layer space. On the basis of the original contrastive learning, it adds some prior information of labeled data, enabling the network to aggregate samples of the same category on the basis of the original transformation invariance, and providing better pre-training weights.

[0103] Based on the above Figure 6 The provided architecture diagram illustrates an image classification method in this application embodiment. Figure 8 This is a flowchart illustrating an image classification method provided in one embodiment of this application. Figure 8 As shown, the method includes:

[0104] Step 102: Extract features from the supervised training set and the unsupervised test set using the encoder to obtain the first low-dimensional features of the supervised training set in the hidden space and the second low-dimensional features of the unsupervised test set in the hidden space.

[0105] In this embodiment of the application, the supervised training set includes a small amount of labeled data; the unsupervised test set includes unlabeled data.

[0106] For example, a supervised training set may include 1% or 10% of labeled data.

[0107] In this embodiment of the application, a supervised training set consisting of a small amount of labeled data and an unsupervised test set consisting of unlabeled data are first passed through an encoder to obtain their representations in the hidden layer space, namely the first low-dimensional feature and the second low-dimensional feature.

[0108] Step 104: Obtain the center prototype vector for each category based on the first low-dimensional feature.

[0109] The central prototype vector represents the category center of the corresponding category.

[0110] In the embodiments of this application, such as Figure 9 As shown, step 104 specifically includes:

[0111] Step 1042: Expand the sample categories of the first low-dimensional feature through the prototype mixing module to obtain a mixed training set.

[0112] In this embodiment, due to the scarcity of label data, the category centers calculated from the limited data for each category are not representative. Therefore, this embodiment adds a prototype mixing module to update the category centers online by mixing nearest neighbor samples based on the model features during training.

[0113] In this embodiment, the prototype mixing module makes the computation of the class space more robust by mixing the second low-dimensional features closest to each class center in the hidden space with the supervised training set during the training process.

[0114] like Figure 10 As shown, the prototype fusion module makes the sample centers calculated using a small amount of labeled data more representative, closer to the true class centers, and improves the accuracy of selecting positive samples. In the prototype fusion module, the robustness of calculating class centers is also enhanced using the nearest neighbor approach. This is achieved by fusion of the original labeled data with several second-lower-dimensional features closest to the class center.

[0115] Step 1044: Calculate the average value of the third low-dimensional feature of the mixed training set in the low-dimensional space to obtain the center prototype vector of each category.

[0116] Step 106: Obtain the similarity between the second low-dimensional feature and the central prototype vector based on the central prototype vector and the second low-dimensional feature.

[0117] In this embodiment of the application, step 106 specifically includes: calculating the similarity between the central prototype vector and the second low-dimensional feature by using the similarity calculation formula.

[0118] In this embodiment of the application, the similarity calculation formula includes:

[0119]

[0120] Among them, s i,j For similarity, z i z is the central prototype vector. j It is the second low-dimensional feature; or, z i As the second low-dimensional feature, z j The central prototype vector.

[0121] Step 108: Select positive samples based on similarity.

[0122] In this embodiment of the application, step 108 specifically includes: selecting positive samples from the third low-dimensional features corresponding to the category with the highest similarity.

[0123] In this embodiment of the application, the distance from each unlabeled data point to the center of each category is obtained by similarity calculation, thereby selecting the category that is closest to the unsupervised test sample, and selecting the sample as the positive sample from the third low-dimensional feature corresponding to this category.

[0124] Step 110: By comparing and learning positive samples with the unsupervised test set, an image classification model is obtained.

[0125] It should be noted that the model is iteratively updated by comparing positive samples with the unsupervised test set to obtain the trained model weights, and finally fine-tuned with some supervised data to obtain the final image classification model.

[0126] In this embodiment of the application, step 110 specifically includes: comparing and learning positive samples with unsupervised test sets through a contrastive learning error function to obtain an image classification model.

[0127] In this embodiment of the application, the original contrastive learning error function is:

[0128]

[0129] Where q is a randomly selected sample, and k + Let q be the positive sample, and k be the positive sample. - Let q be the negative sample, and τ be the temperature coefficient.

[0130] Use s p s represents the similarity between positive samples n To represent the similarity between positive and negative samples, we add a discrimination boundary coefficient m and let γ = 1 / τ, transforming the original contrastive learning error function to obtain:

[0131]

[0132] Generalization to multiple positive samples is as follows:

[0133]

[0134] The similarity between the second low-dimensional feature and the nearest class center is used as the adaptive coefficient α. p The final contrastive learning error function includes:

[0135]

[0136] in, To compare the learning error, k + For positive samples, k - For negative samples, s p For the similarity between positive samples, s nThe similarity between positive and negative samples is given by m, where m is the discrimination boundary coefficient, γ = 1 / τ, τ is the temperature coefficient, and α is the coefficient of mass. p These are adaptive coefficients.

[0137] The embodiments of this application redesign and derive an error function applicable to semi-supervised contrastive learning, and introduce a discrimination boundary coefficient m to better distinguish between positive and negative samples.

[0138] This application proposes a semi-supervised learning strategy based on contrastive learning. On one hand, by calculating the similarity between a small amount of labeled data and the unlabeled data of the training samples in the hidden space, semantically similar positive samples are selected for the unlabeled data of the training samples. This adds prior information from the labeled data to the original contrastive learning, enabling the network to aggregate samples of the same class while maintaining its transformation invariance, thus providing better pre-training weights. In the hidden space represented by the moving average, the cosine similarity between the second low-dimensional features of the unlabeled data and the centers of all classes is calculated and sorted according to similarity. Then, several third low-dimensional features are selected as positive samples from the most similar classes in the hidden space. For example, K third low-dimensional features are selected as positive samples from the most similar classes in the hidden space, as shown in Table 1. Experimental comparisons show that compared to the training situation of contrastive learning on unlabeled data itself, i.e., the training situation where K is 0 in Table 1, the semi-supervised learning training based on contrastive learning in this application can bring significant accuracy improvements. Preferably, K=3 is set in practical applications.

[0139] Table 1. Classification accuracy for comparative learning with different numbers of positive samples.

[0140] Top-1 accuracy (%) 55.3 61.8 63.1 62.8

[0141] On the other hand, the embodiments of this application add an adaptive coefficient α based on the training state to the contrastive learning error function. p The gradient magnitude of the contrastive learning error is determined based on the similarity between the selected positive sample and the second low-dimensional feature, which can improve the robustness of the model. This embodiment of the invention uses an adaptive coefficient α. p (w / α p The results of the contrastive learning obtained do not use the adaptive coefficient α. p (w / oα p The results of the contrastive learning obtained from the baseline method (MoCo v2), i.e., the contrastive learning results obtained in the case of a single positive sample, are compared. As shown in Table 2, the adaptive coefficient α is used... p Compared to contrastive learning itself, and multiple positive samples without the use of adaptive coefficient α... pIn all cases, there are significant improvements in model performance. Here, top-1 and top-5 represent two metrics for measuring classification accuracy: top-1 represents the probability that the class with the highest confidence in the classification output is the correct class, and top-5 represents the probability that the correct class is among the five classes with the highest confidence.

[0142] Table 2 Adaptive coefficients α p Impact on classification accuracy of contrastive learning

[0143]

[0144] To further illustrate the superiority of the image classification method provided in this application, the ImageNet dataset is used as an example. The ImageNet dataset is a large, publicly available dataset widely used in industry and academia, containing 1,281,167 training images and 50,000 validation images. In this application, the training data from the ImageNet dataset is randomly divided into portions containing only 1% or 10% of the labeled data, and the image classification model proposed in this application is used to train the model based on these portions. As shown in Table 3, compared with mainstream methods in academia and industry, it can be seen that the image classification model provided in this application surpasses all previous methods and achieves the best results.

[0145] Table 3. ImageNet Classification Results Statistics

[0146]

[0147]

[0148] In summary, unlike traditional semi-supervised methods and models trained using supervised cross-entropy and consistency with unsupervised data, the image classification method provided in this application employs contrastive learning to train the feature extractor. It extends the previous one-to-one contrastive learning error function to the case of multiple positive samples, using a specific nearest neighbor strategy to select positive samples for model training. Furthermore, this application proposes a prototype hybrid module to smooth out the error introduced by using very few labels to calculate class centers. Additionally, based on the model training state, this application proposes adaptive coefficients that adapt to the training state to smooth out the impact of erroneous samples during the selection of positive samples.

[0149] In the image classification method provided in this application embodiment, feature extraction is performed on the supervised training set and the unsupervised test set by an encoder to obtain the first low-dimensional features of the supervised training set in the hidden space and the second low-dimensional features of the unsupervised test set in the hidden space. A center prototype vector for each category is obtained based on the first low-dimensional features. The similarity between the second low-dimensional features and the center prototype vector is obtained based on the center prototype vector and the second low-dimensional features. Positive samples are selected from the first low-dimensional features corresponding to the category with the highest similarity. An image classification model is obtained by comparing and learning with the positive samples and the unsupervised test set. This application embodiment introduces contrastive learning into the field of semi-supervised learning, enabling data classification with a small number of labels and achieving good classification results.

[0150] The above text combined Figures 8 to 10 The image classification method provided in the embodiments of this application is described in detail below. Figure 11 This document describes in detail the device embodiments of this application. It should be understood that the electronic devices in the embodiments of this application can execute the various methods described in the foregoing embodiments of this application. That is, the specific working processes of the various products described below can be referred to the corresponding processes in the foregoing method embodiments.

[0151] This application provides an electronic device, which can be a terminal device or a circuit device built into the terminal device. This electronic device can be used to perform the functions / steps described in the method embodiments above.

[0152] Figure 11 This is a schematic diagram of the structure of an electronic device 300 provided in an embodiment of this application. The electronic device 300 may include a processor 310, an external memory interface 320, an internal memory 321, a universal serial bus (USB) interface 330, a charging management module 340, a power management module 341, a battery 342, antenna 1, antenna 2, a mobile communication module 350, a wireless communication module 360, an audio module 370, a speaker 370A, a receiver 370B, a microphone 370C, a headphone jack 370D, a sensor module 380, buttons 390, a motor 391, an indicator 392, a camera 393, a display screen 394, and a subscriber identification module (SIM) card interface 395, etc. The sensor module 380 may include a pressure sensor 380A, a gyroscope sensor 380B, a barometric pressure sensor 380C, a magnetic sensor 380D, an accelerometer sensor 380E, a distance sensor 380F, a proximity light sensor 380G, a fingerprint sensor 380H, a temperature sensor 380J, a touch sensor 380K, an ambient light sensor 380L, a bone conduction sensor 380M, etc.

[0153] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 300. In other embodiments of this application, the electronic device 300 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0154] Processor 310 may include one or more processing units, such as application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU). These different processing units may be independent devices or integrated into one or more processors.

[0155] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.

[0156] The processor 310 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 310 is a cache memory. This memory can store instructions or data that the processor 310 has just used or that are used repeatedly. If the processor 310 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 310, and thus improves the efficiency of the system.

[0157] In some embodiments, the processor 310 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0158] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 310 may include multiple I2C buses. The processor 310 can couple to the touch sensor 380K, charger, flash, camera 393, etc., through different I2C bus interfaces. For example, the processor 310 can couple to the touch sensor 380K through the I2C interface, enabling the processor 310 and the touch sensor 380K to communicate through the I2C bus interface, thereby realizing the touch function of the electronic device 300.

[0159] The I2S interface can be used for audio communication. In some embodiments, the processor 310 may include multiple I2S buses. The processor 310 can be coupled to the audio module 370 via the I2S bus to enable communication between the processor 310 and the audio module 370. In some embodiments, the audio module 370 can transmit audio signals to the wireless communication module 360 ​​via the I2S interface to enable the function of answering phone calls through a Bluetooth headset.

[0160] The PCM interface can also be used for audio communication, sampling, quantizing, and encoding analog signals. In some embodiments, the audio module 370 and the wireless communication module 360 ​​can be coupled via the PCM bus interface. In some embodiments, the audio module 370 can also transmit audio signals to the wireless communication module 360 ​​via the PCM interface, enabling the function of answering phone calls through a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

[0161] The UART interface is a universal serial data bus used for asynchronous communication. This bus can be a bidirectional communication bus. It converts the data to be transmitted between serial and parallel communication. In some embodiments, the UART interface is typically used to connect the processor 310 and the wireless communication module 360. For example, the processor 310 communicates with the Bluetooth module in the wireless communication module 360 ​​via the UART interface to implement Bluetooth functionality. In some embodiments, the audio module 370 can transmit audio signals to the wireless communication module 360 ​​via the UART interface to enable music playback through Bluetooth headphones.

[0162] The MIPI interface can be used to connect the processor 310 to peripheral devices such as the display screen 394 and the camera 393. The MIPI interface includes a camera serial interface (CSI) and a display serial interface (DSI). In some embodiments, the processor 310 and the camera 393 communicate via the CSI interface to enable the electronic device 300 to capture images. The processor 310 and the display screen 394 communicate via the DSI interface to enable the electronic device 300 to display images.

[0163] The GPIO interface can be configured via software. It can be configured as a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 310 to a camera 393, a display screen 394, a wireless communication module 360, an audio module 370, a sensor module 380, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

[0164] USB port 330 is a USB standard compliant interface, which can be a Mini USB port, Micro USB port, USB Type-C port, etc. USB port 330 can be used to connect a charger to charge electronic device 300, and can also be used for data transfer between electronic device 300 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices, such as AR devices.

[0165] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 300. In other embodiments of this application, the electronic device 300 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0166] The charging management module 340 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 340 receives charging input from the wired charger via a USB interface 330. In some wireless charging embodiments, the charging management module 340 receives wireless charging input via the wireless charging coil of the electronic device 300. While charging the battery 342, the charging management module 340 can also supply power to the electronic device via the power management module 341.

[0167] The power management module 341 connects the battery 342, the charging management module 340, and the processor 310. The power management module 341 receives input from the battery 342 and / or the charging management module 340, providing power to the processor 310, internal memory 321, display screen 394, camera 393, and wireless communication module 360. The power management module 341 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 341 may be located within the processor 310. In other embodiments, the power management module 341 and the charging management module 340 may be housed in the same device.

[0168] The wireless communication function of electronic device 300 can be realized through antenna 1, antenna 2, mobile communication module 350, wireless communication module 360, modem processor and baseband processor, etc.

[0169] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 300 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.

[0170] The mobile communication module 350 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 300. The mobile communication module 350 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 350 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 350 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 350 may be housed in the processor 310. In some embodiments, at least some functional modules of the mobile communication module 350 and at least some modules of the processor 310 may be housed in the same device.

[0171] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through an audio device (not limited to speaker 370A, receiver 370B, etc.) or displays images or videos through a display screen 394. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 310 and may be housed in the same device as the mobile communication module 350 or other functional modules.

[0172] The wireless communication module 360 ​​can provide solutions for wireless communication applications on the electronic device 300, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 360 ​​can be one or more devices integrating at least one communication processing module. The wireless communication module 360 ​​receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signal, and sends the processed signal to processor 310. The wireless communication module 360 ​​can also receive signals to be transmitted from processor 310, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.

[0173] In some embodiments, antenna 1 of electronic device 300 is coupled to mobile communication module 350, and antenna 2 is coupled to wireless communication module 360, enabling electronic device 300 to communicate with networks and other devices via wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).

[0174] Electronic device 300 implements display functions through a GPU, a display screen 394, and an application processor. The GPU is a microprocessor for image processing, connecting the display screen 394 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 310 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0175] Display screen 394 is used to display images, videos, etc. Display screen 394 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 300 may include one or N displays 394, where N is a positive integer greater than 1.

[0176] Electronic device 300 can achieve shooting function through ISP, camera 393, video codec, GPU, display 394 and application processor.

[0177] The ISP (Image Signal Processor) is used to process data fed back from the camera 393. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing, transforming it into an image visible to the naked eye. The ISP can also perform algorithmic optimization of image noise, brightness, and skin tone. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 393.

[0178] Camera 393 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard RGB, YUV, or other formats. In some embodiments, the electronic device 300 may include one or N cameras 393, where N is a positive integer greater than 1.

[0179] A digital signal processor (DSP) is used to process digital signals. Besides digital image signals, it can also process other digital signals. For example, when the electronic device 300 is selecting a frequency, the DSP is used to perform Fourier transforms on the frequency energy.

[0180] Video codecs are used to compress or decompress digital video. Electronic device 300 may support one or more video codecs. Thus, electronic device 300 can play or record video in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0181] An NPU (Neural Processing Unit) is a computational processor for neural networks (NNs). By borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can rapidly process input information and continuously learn on its own. NPUs can enable intelligent cognitive applications in electronic devices, such as image recognition, facial recognition, speech recognition, and text understanding.

[0182] The external storage interface 320 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 300. The external memory card communicates with the processor 310 through the external storage interface 320 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.

[0183] Internal memory 321 can be used to store computer executable program code, which includes instructions. Internal memory 321 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 300 (such as audio data, phonebook, etc.). Furthermore, internal memory 321 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. Processor 310 executes various functional applications and data processing of electronic device 300 by running instructions stored in internal memory 321 and / or instructions stored in memory located in the processor.

[0184] Electronic device 300 can implement audio functions such as music playback and recording through audio module 370, speaker 370A, receiver 370B, microphone 370C, headphone jack 370D, and application processor.

[0185] The audio module 370 is used to convert digital audio information into analog audio signal output, and also to convert analog audio input into digital audio signal. The audio module 370 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 370 may be located in the processor 310, or some functional modules of the audio module 370 may be located in the processor 310.

[0186] The speaker 370A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. Electronic device 300 can listen to music or make hands-free calls through the speaker 370A.

[0187] The receiver 370B, also known as the "earpiece," is used to convert audio electrical signals into sound signals. When the electronic device 300 answers a telephone call or voice message, the receiver 370B can be brought close to the listener's ear to hear the voice.

[0188] Microphone 370C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 370C, inputting the sound signal into microphone 370C. Electronic device 300 may have at least one microphone 370C. In some embodiments, electronic device 300 may have two microphones 370C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, electronic device 300 may have three, four, or more microphones 370C, which can collect sound signals, reduce noise, identify the sound source, and perform directional recording, etc.

[0189] The 370D headphone jack is used to connect wired headphones. The 370D headphone jack can be a USB 330 interface or a 3.5mm Open Mobile Terminal Platform (OMTP) standard interface, a CTIA (Cellular Telecommunications Industry Association of the USA) standard interface.

[0190] Pressure sensor 380A is used to sense pressure signals and can convert the pressure signals into electrical signals. In some embodiments, pressure sensor 380A may be disposed on display screen 394.

[0191] There are many types of pressure sensors, such as resistive pressure sensors, inductive pressure sensors, and capacitive pressure sensors. A capacitive pressure sensor may consist of at least two parallel plates with conductive material. When force is applied to the pressure sensor 380A, the capacitance between the electrodes changes. The electronic device 300 determines the pressure intensity based on the change in capacitance. When a touch operation is applied to the display screen 394, the electronic device 300 detects the intensity of the touch operation based on the pressure sensor 380A. The electronic device 300 can also calculate the touch position based on the detection signal from the pressure sensor 380A. In some embodiments, touch operations applied to the same touch position but with different touch operation intensities can correspond to different operation commands. For example, when a touch operation with an intensity less than a first pressure threshold is applied to the SMS application icon, a command to view an SMS message is executed. When a touch operation with an intensity greater than or equal to the first pressure threshold is applied to the SMS application icon, a command to create a new SMS message is executed.

[0192] The gyroscope sensor 380B can be used to determine the motion attitude of the electronic device 300. In some embodiments, the gyroscope sensor 380B can determine the angular velocity of the electronic device 300 around three axes (i.e., the x, y, and z axes). The gyroscope sensor 380B can be used for image stabilization. For example, when the shutter is pressed, the gyroscope sensor 380B detects the angle of the electronic device 300's shake, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to counteract the shake of the electronic device 300 through reverse movement, thus achieving image stabilization. The gyroscope sensor 380B can also be used in navigation and motion-sensing game scenarios.

[0193] The barometric pressure sensor 380C is used to measure air pressure. In some embodiments, the electronic device 300 calculates altitude using the air pressure value measured by the barometric pressure sensor 380C to assist in positioning and navigation.

[0194] The magnetic sensor 380D includes a Hall sensor. The electronic device 300 can use the magnetic sensor 380D to detect the opening and closing of the flip cover. In some embodiments, when the electronic device 300 is a flip phone, the electronic device 300 can detect the opening and closing of the flip cover using the magnetic sensor 380D. Then, based on the detected opening and closing state of the cover or the flip cover, features such as automatic flip unlocking can be set.

[0195] The accelerometer 380E can detect the magnitude of acceleration of an electronic device 300 in various directions (typically three axes). When the electronic device 300 is stationary, it can detect the magnitude and direction of gravity. It can also be used to identify the posture of the electronic device, and can be applied to applications such as screen orientation switching and pedometers.

[0196] A distance sensor 380F is used to measure distance. Electronic device 300 can measure distance via infrared or laser. In some embodiments, during a shooting scene, electronic device 300 can utilize the distance sensor 380F to measure distance for rapid focusing.

[0197] The proximity sensor 380G may include, for example, a light-emitting diode (LED) and a light detector, such as a photodiode. The LED may be an infrared LED. The electronic device 300 emits infrared light outward through the LED. The electronic device 300 uses the photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that an object is near the electronic device 300. When insufficient reflected light is detected, the electronic device 300 can determine that no object is near the electronic device 300. The electronic device 300 can use the proximity sensor 380G to detect when a user holds the electronic device 300 close to their ear for a call, so as to automatically turn off the screen to save power. The proximity sensor 380G can also be used in holster mode and pocket mode for automatic unlocking and locking of the screen.

[0198] The ambient light sensor 380L is used to sense the brightness of ambient light. The electronic device 300 can adaptively adjust the brightness of its display screen 394 based on the sensed ambient light level. The ambient light sensor 380L can also be used to automatically adjust the white balance when taking photos. The ambient light sensor 380L can also work in conjunction with the proximity sensor 380G to detect whether the electronic device 300 is in a pocket, preventing accidental touches.

[0199] The fingerprint sensor 380H is used to collect fingerprints. The electronic device 300 can utilize the characteristics of the collected fingerprints to achieve fingerprint unlocking, accessing application locks, taking photos with fingerprints, answering calls with fingerprints, etc.

[0200] Temperature sensor 380J is used to detect temperature. In some embodiments, electronic device 300 uses the temperature detected by temperature sensor 380J to execute a temperature handling strategy. For example, when the temperature reported by temperature sensor 380J exceeds a threshold, electronic device 300 performs thermal protection by reducing the performance of a processor located near temperature sensor 380J to reduce power consumption. In other embodiments, when the temperature is below another threshold, electronic device 300 heats battery 342 to prevent abnormal shutdown of electronic device 300 due to low temperature. In still other embodiments, when the temperature is below yet another threshold, electronic device 300 boosts the output voltage of battery 342 to prevent abnormal shutdown due to low temperature.

[0201] Touch sensor 380K, also known as a "touch device," can be located on display screen 394. The touch sensor 380K and display screen 394 together form a touchscreen, also known as a "touchscreen." Touch sensor 380K detects touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 394. In other embodiments, touch sensor 380K may also be located on the surface of electronic device 300, in a different position than display screen 394.

[0202] The bone conduction sensor 380M can acquire vibration signals. In some embodiments, the bone conduction sensor 380M can acquire vibration signals from the vibrating bone segments of the human vocal cords. The bone conduction sensor 380M can also contact the human pulse to receive blood pressure signals. In some embodiments, the bone conduction sensor 380M can also be incorporated into headphones to form bone conduction headphones. The audio module 370 can parse the voice signals from the vibrating bone segments of the vocal cords acquired by the bone conduction sensor 380M to realize voice functionality. The application processor can parse heart rate information from the blood pressure signals acquired by the bone conduction sensor 380M to realize heart rate detection functionality.

[0203] Buttons 390 include a power button, volume buttons, etc. Buttons 390 can be mechanical buttons or touch-sensitive buttons. Electronic device 300 can receive button input and generate key signal inputs related to user settings and function control of electronic device 300.

[0204] Motor 391 can generate vibration alerts. Motor 391 can be used for incoming call vibration alerts or for touch vibration feedback. For example, different vibration feedback effects can be corresponding to touch operations applied to different applications (such as taking photos, playing audio, etc.). Motor 391 can also correspond to different vibration feedback effects for touch operations applied to different areas of the display screen 394. Different application scenarios (such as time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also be customized.

[0205] Indicator 392 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.

[0206] The SIM card interface 395 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 395 to make contact with and separate from the electronic device 300. The electronic device 300 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 395 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 395 simultaneously. The multiple cards can be of the same or different types. The SIM card interface 395 is also compatible with different types of SIM cards. The SIM card interface 395 is also compatible with external memory cards. The electronic device 300 interacts with the network through the SIM card to realize functions such as calls and data communication. In some embodiments, the electronic device 300 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 300 and cannot be separated from the electronic device 300.

[0207] This application provides a computer-readable storage medium storing instructions that, when executed on a terminal device, cause the terminal device to perform the functions / steps described in the above method embodiments.

[0208] This application also provides a computer program product containing instructions that, when run on a computer or any at least one processor, cause the computer to perform the functions / steps described in the above method embodiments.

[0209] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent the existence of A alone, the simultaneous existence of A and B, or the existence of B alone. A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects have an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, and c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

[0210] Those skilled in the art will recognize that the units and algorithm steps described in the embodiments disclosed herein can be implemented using electronic hardware, computer software, or a combination of electronic hardware and software. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0211] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0212] In the several embodiments provided in this application, any function, if implemented as a software functional unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0213] The above description is merely a specific embodiment of this application. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application. The protection scope of this application should be determined by the protection scope of the claims.

Claims

1. An image classification method, characterized in that, The method includes: The encoder extracts features from the supervised training set and the unsupervised test set to obtain the first low-dimensional features of the supervised training set in the hidden space and the second low-dimensional features of the unsupervised test set in the hidden space. The central prototype vector of each category is obtained based on the first low-dimensional feature; The similarity between the second low-dimensional feature and the central prototype vector is obtained based on the central prototype vector and the second low-dimensional feature. Positive samples are selected based on the similarity. An image classification model is obtained by comparing the positive samples with the unsupervised test set. The step of obtaining the center prototype vector for each category based on the first low-dimensional feature specifically includes: The first low-dimensional feature is expanded to include a variety of sample categories using a prototype fusion module to obtain a fusion training set. The center prototype vector of each category is obtained by calculating the average value of the third low-dimensional feature of the hybrid training set in the low-dimensional space. The step of selecting positive samples based on the similarity specifically includes: Positive samples are selected from the third low-dimensional features corresponding to the category with the highest similarity.

2. The method according to claim 1, characterized in that, The supervised training set includes a small amount of labeled data; the unsupervised test set includes unlabeled data.

3. The method according to claim 1, characterized in that, The step of obtaining the similarity between the second low-dimensional feature and the central prototype vector based on the central prototype vector and the second low-dimensional feature specifically includes: The similarity between the second low-dimensional feature and the central prototype vector is calculated by using a similarity calculation formula.

4. The method according to claim 3, characterized in that, The similarity calculation formula includes: ; in, For the aforementioned similarity, The central prototype vector, This is the second low-dimensional feature; or, This is the second low-dimensional feature. The central prototype vector.

5. The method according to claim 1, characterized in that, The step of comparing and learning the positive samples with the unsupervised test set to obtain the image classification model specifically includes: The positive samples are compared with the unsupervised test set by contrastive learning of the error function to obtain the image classification model.

6. The method according to claim 5, characterized in that, The contrastive learning error function includes: ; in, To compare learning errors, As a positive sample, For negative samples, The similarity between the positive samples, The similarity between the positive sample and the negative sample. To determine the boundary coefficients, , For temperature coefficient, These are adaptive coefficients that adapt to the model's training state.

7. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory is used to store a computer program, the computer program including program instructions, which, when executed by the processor, cause the electronic device to perform the following steps: The encoder extracts features from the supervised training set and the unsupervised test set to obtain the first low-dimensional features of the supervised training set in the hidden space and the second low-dimensional features of the unsupervised test set in the hidden space. The central prototype vector of each category is obtained based on the first low-dimensional feature; The similarity between the second low-dimensional feature and the central prototype vector is obtained based on the central prototype vector and the second low-dimensional feature. Positive samples are selected based on the similarity. An image classification model is obtained by comparing the positive samples with the unsupervised test set. The step of obtaining the center prototype vector for each category based on the first low-dimensional feature specifically includes: The first low-dimensional feature is expanded to include a variety of sample categories using a prototype fusion module to obtain a fusion training set. The center prototype vector of each category is obtained by calculating the average value of the third low-dimensional feature of the hybrid training set in the low-dimensional space. The step of selecting positive samples based on the similarity specifically includes: Positive samples are selected from the third low-dimensional features corresponding to the category with the highest similarity.

8. The electronic device according to claim 7, characterized in that, The supervised training set includes a small amount of labeled data; the unsupervised test set includes unlabeled data.

9. The electronic device according to claim 7, characterized in that, When the processor executes the program instructions, the electronic device performs the following steps: The step of obtaining the similarity between the second low-dimensional feature and the central prototype vector based on the central prototype vector and the second low-dimensional feature specifically includes: The similarity between the second low-dimensional feature and the central prototype vector is calculated by using a similarity calculation formula.

10. The electronic device according to claim 8, characterized in that, The similarity calculation formula includes: ; in, For the aforementioned similarity, The central prototype vector, This is the second low-dimensional feature; or, This is the second low-dimensional feature. The central prototype vector.

11. The electronic device according to claim 7, characterized in that, When the processor executes the program instructions, the electronic device performs the following steps: The step of comparing and learning the positive samples with the unsupervised test set to obtain the image classification model specifically includes: The positive samples are compared with the unsupervised test set by contrastive learning of the error function to obtain the image classification model.

12. The electronic device according to claim 11, characterized in that, The contrastive learning error function includes: ; in, To compare learning errors, As a positive sample, For negative samples, The similarity between the positive samples, The similarity between the positive sample and the negative sample. To determine the boundary coefficients, , For temperature coefficient, These are adaptive coefficients that adapt to the model's training state.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program including program instructions that, when requested to be run by a computer, cause the computer to perform the method as described in any one of claims 1-6.