Deep metric learning-based positive and negative unmarked image classification method and system
Adjusting positive sample images and generating enhanced views of unlabeled images through the depth measurement learning framework, solving the problem of incorrect samples introduced in the prior art, achieving high-quality feature representation and accurate positive and negative image classification.
Patent Information
- Application Number
- CN202510745717.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2045-06-05
AI Technical Summary
The existing positive and negative unlabeled image classification methods are prone to introduce wrong samples when using PU data to train binary classifiers, resulting in poor classification results and the inability to accurately distinguish positive and negative samples.
Using the depth metric learning framework, the marked positive sample images are adjusted in the deep feature space through the depth metric learning model, enhanced views of unlabeled images, and aligned semantic similarity in the representation space, output related feature representations, and trained the binary classifier with these features.
It effectively avoids error accumulation of wrong samples, learns high-quality feature representations, and can more reliably screen out negative samples for classifier training, improving the classification accuracy of positive and negative unlabeled images.
Smart Images

Figure CN120580501A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of sample classification, and in particular to a positive and negative unlabeled image classification method and system based on deep metric learning. Background Art
[0002] Learning binary classifiers from positive and unlabeled (PU) image data has received extensive attention in the past few decades.
[0003] This framework is particularly well-suited for real-world scenarios where positive examples of user interest are scarce, while the majority of data is unlabeled. For example, in an e-commerce product recommendation system, a user may be interested only in products in the "luxury mobile phone" category, while the vast majority of products on the platform belong to unrelated categories such as home appliances and clothing. Due to the prohibitive cost of comprehensive labeling, the system typically only labels as positive only those samples that clearly match the user's preferences, while most other samples remain unlabeled. A similar situation exists in medical image analysis: doctors may be more interested in detecting malignant tumors, while a large amount of image data contains benign lesions or normal tissue. While common pathologies are relatively easy to observe, obtaining labeled data for rare pathologies or specialized diagnostic tasks is still resource-intensive and technically challenging. In these scenarios, the goal is to use PU data to train a binary classifier that can reliably determine whether an unseen sample belongs to the target domain.
[0004] Given the importance of these applications, a variety of PU learning methods have been proposed in academia. Inspired by the successful application of deep learning in various fields, recent PU learning research has gradually shifted to selecting reliable negative samples or resolving label ambiguity problems by learning discriminative deep features. These methods mainly focus on two closely related tasks: (1) learning discriminative features from identified reliable negative samples or disambiguated unlabeled samples; (2) selecting reliable negative samples through heuristic methods based on the learned representation. However, existing heuristic methods inevitably introduce erroneous samples. Using data with introduced erroneous samples to train a binary classifier will result in poor classification performance of the trained binary classifier and an inability to accurately classify samples. Summary of the Invention
[0005] The purpose of the present invention is to address the deficiencies of the above-mentioned prior art and provide a positive and negative unlabeled image classification method and system based on deep metric learning to solve the problems in the prior art.
[0006] The present invention specifically provides the following technical solutions: A method for positive and negative unlabeled image classification based on deep metric learning, comprising: Obtain labeled positive sample images and unlabeled images; the positive sample images are images that match the user's target category in product recommendations, and the unlabeled images include positive sample images and images that are not the user's target category; The labeled positive sample images and unlabeled images are input into the deep metric learning model. The labeled positive sample images are adjusted in the deep feature space through positive center metric learning to minimize the distance between the labeled positive sample images and the centers of the positive sample images. The enhanced views of the unlabeled images are then aligned with the unlabeled images in the representation space to minimize the distance. This captures the semantic similarity between different views and outputs relevant feature representations with positive and negative discrimination in all sample images. Calculating the dissimilarity between each sample image and the center of the positive sample image using the relevant feature representation, sorting all sample images in ascending order of the dissimilarity, and sequentially selecting sample images that are multiple times the number of positive sample images from all sorted sample images as reliable negative samples; The relevant feature representation is taken as input, and the labeled positive sample images and reliable negative samples are used as supervision signals to train a binary classifier. The trained binary classifier is used to classify the positive and negative unlabeled images to be detected.
[0007] Preferably, the deep metric learning model includes two encoders based on ResNet-18, where the main encoder Used to perform positive center metric learning, auxiliary encoder Used to perform consistent alignment metric learning.
[0008] Preferably, the positive sample image is adjusted in the deep feature space by positive center metric learning to minimize the distance between the positive sample image and the center of the positive sample image, specifically: Minimize the difference between each labeled positive sample image and the center of the positive sample image The negative cosine similarity between them is used to obtain the positive center metric loss, which minimizes the distance between the positive sample image and the center of the labeled positive sample image. The specific expression is: ; ; in, is the positive center metric loss, MP is the set of positive samples marked in the current batch, x is the positive sample image, For the input positive sample image x, pass through the main encoder The feature representation obtained after encoding, θ is the parameter of the main encoder, and φ is the parameter of the auxiliary encoder.
[0009] Preferably, the aligning of the enhanced view of the unlabeled image with the unlabeled image in the representation space by minimizing the distance is specifically performed as follows: Based on the negative cosine similarity between the original view representation generated by the main encoder and the enhanced view representation generated by the auxiliary encoder, the self-consistency metric loss is obtained. The specific expression is: ; in, is the self-consistency metric loss, M U is the set of unlabeled samples in the current batch, Input positive sample image x Through auxiliary encoder Feature representation obtained after encoding; Based on the self-consistency metric loss, the unlabeled image and the corresponding augmented view are aligned in the representation space to minimize the distance.
[0010] Preferably, after outputting the relevant feature representations with positive and negative discrimination in all sample images, the method further includes: Get the overall loss function of the deep metric learning model. The specific expression is: ; To minimize overall losses As the target, update the main encoder by stochastic gradient descent or its variants Parameters ; Through the main encoder parameters Exponential moving average updates the auxiliary encoder Parameters , the specific expression is: ; Among them, opt represents the optimizer, η is the learning rate, is the momentum coefficient of EMA; By updating parameters, the optimal deep metric learning model is obtained, and the output of relevant feature representation is re-performed through the optimal deep metric learning model.
[0011] Preferably, the dissimilarity between each sample image and the center of the positive sample image is calculated using the relevant feature representation, all sample images are sorted in ascending order of the dissimilarity, and sample images that are multiple times the number of positive sample images are sequentially selected from all sorted sample images as reliable negative samples. The specific expression is: ; ; in, is the dissimilarity, is a reliable negative sample.
[0012] Preferably, the relevant feature representation is used as input, and the labeled positive sample images and reliable negative samples are used as supervision signals to train the binary classifier. The specific expression is: ; in, is the trained binary classifier, is the weight parameter of the classifier, is the bias, is the constraint parameter, are the relevant features output by the main encoder.
[0013] The present invention provides a positive and negative unlabeled image classification system based on deep metric learning, comprising: An image acquisition module is used to acquire labeled positive sample images and unlabeled images; the positive sample images are images that meet the user's target category in product recommendations, and the unlabeled images include positive sample images and images that are not the user's target category; The model output module is used to input the labeled positive sample images and unlabeled images into the deep metric learning model, adjust the labeled positive sample images in the deep feature space through positive center metric learning, minimize the distance between the labeled positive sample images and the centers of the positive sample images, generate enhanced views of the unlabeled images, align the enhanced views of the unlabeled images with the unlabeled images in the representation space to minimize the distance, capture the semantic similarity between different views, and output relevant feature representations with positive and negative discrimination in all sample images; a negative sample acquisition module, configured to calculate the dissimilarity between each sample image and the center of the positive sample image using the relevant feature representation, sort all sample images in ascending order of the dissimilarity, and sequentially select sample images that are multiple times the number of positive sample images from all sorted sample images as reliable negative samples; The training module is used to take the relevant feature representation as input, use the labeled positive sample images and reliable negative samples as supervision signals to train a binary classifier, and classify the positive and negative unlabeled images to be detected through the trained binary classifier.
[0014] The present invention provides a computer device, comprising a memory and a processor, wherein a program is stored in the memory, and when the program is executed by the processor, the processor performs the steps of the above-mentioned method for positive and negative unlabeled image classification based on deep metric learning.
[0015] The present invention provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-mentioned method for positive and negative unlabeled image classification based on deep metric learning.
[0016] Compared with the prior art, the present invention has the following significant advantages: The present invention adopts a deep metric learning framework to learn discriminative representations by directly optimizing the relationship between samples in the deep feature space, thereby avoiding dependence on heuristic negative sample selection, and by simultaneously minimizing two metric distances, namely the distance between the positive sample image and the center of the positive sample image, and the distance between the unlabeled image and the enhanced view of the unlabeled image in the representation space, it effectively utilizes the supervisory information of the positive sample and the structural information of the unlabeled sample, and can learn high-quality feature representations that are discriminative for positive and negative samples, and effectively prevent the error accumulation and propagation of erroneous samples in the representation learning process. Based on the learned high-quality feature representation, negative samples can be more reliably screened out for subsequent classifier training, as well as accurate classification of positive and negative unlabeled images. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 This is a schematic diagram of the DML framework in the present invention; Figure 2 Graph showing the training process of the classifier in the present invention; Figure 3 This is a t-SNE visualization of the representations learned by different methods in this invention; green dots represent positive samples (including positive samples from labeled and unlabeled data), blue dots represent negative samples (from unlabeled data), and in the DML-PU visualization, red dots represent reliable negative samples that it has screened out; Figure 3 (a)~ Figure 3 (c) are the distribution alignment methods Dist-PU diagrams of three datasets: CIFAR-10, MNIST, and EuroSAT; Figure 4 t-SNE visualization of the representations learned by different methods in the present invention; Figure 4 (a)~ Figure 4 (c) are LaGAM graphs of the gradient-aware mining method based on contrastive meta-learning for three datasets: CIFAR-10, MNIST, and EuroSAT; Figure 5 t-SNE visualization of the representations learned by different methods in the present invention; Figure 5 (a)~ Figure 5 (c) are the DML-PU graphs of the deep metric learning method for three datasets: CIFAR-10, MNIST, and EuroSAT; Figure 6 This is a flowchart of a positive and negative unlabeled image classification method based on deep metric learning in the present invention. DETAILED DESCRIPTION
[0018] The following is a clear and complete description of the technical solutions of the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0019] In the past few decades, PU learning has been widely studied and has led to the development of many methods. Its development process can be roughly divided into two stages:
[0020] Phase 1: Early PU learning methods primarily relied on manually defined, fixed metric functions to screen reliable negative samples. However, these methods were mostly limited to processing structured data (such as text documents) and had limited effectiveness and generalization capabilities when faced with complex, unstructured data such as images.
[0021] Phase II: With the tremendous success of deep learning in various fields, recent PU learning research has shifted to using deep neural networks to learn discriminative feature representations, and based on this, to perform negative sample screening or disambiguation of unlabeled samples. Specifically, current research focuses on two closely related goals: (1) using screened reliable negative samples or disambiguated unlabeled samples to learn discriminative data representations; (2) based on the learned representations, using heuristic methods to further screen reliable negative samples.
[0022] However, these heuristic-based methods inevitably introduce error accumulation and propagation during representation learning and sample screening, ultimately resulting in overall performance significantly lagging behind fully supervised learning methods. Although recent studies have attempted to introduce self-supervised learning or contrastive learning techniques into PU learning to improve the quality of feature representation, these methods still rely on the reliability of initially screened negative samples or disambiguated categories.
[0023] The core goal of deep metric learning is to construct a representation space (embedding space) through nonlinear transformations so that the geometric distance between samples can accurately reflect their semantic relationships—that is, semantically similar samples are clustered into tight clusters in space, while semantically dissimilar samples are effectively pulled apart. This method has demonstrated excellent results in multiple computer vision tasks, including face recognition, cross-modal retrieval, object classification, and data clustering. The foundation of deep metric learning lies in the design of effective metric loss functions, such as contrastive loss, triplet loss, ranked list loss, and angular loss. However, these classic loss functions typically rely on negative samples or fully labeled datasets for training, and therefore their direct application is greatly limited in PU data scenarios where only positive and unlabeled samples are present.
[0024] In the context of positive and negative unlabeled (PU) metric learning, the main challenge lies in the lack of supervisory information provided by negative samples. Traditional metric learning methods rely heavily on negative samples or fully labeled data during training. In contrast, the work of [1] focuses on deep metric learning in the PU context, aiming to effectively train using only labeled positive and unlabeled samples, without relying on any pre-labeled or filtered negative samples.
[0025] The core task of PU learning for image data is to develop a binary classifier , the classifier only uses a set of labeled positive sample images and a set of unlabeled images Conduct training, such as Figure 2 As shown in Figure 2, the ultimate goal is to accurately identify images belonging to a specific target category. It consists of two parts:
[0026] : Contains positive sample images that are determined to belong to the target category.
[0027] : Contains unlabeled images, which contain both positive samples belonging to the target category and negative samples that do not belong to the target category, but these negative samples are not explicitly labeled.
[0028] The fundamental challenge of PU learning stems from the unlabeled dataset The mixed nature of the image and the lack of negative sample labels greatly increase the difficulty of the classification task. The goal is to build a robust two-class classification model that can accurately determine whether an unseen image belongs to the target positive class.
[0029] The main challenges in learning effective representations from PU image data are: (1) the number of labeled positive samples is usually extremely scarce; (2) there is a complete lack of labeled negative samples. To address these challenges, a deep metric learning (DML) framework was introduced, which is specifically designed for PU learning in the image domain and can learn on both labeled positive samples and unlabeled samples. Figure 1 As shown in Figure 2, the DML framework consists of two complementary learning tasks: positive-centered metric learning and consistency-aligned metric learning. Its goal is to effectively capture the semantic similarity between positive samples while maintaining the inherent semantic similarity and consistency of each sample, thereby enriching the similarity information that can be used in subsequent classification tasks.
[0030] Specifically, the image features are mapped into a representation space where similar images are close to each other and dissimilar images are separated. The DML representation learning module trains its main encoder by using a learning loss calculated using the cosine distance . This loss function aims to minimize Deduced positive sample center and positive samples in the representation space In addition, it also ensures that the self-anchor Alignment with the corresponding representation. and are all trainable; however, the auxiliary mapping parameters By using a momentum-based update mechanism as To stabilize the training, the stop-gradient ("sg") operation is used to limit the flow gradient.
[0031] Network Architecture: The DML architecture consists of two encoders based on ResNet-18: the main encoder Used to perform positive center metric learning, auxiliary encoder Used to perform consistent alignment metric learning. During training, the parameters and It is worth noting that the feature dimensions of the two encoder outputs are the same.
[0032] Network Update: Master Encoder Responsible for extracting image features, its parameters are updated through the back-propagation algorithm, the goal is to minimize the metric loss calculated for the labeled positive samples and single samples. The robustness of the model is enhanced by contrast supervision, and its parameters are obtained by the main encoder parameters This framework of collaborative work between the main and auxiliary encoders can effectively improve the overall generalization ability of the model.
[0033] Forward propagation model: Given a batch of input images, DML first applies the data augmentation function to generate an augmented view for each image. Then, the original view and the augmented view are input to the main encoder respectively. and auxiliary encoder , produces the corresponding output representation and , both representations are in the same representation space.
[0034] Training Objective: DML performs two parallel metric learning tasks: one focuses on known positive samples, and the other processes unlabeled data, learning from its own positive (augmented) view as the target. For ease of discussion, these two tasks are referred to as positive-centered metric learning and self-consistency metric learning, respectively. The overall goal is to effectively capture the semantic similarity between positive samples while ensuring that the inherent semantic similarity and consistency of each sample are preserved in the representation space, thereby providing richer similarity information for subsequent tasks.
[0035] like Figure 6 As shown, in this embodiment, a positive and negative unlabeled image classification method based on deep metric learning includes the following steps: Step S1: Obtain labeled positive sample images and unlabeled images; positive sample images are images that meet the user's target category in product recommendation, and unlabeled images include positive sample images and images that are not user target categories.
[0036] Step S2: Input the labeled positive sample image and the unlabeled image into the deep metric learning model, adjust the labeled positive sample image in the deep feature space through positive center metric learning, minimize the distance between the labeled positive sample image and the center of the positive sample image, and generate an enhanced view of the unlabeled image. Align the enhanced view of the unlabeled image with the unlabeled image in the representation space with minimized distance, capture the semantic similarity between different views, and output relevant feature representations with positive and negative discrimination in all sample images.
[0037] The deep metric learning model includes two encoders based on ResNet-18, where the main encoder Used to perform positive center metric learning, auxiliary encoder Used to perform consistent alignment metric learning.
[0038] Aims to bring the labeled target positive samples closer to their center points in the deep feature space. Initialized to the mean of the positive samples in the current batch and dynamically updated during training. Specifically, for each small batch , positive sample center is calculated as follows:
[0039] ; in, is the subset of labeled positive samples in the current batch M, Represents a sample Through the main encoder The obtained feature representation.
[0040] The labeled positive sample image is adjusted in the deep feature space through positive center metric learning to minimize the distance between the positive sample image and the center of the positive sample image. Specifically: Minimize the difference between each labeled positive sample image and the center of the positive sample image The negative cosine similarity between them is used to obtain the positive center metric loss, which minimizes the distance between the positive sample image and the center of the labeled positive sample image. The specific expression is: ; in, is the positive center metric loss, MP is the set of positive samples marked in the current batch, x is a positive sample image, θ is the parameter of the main encoder, and φ is the parameter of the auxiliary encoder.
[0041] The unlabeled image and its corresponding augmented view are aligned in the representation space to minimize the distance through self-consistent metric learning, specifically: The self-consistency metric loss is obtained by the negative cosine similarity between the original view representation produced by the main encoder and the enhanced view representation produced by the auxiliary encoder. The specific expression is: ; in, is the self-consistency metric loss, MU is the set of unlabeled samples in the current batch, Input positive sample image x Through auxiliary encoder The feature representation obtained after encoding; based on the self-consistency metric loss, the unlabeled image and the corresponding enhanced view are aligned in the representation space to minimize the distance.
[0042] After outputting the relevant feature representation, it also includes: Get the overall loss function of the deep metric learning model. The specific expression is: ; To minimize overall losses As the target, update the main encoder by stochastic gradient descent or its variants Parameters ; Through the main encoder parameters Exponential moving average updates the auxiliary encoder The parameter φ is expressed as follows: ; Among them, opt (optimizer) represents the optimizer, η is the learning rate, is the momentum coefficient of EMA; By updating parameters, the optimal deep metric learning model is obtained, and the output of relevant feature representation is re-performed through the optimal deep metric learning model.
[0043] Step S3: Using the relevant feature representation, calculate the dissimilarity between each sample image and the center of the positive sample image, sort all sample images in ascending order of dissimilarity, and sequentially select sample images from all sorted sample images that are multiples (in one embodiment, 3 times) of the number of positive sample images as reliable negative samples. The specific expression is:
[0044] ; ; in, is the dissimilarity, is a reliable negative sample.
[0045] Step S4: Take the relevant feature representation as input, use the labeled positive sample images and reliable negative samples as supervision signals to train a binary classifier, and use the trained binary classifier to classify the positive and negative unlabeled images to be detected.
[0046] The specific expression of the binary classifier is: ; in, is the trained binary classifier, is the weight parameter of the classifier, is the bias, is the constraint parameter, are the relevant features output by the main encoder.
[0047] The following is an explanation of the experimental setup: The performance of the DML-PU method was evaluated on five different datasets covering different image classification tasks: CIFAR-10: for classifying natural images of 10 categories, such as vehicles. MNIST: a foundational benchmark dataset for handwritten digit recognition. Fashion-MNIST (F-MNIST): a variant of MNIST containing grayscale images of 10 categories of clothing and accessories. PCAM: containing histopathological images for detecting metastatic cancer tissue in lymph node sections, representing a key application in medical diagnosis. EuroSAT: land cover classification using Sentinel-2 satellite imagery, supporting environmental monitoring and geospatial analysis. As shown in Table 1.
[0048] Table 1: Dataset summary Data configuration: For each multi-class dataset (CIFAR-10, MNIST, F-MNIST, EuroSAT), the class with class index 1 is designated as the positive class, and all other classes are considered negative classes. For the PCAM dataset, which is inherently binary, its original class definition is followed. During the training phase, a portion of samples from the positive class are randomly sampled as labeled positive samples. , the remaining positive samples are mixed with all negative samples to form an unlabeled dataset The specific sampling quantities are as follows:
[0049] The datasets CIFAR-10, MNIST, F-MNIST, and PCAM randomly select 2,000 samples from the positive class as EuroSAT: Randomly select 1,500 samples from the positive class as .
[0050] DML-PU is compared with a range of state-of-the-art PU learning methods, including: PAN (PU learning with class-conditional GANs), a PU learning method based on generative adversarial networks, constructs pseudo-negative samples using class-conditional generative adversarial networks (GANs). Robust-PU (Robust PU learning with curriculum-based adaptive weighting), a PU learning method with enhanced robustness, adopts a curriculum learning strategy with adaptive sample weighting. Self-PU (Self-training with confidence refinement), a self-training method, refines pseudo-labels through confidence-based self-training. P3MIX (Polarized Mixup for PU Learning), a method based on a polarized mixup enhancement strategy, uses polarized mixup enhancement to strengthen decision boundaries. Non-negative PU learning (uPU), a traditional PU method for unbiased risk estimation, achieves an unbiased risk estimator. Unbiased PU learning (nnPU), a PU method for non-negative risk estimation, achieves a non-negative risk estimator. Variational PU learning (VPU), an PU learning method, optimizes the variational evidence lower bound. LaGAM (Label-Aware Gradient-based Adversarial Mining), a gradient-aware mining method based on contrastive meta-learning, combines contrastive meta-learning and gradient-aware mining strategies. Dist-PU (Distribution-aligned PU learning), a distribution alignment method, aligns the distributions of positive and negative samples through KL divergence regularization.
[0051] For all comparison methods, we used the official source code released by the authors on GitHub to ensure fair comparison and reproducibility of the results. We also strictly adhered to their default hyperparameter settings, implementation details, and recommended training procedures.
[0052] Fully supervised baseline model: In addition, two fully supervised baseline models were trained as a performance ceiling reference. Each model contains the same ResNet-18 image encoder and a linear logistic regression classifier as the DML-PU. Both models use the Sigmoid activation function and binary cross-entropy loss for optimization, differing in the number of negative samples used during training:
[0053] Supervised-Part: Use the same number of labeled positive samples (i.e. ) labeled negative samples for training.
[0054] Supervised-All: Use all available labeled negative samples for training.
[0055] Evaluation Metrics: In PU learning, the primary goal is to accurately identify positive samples of interest to the user. Therefore, the F1 score (F1-Score), a widely used standard metric in the PU learning field, is used as the primary evaluation metric. To ensure the stability and reliability of the evaluation results, each method is independently run 10 times on each dataset. The final performance reported is the average F1 score and its standard deviation of these 10 runs. All models are evaluated on a reserved test set.
[0056] Experimental details: The DML-PU framework adopts a dual encoder architecture based on ResNet-18 (main encoder and auxiliary encoder The internal classifier is implemented as a logistic regression model with L2 regularization, acting on the encoder output representation. Before entering the classifier, the feature vector is L2 normalized to improve training stability and generalization ability.
[0057] In terms of optimization, AdamW optimizer is used and the learning rate is set to 5×10 −4 , the weight decay is 1×10 −5 , the momentum coefficient of EMA Set to 0.005.
[0058] To enhance the robustness of the model, standard data augmentation techniques were applied, including random cropping, random horizontal flipping, and other augmentations tailored to the characteristics of the dataset (such as brightness adjustment, random translation, vertical flipping, random erasing, etc.), ensuring that the input to the model is a diverse set of augmented views. All datasets were trained using a uniform mini-batch size of 256.
[0059] All experiments were implemented using the PyTorch framework and performed on a server equipped with an NVIDIA RTX 3090 GPU (24GB of video memory).
[0060] Table 2 shows the average F1 scores and standard deviations of all compared methods and the proposed DML-PU on five benchmark datasets.
[0061] Comparative analysis of DML-PU with state-of-the-art methods: Experimental results clearly demonstrate that DML-PU significantly outperforms all existing PU learning methods on all five datasets. On the relatively simple single-channel image datasets MNIST and F-MNIST, where most methods achieve high accuracy, DML-PU achieves the best performance, with F1 scores of 99.39% and 95.96%, respectively.
[0062] Table 2: Main results (F1 score, higher is better) On more challenging real-world datasets such as CIFAR-10, EuroSAT, and PCAM, the advantages of DML-PU are even more obvious. For example:
[0063] Compared with the recently better-performing Robust-PU, DML-PU improves the F1 scores on CIFAR-10, EuroSAT, and PCAM by approximately 23.19%, 7.16%, and 14.99%, respectively.
[0064] Compared to LaGAM, which also focuses on representation learning, DML-PU achieves significantly better performance on CIFAR-10, EuroSAT, and PCAM, reaching approximately 22.97%, 33.72%, and 22.87%, respectively. This demonstrates that the deep metric learning strategy employed by DML-PU, by directly optimizing sample relationships in the representation space, is more effective in PU scenarios than LaGAM's contrastive meta-learning and gradient mining strategies, particularly when dealing with complex and diversely distributed datasets, enabling better generalization.
[0065] Compared to Dist-PU, which uses KL divergence to align distributions, DML-PU achieves performance improvements of approximately 35.90%, 8.63%, and 8.82% on CIFAR-10, EuroSAT, and PCAM, respectively. This demonstrates that DML-PU's metric learning approach is more robust in capturing complex data structures and distinguishing between positive and negative samples.
[0066] Overall, these results strongly demonstrate the superiority of DML-PU in PU learning tasks, showcasing its ability to surpass existing state-of-the-art methods, especially on complex datasets that require higher model discrimination and generalization capabilities.
[0067] Performance analysis of DML-PU and fully supervised models: It can also be observed from Table 2 that the performance of the proposed DML-PU framework is very close to or even reaches the level of the fully supervised model on most datasets when only using some positive samples and unlabeled samples.
[0068] On the CIFAR-10, MNIST, F-MNIST, and EuroSAT datasets, DML-PU achieves an F1 score very close to that of the Supervised-All model trained with all negative samples, and even slightly exceeds the Supervised-Part model trained with only some negative samples on CIFAR-10 and EuroSAT.
[0069] It's particularly noteworthy that on the PCAM dataset, DML-PU's performance (76.35%) is not only close to that of Supervised-Part (76.90%), but also slightly lower than that of Supervised-All (80.24%). However, considering the difficulty of learning PU, this is still an excellent result. Supervised-Part's relatively weak performance may be due to the limited number of negative samples used, which limits the model's ability to learn discriminative features. While Supervised-All uses all negative samples, on a dataset like PCAM, which has a highly imbalanced class structure (positive samples far outnumber negative samples), excessive imbalance can negatively impact model training.
[0070] The key to DML-PU's ability to achieve performance approaching or even rivaling that of fully supervised models lies in its deep metric learning strategy, which effectively leverages information contained in unlabeled data to assist in representation learning. Furthermore, through carefully designed metric loss functions (positive center loss and self-consistency loss), it guides the model to learn compact yet discriminative feature representations, laying a solid foundation for subsequent classifier training. This demonstrates the DML-PU framework's effectiveness in balancing the use of limited labeled information with the abundance of unlabeled information, as well as its robustness across diverse datasets.
[0071] Visual analysis: like Figure 3 As shown, a visual analysis is performed: In order to more intuitively understand the quality of feature representations learned by different methods, a visual comparison is made of the image representations obtained after training by the gradient-aware mining method LaGAM based on contrastive meta-learning, the distribution alignment method Dist-PU, and the proposed deep metric learning method DML-PU. The high-dimensional feature embedding is projected into a two-dimensional space using the t-SNE dimensionality reduction technique and visualized on three benchmark datasets: CIFAR-10, MNIST, and EuroSAT. The results are shown in Figure 2. Figure 3 (a)~ Figure 3 (c) Figure 4 (a)~ Figure 4 (c) and Figure 5 (a)~ Figure 5 As shown in (c).
[0072] from Figure 3 The visualization results show that DML-PU effectively clusters all positive samples (green dots) within a compact region, while clearly distributing negative samples (blue dots) outside this region. The reliable negative samples (red dots) it selects are also mostly located far from the positive cluster. This demonstrates that the representations learned by DML-PU are highly discriminative. On the MNIST dataset, where categories are inherently easy to distinguish, all three methods demonstrate good discriminative performance, with clear separation between the positive and negative clusters.
[0073] However, if Figure 3 、 Figure 4 and Figure 5 As shown, DML-PU significantly outperforms LaGAM and Dist-PU on the more challenging CIFAR-10 and EuroSAT datasets. LaGAM (which relies on contrastive learning) and Dist-PU (which relies on prior assumptions about class classification) experience significant overlap and confusion between positive and negative sample clusters on these complex datasets, resulting in poor discrimination. In contrast, DML-PU directly optimizes the relationship between samples through deep metric learning, without relying on negative samples or strong prior assumptions. This allows for better generalization and more robust discrimination performance on complex datasets, learning purer and more compact representations of positive samples.
[0074] Ablation studies: In order to verify the effectiveness of each component in the DML-PU framework, a series of ablation experiments were conducted. The results of two learning tasks are:
[0075] We investigated the contribution of the two core metric learning tasks in DML-PU—positive-centered metric learning (PC) and self-consistency metric learning (SC)—to final classification performance. We denoted the approach using only the PC task as DML-PC and the approach using only the SC task as DML-SC, and compared them with the full DML-PU approach using both tasks. The results are shown in Table 3.
[0076] Table 3: Ablation results of two learning tasks (F1 score) As can be seen from Table 3, when using either DML-PC or DML-SC alone, the performance of the model is much lower than the full DML-PU method. This indicates that neither task alone can learn sufficiently discriminative representations for effective PU classification.
[0077] Interestingly, combining these two tasks to form DML-PU achieves performance far exceeding the sum of the performance of the two individual tasks. This strongly demonstrates that the two strategies of positive center metric learning and self-consistent metric learning are complementary and mutually reinforcing, and their combination can produce a synergistic effect, significantly improving the quality of representation learning and the final classification performance.
[0078] The effect of the number of reliable negative samples: In the second stage of DML-PU, the present invention uses the learned metric function to filter reliable negative samples from the unlabeled data to train the final classifier. The present invention analyzes the impact of the number of reliable negative samples used to train the internal classifier on the final performance.
[0079] This paper evaluates the configuration of selecting different proportions of negative samples: relative to the number of labeled positive samples The results are shown in Table 4.
[0080] Table 4: Impact of different numbers of reliable negative samples on performance (F1 score) Table 4 shows that DML-PU's performance remains very stable, with no significant fluctuations, under different ratios of reliable negative samples (1x, 3x, and 5x). This consistency demonstrates that the proposed method is robust to variations in the number of selected reliable negative samples. This indicates that the representation learned by DML-PU is sufficiently good that subsequent classifiers can effectively learn from reliable negative sample distributions of varying magnitudes without significantly impacting final performance. The default selection of 3x the number of negative samples is a relatively balanced choice.
[0081] The impact of reliable positive samples: The present invention also explores the use of the original labeled positive samples in training the final classifier. and the filtered reliable negative samples In addition, can we further use the learned metric function to extract unlabeled data? Identify some of the most reliable positive samples (i.e., those that are farthest from the center in the representation space) Very close unlabeled samples), and add them to the training of the classifier, such as Figure 2 The present invention conducted an experiment, selecting 200, 400, 600 and 800 samples with the highest confidence from the unlabeled data as additional “reliable positive samples” (denoted as RP200, RP400, RP600, RP800), and comparing them with and The results are shown in Table 5.
[0082] Table 5: Effect of adding reliable positive samples on classification performance (F1 score) From the results in Table 5, we can see that adding the screened reliable positive samples to the classifier training does not bring about a significant performance improvement, and in some cases even slightly degrades the performance. This shows that the original labeled positive samples Sufficient positive sample supervision information has been provided, and additional screening of positive samples from unlabeled data may introduce noise or uncertainty. Therefore, the default DML-PU method of the present invention (using only and training classifiers) is robust and efficient enough without relying on the extra step of filtering reliable positive samples from unlabeled data.
[0083] Extensive experimental results on multiple standard benchmark datasets demonstrate that DML-PU consistently and significantly outperforms various existing PU learning methods. More importantly, in most cases, DML-PU achieves F1 scores comparable to or even surpassing those of supervised models trained using fully labeled data. This fully demonstrates the effectiveness of the dual metric learning optimization strategy proposed in this paper. It not only improves the quality of feature learning but also provides a more reliable negative sample foundation for subsequent classifier training, ultimately leading to significant performance improvements and providing a powerful and effective new approach to solving PU learning problems in practical applications.
[0084] The present invention proposes a positive and negative unlabeled image classification system based on deep metric learning, which includes: an image acquisition module, a model output module, a negative sample acquisition module and a training module.
[0085] Among them, the image acquisition module is used to obtain labeled positive sample images and unlabeled images; positive sample images are images that meet the user's target category in product recommendation, and unlabeled images include positive sample images and images of non-user target categories; the model output module is used to input the labeled positive sample images and unlabeled images into the deep metric learning model, and adjust the labeled positive sample images in the deep feature space through positive center metric learning to minimize the distance between the labeled positive sample images and the center of the positive sample images, and generate an enhanced view of the unlabeled image, and align the enhanced view of the unlabeled image with the unlabeled image in the representation space to minimize the distance, capturing The semantic similarity between different views is used to output the relevant feature representation with positive and negative discrimination in all sample images; the negative sample acquisition module is used to use the relevant feature representation to calculate the dissimilarity between each sample image and the center of the positive sample image, sort all sample images in ascending order of dissimilarity, and select sample images that are multiple times the number of positive sample images from all sorted sample images in sequence as reliable negative samples; the training module is used to take the relevant feature representation as input, use the labeled positive sample images and reliable negative samples as supervision signals to train a binary classifier, and use the trained binary classifier to classify the positive and negative unlabeled images to be detected.
[0086] The present invention also provides a computer device, including a memory and a processor, wherein a program is stored in the memory, and when the program is executed by the processor, the processor performs the steps of a positive and negative unlabeled image classification method based on deep metric learning.
[0087] According to the disclosed embodiments, a computing device may communicate with one or more external devices (e.g., keyboards, pointing devices, Bluetooth communications, etc.), or any device (e.g., routers, modems, etc.) that enables a computing device to communicate with one or more other computing devices.
[0088] The present invention provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-mentioned method for classifying positive and negative unlabeled images based on deep metric learning.
[0089] The above content is a further detailed description of the present invention in combination with specific preferred embodiments. For those skilled in the art to which the present invention belongs, several simple deductions or replacements can be made without departing from the concept of the present invention, which should be regarded as falling within the scope of protection of the present invention.
Claims
1. A method for positive and negative unlabeled image classification based on deep metric learning, characterized in that: include: Obtain labeled positive sample images and unlabeled images; The positive sample images are images that match the user's target category in the product recommendation, and the unlabeled images include positive sample images and images that are not in the user's target category; The labeled positive sample images and unlabeled images are input into the deep metric learning model. The labeled positive sample images are adjusted in the deep feature space through positive center metric learning to minimize the distance between the labeled positive sample images and the centers of the positive sample images. The enhanced views of the unlabeled images are then aligned with the unlabeled images in the representation space to minimize the distance. This captures the semantic similarity between different views and outputs relevant feature representations with positive and negative discrimination in all sample images. Calculating the dissimilarity between each sample image and the center of the positive sample image using the relevant feature representation, sorting all sample images in ascending order of the dissimilarity, and sequentially selecting sample images that are multiple times the number of positive sample images from all sorted sample images as reliable negative samples; The relevant feature representation is taken as input, and the labeled positive sample images and reliable negative samples are used as supervision signals to train a binary classifier. The trained binary classifier is used to classify the positive and negative unlabeled images to be detected.
2. The method for positive and negative unlabeled image classification based on deep metric learning according to claim 1, wherein: The deep metric learning model includes two encoders based on ResNet-18, where the main encoder Used to perform positive center metric learning, auxiliary encoder Used to perform consistent alignment metric learning.
3. The method for positive and negative unlabeled image classification based on deep metric learning according to claim 2, characterized in that: The positive center metric learning is used to adjust the labeled positive sample image in the deep feature space to minimize the distance between the labeled positive sample image and the center of the positive sample image, specifically: Minimize the difference between each labeled positive sample image and the center of the positive sample image The negative cosine similarity between them is used to obtain the positive center metric loss, which minimizes the distance between the positive sample image and the center of the labeled positive sample image. The specific expression is: ; ; in, is the positive center metric loss, M P is the set of labeled positive samples in the current batch, x is a positive sample image, Input positive sample image x Through the main encoder The feature representation obtained after encoding, θ are the parameters of the main encoder, and φ are the parameters of the auxiliary encoder.
4. The method for positive and negative unlabeled image classification based on deep metric learning according to claim 3, wherein: The enhanced view of the unlabeled image is aligned with the unlabeled image in the representation space to minimize the distance, specifically: Based on the negative cosine similarity between the original view representation generated by the main encoder and the enhanced view representation generated by the auxiliary encoder, the self-consistency metric loss is obtained. The specific expression is: ; in, is the self-consistency metric loss, M U is the set of unlabeled samples in the current batch, Input positive sample image x Through auxiliary encoder Feature representation obtained after encoding; Based on the self-consistency metric loss, the unlabeled image and the corresponding augmented view are aligned in the representation space to minimize the distance.
5. The method for positive and negative unlabeled image classification based on deep metric learning according to claim 1, wherein: After outputting the relevant feature representations with positive and negative discrimination in all sample images, the method further includes: Get the overall loss function of the deep metric learning model. The specific expression is: ; To minimize overall losses As the target, update the main encoder by stochastic gradient descent or its variants Parameters ; Through the main encoder parameters Exponential moving average updates the auxiliary encoder Parameters , the specific expression is: ; Among them, opt represents the optimizer, η is the learning rate, is the momentum coefficient of EMA; By updating parameters, the optimal deep metric learning model is obtained, and the output of relevant feature representation is re-performed through the optimal deep metric learning model.
6. The method for positive and negative unlabeled image classification based on deep metric learning according to claim 3, characterized in that: Using the relevant feature representation, calculate the dissimilarity between each sample image and the center of the positive sample image, sort all sample images in ascending order of the dissimilarity, and select sample images that are multiple times the number of positive sample images from all sorted sample images in sequence as reliable negative samples. The specific expression is: ; ; in, is the dissimilarity, is a reliable negative sample.
7. The method for positive and negative unlabeled image classification based on deep metric learning according to claim 1, wherein: The relevant feature representation is used as input, and the labeled positive sample images and reliable negative samples are used as supervision signals to train the binary classifier. The specific expression is: ; in, is the trained binary classifier, is the weight parameter of the classifier, is the bias, is the constraint parameter, are the relevant features output by the main encoder.
8. A positive and negative unlabeled image classification system based on deep metric learning, characterized by: include: An image acquisition module is used to acquire labeled positive sample images and unlabeled images; the positive sample images are images that meet the user's target category in product recommendations, and the unlabeled images include positive sample images and images that are not the user's target category; The model output module is used to input the labeled positive sample images and unlabeled images into the deep metric learning model, adjust the labeled positive sample images in the deep feature space through positive center metric learning, minimize the distance between the labeled positive sample images and the centers of the positive sample images, generate enhanced views of the unlabeled images, align the enhanced views of the unlabeled images with the unlabeled images in the representation space to minimize the distance, capture the semantic similarity between different views, and output relevant feature representations with positive and negative discrimination in all sample images; a negative sample acquisition module, configured to calculate the dissimilarity between each sample image and the center of the positive sample image using the relevant feature representation, sort all sample images in ascending order of the dissimilarity, and sequentially select sample images that are multiple times the number of positive sample images from all sorted sample images as reliable negative samples; The training module is used to take the relevant feature representation as input, use the labeled positive sample images and reliable negative samples as supervision signals to train a binary classifier, and classify the positive and negative unlabeled images to be detected through the trained binary classifier.
9. A computer device, characterized in that: The invention comprises a memory and a processor, wherein a program is stored in the memory, and when the program is executed by the processor, the processor performs the steps of a positive and negative unlabeled image classification method based on deep metric learning as described in any one of claims 1 to 7.
10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of a method for classifying positive and negative unlabeled images based on deep metric learning according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Image sentiment classification and retrieval algorithm based on depth measurement learning
CN108427740A
Image retrieval method based on similarity preservation under deep metric learning
CN110851645A
Multi-model grouping fusion remote sensing image classification method based on metric learning
CN113807385A
Image classification method and system based on label propagation contrast semi-supervised learning
CN115410026A
Cited By
Fault diagnosis data enhancement method and device
CN121564493A
Fault diagnosis data augmentation method and apparatus
CN121564493B