A positive-negative unlabeled image classification method and system based on deep metric learning

By optimizing sample relationships through a deep metric learning framework, discriminative feature representations are generated, solving the problem of introducing erroneous samples in the classification of unlabeled positive and negative images in existing technologies, and achieving more efficient classification accuracy.

CN120580501BActive Publication Date: 2026-06-02NORTHWEST A & F UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NORTHWEST A & F UNIV
Filing Date
2025-06-05
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing methods for classifying unlabeled positive and negative images are prone to introducing erroneous samples when training binary classifiers using PU data, resulting in poor classification performance and an inability to accurately distinguish between positive and negative samples.

Method used

We employ a deep metric learning framework, utilizing positive center metric learning and consistency alignment metric learning to optimize the sample relationships in the deep feature space using labeled positive samples and unlabeled images, generating discriminative feature representations, and selecting reliable negative samples for training.

Benefits of technology

It effectively avoids the accumulation of errors from erroneous samples, learns high-quality feature representations, and can more reliably select negative samples for classifier training, thereby improving the classification accuracy of positive and negative unlabeled images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120580501B_ABST
    Figure CN120580501B_ABST
Patent Text Reader

Abstract

The application discloses a positive and negative unlabeled image classification method and system based on deep metric learning, relates to the technical field of sample classification, and comprises the following steps: obtaining labeled positive sample images and unlabeled images, and inputting a deep metric learning model; adjusting the labeled positive sample images in a deep feature space; minimizing the distance between the labeled positive sample images and the center of the positive sample images; aligning the unlabeled images and their corresponding enhanced views in a representation space through self-consistent metric learning; and outputting relevant feature representations; selecting sample images in a multiple ratio of the number of positive sample images as reliable negative samples by using the relevant feature representations; taking the relevant feature representations as input, using the positive sample images and the reliable negative samples as supervision signals to train a binary classifier, and classifying positive and negative unlabeled images to be detected. The application avoids the dependence on heuristic negative sample selection and can learn high-quality feature representations that can distinguish positive and negative samples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of sample classification technology, and in particular to a method and system for classifying positive and negative unlabeled images based on deep metric learning. Background Technology

[0002] Learning binary classifiers from positive-unlabeled (PU) image data has received widespread attention over the past few decades.

[0003] This framework is particularly suitable for real-world applications where positive samples of interest to users are scarce, while the majority of data remains unlabeled. For example, in e-commerce product recommendation systems, users might only be interested in "luxury mobile phones," while the vast majority of products on the platform belong to irrelevant categories such as home appliances and clothing. Due to the prohibitive cost of comprehensive labeling, the system typically only labels samples that clearly match user preferences as positive, leaving most other samples unlabeled. A similar situation exists in medical image analysis: doctors may be more focused on detecting malignant tumors, while a large amount of image data contains benign lesions or normal tissue. Although common symptoms are relatively easy to observe, obtaining labeled data for rare pathologies or specialized diagnostic tasks still requires significant resources and is technically challenging. In these scenarios, the goal is to use PU data to train a binary classifier capable of reliably determining whether unseen samples belong to the target domain.

[0004] Given the importance of these applications, the academic community has proposed various PU learning methods. Inspired by the successful applications of deep learning in various fields, recent PU learning research has gradually shifted towards selecting reliable negative samples or solving 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 based on learned representations using heuristic methods. 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, which cannot accurately classify the samples. Summary of the Invention

[0005] The purpose of this invention is to address the shortcomings of the prior art by providing a method and system for classifying positive and negative unlabeled images based on deep metric learning, thereby solving the problems in the prior art.

[0006] The present invention specifically provides the following technical solution:

[0007] A method for classifying positive and negative unlabeled images based on deep metric learning, comprising:

[0008] Obtain labeled positive sample images and unlabeled images; the positive sample images are images in the product recommendations that match the user's target category, and the unlabeled images include positive sample images and images that do not match the user's target category;

[0009] Labeled positive sample images and unlabeled images are input into a 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 center of the labeled positive sample images and the center of the positive sample images. An enhanced view of the unlabeled images is generated. The enhanced view of the unlabeled images is aligned with the unlabeled images in the representation space by minimizing the distance. The semantic similarity between different views is captured, and the relevant feature representations with positive and negative discrimination in all sample images are output.

[0010] Using the relevant features, the dissimilarity between the center of each sample image and the center of the positive sample image is calculated. All sample images are sorted in ascending order of the dissimilarity. From all sorted sample images, sample images that are multiple times the number of positive sample images are selected as reliable negative samples.

[0011] The relevant feature representation is used as input, and a binary classifier is trained using labeled positive sample images and reliable negative samples as supervision signals. The trained binary classifier is then used to classify the unlabeled positive and negative images to be detected.

[0012] Preferably, the deep metric learning model includes two ResNet-18-based encoders, wherein the main encoder... Used to perform centrality metric learning, auxiliary encoder Used to perform consistent alignment metric learning.

[0013] Preferably, the step of adjusting the labeled positive sample images in the depth 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 specifically involves:

[0014] Minimize the distance between each labeled positive sample image and the center of the positive sample image. The negative cosine similarity between the positive and labeled positive sample images is used to obtain the positive center metric loss. This loss minimizes the distance between the centers of the positive sample images and the labeled positive sample images. The specific expression is as follows:

[0015] ;

[0016] ;

[0017] in, To measure the loss for positive centering, MP is the set of labeled positive samples in the current batch, and x is the image of a positive sample. The input positive sample image x is processed by the main encoder. The feature representation obtained after encoding is θ, which is the parameter of the main encoder, and φ, which is the parameter of the auxiliary encoder.

[0018] Preferably, aligning the enhanced view of the unlabeled image with the unlabeled image in the representation space with minimal distance specifically involves:

[0019] 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, with the specific expression as follows:

[0020] ;

[0021] in, The loss is used as a measure of self-consistency. M U This is the set of unlabeled samples in the current batch. Input positive sample images x After auxiliary encoder The feature representation obtained after encoding;

[0022] Based on the self-consistency metric loss, the unlabeled image and the corresponding augmented view are aligned in the representation space with the distance minimized.

[0023] Preferably, after outputting the relevant feature representations with positive and negative distinguishability in all sample images, the method further includes:

[0024] The overall loss function of the deep metric learning model is obtained as follows:

[0025] ;

[0026] To minimize overall loss To achieve this, the main encoder is updated using stochastic gradient descent or its variants. parameters ; via main encoder parameters Exponential moving average update auxiliary encoder parameters The specific expression is:

[0027] ;

[0028] Where opt represents the optimizer and η is the learning rate. It is the momentum coefficient of the EMA;

[0029] By updating the parameters, the optimal deep metric learning model is obtained, and the relevant feature representations are re-output using the optimal deep metric learning model.

[0030] Preferably, using the relevant feature representation, the dissimilarity between the center of each sample image and the center of the positive sample image is calculated. All sample images are sorted in ascending order of the dissimilarity, and sample images that are proportional to the number of positive sample images are selected sequentially from all sorted sample images as reliable negative samples. The specific expression is as follows:

[0031] ;

[0032] ;

[0033] in, For dissimilarity, This is a reliable negative sample.

[0034] Preferably, the step of using relevant feature representations as input and training a binary classifier using labeled positive sample images and reliable negative samples as supervisory signals is specifically expressed as follows:

[0035] ;

[0036] in, For the trained binary classifier, These are the weight parameters of the classifier. For bias, These are constraint parameters. The relevant features output by the main encoder.

[0037] This invention provides a positive and negative unlabeled image classification system based on deep metric learning, comprising:

[0038] The image acquisition module is used to acquire labeled positive sample images and unlabeled images; the positive sample images are images that match the user's target category in the product recommendations, and the unlabeled images include positive sample images and images that do not belong to the user's target category;

[0039] The model output module is used to input labeled positive sample images and unlabeled images into the deep metric learning model. Through positive center metric learning, the labeled positive sample images are adjusted in the deep feature space to minimize the distance between the center of the labeled positive sample images and the center of the positive sample images. An enhanced view of the unlabeled images is generated. The enhanced view of the unlabeled images is aligned with the unlabeled images in the representation space by minimizing the distance, capturing the semantic similarity between different views, and outputting the relevant feature representations with positive and negative discrimination in all sample images.

[0040] The negative sample acquisition module is used to calculate the dissimilarity between the center of 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 select sample images from all sorted sample images in a sequential manner that are multiple times the number of positive sample images as reliable negative samples.

[0041] The training module takes relevant feature representations as input, uses labeled positive sample images and reliable negative samples as supervision signals to train a binary classifier, and then uses the trained binary classifier to classify the unlabeled positive and negative images to be detected.

[0042] The present invention provides a computer device, including a memory and a processor. The memory stores a program, and when the program is executed by the processor, the processor performs the steps of the above-described method for classifying positive and negative unlabeled images based on deep metric learning.

[0043] The present invention provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the above-described method for classifying positive and negative unlabeled images based on deep metric learning.

[0044] Compared with the prior art, the present invention has the following significant advantages:

[0045] This invention employs a deep metric learning framework, which learns discriminative representations by directly optimizing the relationships between samples in the deep feature space. This avoids dependence on heuristic negative sample selection. By simultaneously minimizing two metric distances—the distance between the centers of positive sample images and the distance between the augmented views of unlabeled images in the representation space—it effectively utilizes the supervision information of positive samples and the structural information of unlabeled samples. This enables the learning of high-quality feature representations that are discriminative between positive and negative samples, and effectively prevents the accumulation and propagation of errors from erroneous samples during representation learning. Based on the learned high-quality feature representations, negative samples can be more reliably selected for subsequent classifier training, and accurate classification of positive and negative unlabeled images can be achieved. Attached Figure Description

[0046] Figure 1 This is a schematic diagram outlining the DML framework in this invention;

[0047] Figure 2 This is a diagram illustrating the training process of the classifier in this invention;

[0048] Figure 3This is a t-SNE visualization of the representations learned by different methods in this invention; green dots represent positive samples (including positive samples in both labeled and unlabeled data), blue dots represent negative samples (from unlabeled data), and in the DML-PU visualization, red dots represent the reliable negative samples selected; where, Figure 3 (a)~ Figure 3 (c) shows the Dist-PU plots for the distribution alignment methods of the CIFAR-10, MNIST and EuroSAT datasets, respectively.

[0049] Figure 4 This is a t-SNE visualization of the representations learned by different methods in this invention; wherein Figure 4 (a)~ Figure 4 (c) shows the LaGAM gradient-aware mining method based on contrastive meta-learning for the CIFAR-10, MNIST, and EuroSAT datasets, respectively.

[0050] Figure 5 This is a t-SNE visualization of the representations learned by different methods in this invention; wherein Figure 5 (a)~ Figure 5 (c) shows the deep metric learning method DML-PU graphs for the CIFAR-10, MNIST and EuroSAT datasets, respectively.

[0051] Figure 6 This is a flowchart of a method for classifying positive and negative unlabeled images based on deep metric learning, as described in this invention. Detailed Implementation

[0052] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0053] Over the past few decades, PU learning has been extensively researched and has spurred the development of numerous methods. Its development can be broadly divided into two stages:

[0054] Phase 1: Early PU learning methods primarily relied on manually defined, fixed metric functions to select reliable negative samples. However, these methods were mostly limited to processing structured data (such as text documents), and their effectiveness and generalization ability were limited when faced with complex unstructured data such as images.

[0055] Phase Two: With the tremendous success of deep learning in various fields, recent PU learning research has shifted towards using deep neural networks to learn discriminative feature representations and then using these representations for negative sample screening or unlabeled sample disambiguation. Specifically, current research focuses on two closely related objectives: (1) using the screened reliable negative samples or disambiguated unlabeled samples to learn discriminative data representations; and (2) using heuristic methods to further screen reliable negative samples based on the learned representations.

[0056] However, these heuristic-based methods inevitably introduce error accumulation and propagation during representation learning and sample selection, ultimately leading to 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 representations, these methods still fundamentally rely on the reliability of the initially selected negative samples or the disambiguated categories.

[0057] The core objective of deep metric learning is to construct an embedding space through nonlinear transformations, ensuring that the geometric distance between samples accurately reflects their semantic relationships—meaning semantically similar samples cluster together in the space, while semantically dissimilar samples are effectively spaced out. This method has demonstrated excellent performance in multiple computer vision tasks, including face recognition, cross-modal retrieval, object classification, and data clustering. The foundation of deep metric learning lies in designing effective metric loss functions, such as contrastive loss, triplet loss, ranked list loss, and angular loss. However, these classic loss functions typically rely on training with negative samples or fully labeled datasets, thus significantly limiting their direct application in PU (Problem-Based) datasets containing only positive and unlabeled samples.

[0058] In the context of unlabeled positive and negative (PU) metric learning, the main challenge lies in the lack of supervision information provided by negative samples, while traditional metric learning methods heavily rely on negative samples or fully labeled data during training. In contrast, this work focuses on deep metric learning in the unlabeled positive and negative scenario, aiming to achieve effective training using only labeled positive and unlabeled samples, without relying on any pre-labeled or screened negative samples.

[0059] For PU learning of image data, the core task is to develop a binary classifier. This classifier uses only a set of labeled positive sample images. and a set of unlabeled images Conduct training, specifically as follows Figure 2 As shown, the ultimate goal is to accurately identify images belonging to a specific object category. (Dataset) It consists of two parts:

[0060] : Contains positive sample images that are determined to belong to the target category.

[0061] : 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.

[0062] The fundamental challenge of PU learning stems from unlabeled datasets. The mixed nature of images and the lack of negative sample labels greatly increase the difficulty of classification tasks. The goal is to build a robust binary classification model that can accurately determine whether an unseen image belongs to the positive class of the target.

[0063] The main challenges in learning effective representations from PU image data are: (1) the number of labeled positive samples is usually extremely scarce; and (2) labeled negative samples are completely lacking. To address these challenges, a deep metric learning (DML) framework has been introduced, specifically designed for PU learning in the image domain, capable of learning on both labeled positive and unlabeled samples simultaneously. Figure 1 As shown, the DML framework includes two complementary learning tasks: Positive-CenteredMetric 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 for subsequent classification tasks.

[0064] Specifically, image features are mapped to a representation space, where similar images are grouped together and dissimilar images are separated. The DML representation learning module trains its main encoder using a learning loss computed using cosine distance. The loss function aims to minimize the loss caused by... Derived positive sample center Compared with positive samples in the representation space The differences between the feature representations in the code. Furthermore, it ensures self-anchoring. Alignment with the corresponding representation. Parameter and All are trainable; however, the auxiliary mapping parameters Using a momentum-based update mechanism as It evolves using a slow moving average. To stabilize training, a stop-gradient ("sg") operation is used to restrict the flow. The gradient.

[0065] Network Architecture: The DML architecture consists of two ResNet-18 based encoders: the main encoder and the main encoder. Used to perform centrality metric learning, auxiliary encoder Used to perform consistent alignment metric learning. During training, parameters... and Both will be optimized. It's worth noting that the feature dimensions output by both encoders are the same.

[0066] Network update: Main encoder The encoder is responsible for extracting image features, and its parameters are updated through backpropagation. The goal is to minimize the metric loss calculated for labeled positive samples and individual samples. Meanwhile, the auxiliary encoder... The robustness of the model is enhanced by contrastive supervision, and its parameters are derived from the parameters of the main encoder. The model is updated using the exponential moving average (EMA). This framework, where the master and slave encoders work together, effectively improves the overall generalization ability of the model.

[0067] Forward propagation model: Given a batch of input images, DML first applies a data augmentation function to generate an augmented view for each image. Then, the original view and the augmented view are respectively fed into the main encoder. and auxiliary encoder In this process, the corresponding output representation is generated. and Both of these representations reside in the same representation space.

[0068] Training Objective: DML performs two parallel metric learning tasks: one focusing on known positive samples, and the other processing unlabeled data by learning from its own positive (augmented) view. 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.

[0069] like Figure 6 As shown in the figure, this embodiment presents a method for classifying positive and negative unlabeled images based on deep metric learning, which includes the following steps:

[0070] Step S1: Obtain labeled positive sample images and unlabeled images; positive sample images are images that match the user's target category in the product recommendations, and unlabeled images include positive sample images and images that do not match the user's target category.

[0071] Step S2: 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 to minimize the distance between the center of the labeled positive sample images and the center of the positive sample images. Generate an enhanced view of the unlabeled images. Align the enhanced view of the unlabeled images with the unlabeled images in the representation space by minimizing the distance. Capture the semantic similarity between different views and output the relevant feature representations with positive and negative discrimination in all sample images.

[0072] The deep metric learning model includes two ResNet-18-based encoders, with the main encoder being... Used to perform centrality metric learning, auxiliary encoder Used to perform consistent alignment metric learning.

[0073] The aim is to bring the labeled positive target samples closer to their center point in the depth feature space. Positive sample center It is initialized to the mean of the labeled positive samples in the current batch and dynamically updated during training. Specifically, for each mini-batch... Positive sample center The calculation method is as follows:

[0074] ;

[0075] in, It is the subset of labeled positive samples in the current batch M. Indicates sample After the main encoder The obtained feature representation.

[0076] By learning the positive center metric, the labeled positive sample images are adjusted in the deep feature space to minimize the distance between the positive sample images and their centers. Specifically:

[0077] Minimize the distance between each labeled positive sample image and the center of the positive sample image. The negative cosine similarity between the positive and labeled positive sample images is used to obtain the positive center metric loss. This loss minimizes the distance between the centers of the positive sample images and the labeled positive sample images. The specific expression is as follows:

[0078] ;

[0079] in, To measure the loss for positive centering, MP is the set of labeled positive samples in the current batch. x For positive sample images, θ is the parameter of the main encoder, and φ is the parameter of the auxiliary encoder.

[0080] By employing self-consistent metric learning, unlabeled images and their corresponding augmented views are aligned in the representation space with minimal distance. Specifically:

[0081] The consistency metric loss is obtained by using 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 specific expression is as follows:

[0082] ;

[0083] in, The loss is a measure of self-consistency, where MU is the set of unlabeled samples in the current batch. Input positive sample images x After auxiliary encoder The encoded feature representation is then used to align the unlabeled image with the corresponding augmented view in the representation space by minimizing the distance, based on the self-consistency metric loss.

[0084] After outputting the relevant feature representations, it also includes:

[0085] The overall loss function of the deep metric learning model is obtained as follows:

[0086] ;

[0087] To minimize overall loss To achieve this, the main encoder is updated using stochastic gradient descent or its variants. parameters ; via main encoder parameters Exponential moving average update auxiliary encoder The parameter ϕ is expressed as follows:

[0088] ;

[0089] Where opt (optimizer) represents the optimizer, and η is the learning rate. It is the momentum coefficient of the EMA;

[0090] By updating the parameters, the optimal deep metric learning model is obtained, and the relevant feature representations are re-output using the optimal deep metric learning model.

[0091] Step S3: Using relevant feature representations, calculate the dissimilarity between the center of 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 a multiple (3 times) the number of positive sample images as reliable negative samples. The specific expression is:

[0092] ;

[0093] ;

[0094] in, For dissimilarity, This is a reliable negative sample.

[0095] Step S4: Using the relevant feature representation as input, a binary classifier is trained using labeled positive sample images and reliable negative samples as supervision signals. The trained binary classifier is then used to classify the unlabeled positive and negative images to be detected.

[0096] The specific expression for the binary classifier is:

[0097] ;

[0098] in, For the trained binary classifier, These are the weight parameters of the classifier. For bias, These are constraint parameters. The relevant features output by the main encoder.

[0099] The following explanation is provided through experimental setup:

[0100] The performance of the DML-PU method was evaluated on five different datasets covering various image classification tasks: CIFAR-10: for classifying 10 classes of natural images, 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 classes of clothing and accessories; PCAM: containing histopathological images for detecting metastatic cancer tissue in lymph node sections, representing a key application in medical diagnostics; and EuroSAT: utilizing Sentinel-2 satellite imagery for land cover classification, supporting environmental monitoring and geospatial analysis. See Table 1 for details.

[0101] Table 1: Dataset Summary

[0102]

[0103] Data configuration: For each multi-class dataset (CIFAR-10, MNIST, F-MNIST, EuroSAT), the class with a class index of 1 is designated as the positive class, and all other classes are considered negative. For the PCAM dataset, which is inherently binary, its original class definitions are followed. During the training phase, a subset of samples is randomly selected from the positive class as labeled positive samples. The remaining positive samples are mixed with all the negative samples to form an unlabeled dataset. The specific number of samples is as follows:

[0104] The datasets CIFAR-10, MNIST, F-MNIST, and PCAM randomly selected 2,000 samples from the positive class as... EuroSAT: 1,500 samples are randomly selected from the positive class as... .

[0105] The DML-PU was compared with a range of state-of-the-art PU learning methods, including:

[0106] The PU learning method PAN (PU learning with class-conditional GANs) constructs pseudo-negative samples using class-conditional GANs. Robust-PU (Robust PU learning with curriculum-based adaptive weighting) employs a curriculum-based learning strategy with adaptive sample weighting. Self-PU (Self-training with confidence refinement) refines pseudo-labels through confidence-based self-training. P3MIX (Polarized Mixup for PU Learning) uses polarized mixup enhancement techniques to strengthen decision boundaries. The traditional PU method uPU (Non-negative PU learning) implements an unbiased risk estimator. The PU method nnPU (Unbiased PU learning) implements a non-negative risk estimator. The variational PU learning method VPU (Variational PU learning) optimizes the lower bound of variational evidence. 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 positive and negative sample distributions through KL divergence regularization.

[0107] For all comparison methods, the official source code publicly released by the original authors on GitHub was used to ensure the fairness of the comparison and the reproducibility of the results. Their default hyperparameter settings, implementation details, and recommended training procedures were strictly followed.

[0108] Fully supervised baseline model:

[0109] In addition, two fully supervised baseline models were trained as performance ceilings. Each model contained the same ResNet-18 image encoder and linear logistic regression classifier as the DML-PU. Both models were optimized using the sigmoid activation function and binary cross-entropy loss (Log Loss), differing only in the number of negative samples used during training.

[0110] Supervised-Part: Use the same number of labeled positive samples as the total number of samples (i.e., ... Training is performed using 100 labeled negative samples.

[0111] Supervised-All: Training is performed using all available labeled negative samples.

[0112] Evaluation indicators:

[0113] In PU learning, the primary goal is to accurately identify positive samples of interest to the user. Therefore, the F1 score is used as the main evaluation metric, which is also a widely used standard metric in the PU learning field. To ensure the stability and reliability of the evaluation results, each method is run independently 10 times on each dataset, and the final reported performance is the average F1 score and its standard deviation of these 10 runs. All models are evaluated on a reserved test set.

[0114] Experimental details:

[0115] 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, which operates on the representation output by the encoder. Before being input into the classifier, the feature vectors are subjected to L2 normalization to improve training stability and generalization ability.

[0116] For optimization, the AdamW optimizer was used with a learning rate of 5×10⁻⁶. −4 The weight decays to 1×10 −5 The momentum coefficient of EMA Set to 0.005.

[0117] To enhance the model's robustness, standard data augmentation techniques were applied, including random cropping, random horizontal flipping, and other augmentations based on dataset characteristics (such as brightness adjustment, random translation, vertical flipping, random erasing, etc.) to ensure that the input to the model is a diverse range of augmented views. All datasets were trained using a uniform mini-batch size of 256.

[0118] All experiments were implemented using the PyTorch framework and conducted on a server equipped with an NVIDIA RTX 3090 GPU (24GB VRAM).

[0119] Table 2 shows all the comparison methods and the average F1 score and standard deviation of the proposed DML-PU on five benchmark datasets.

[0120] Comparative analysis of DML-PU and state-of-the-art methods:

[0121] Experimental results clearly demonstrate that DML-PU significantly outperforms all existing PU learning comparison methods on all five datasets. On the relatively simple single-channel image datasets MNIST and F-MNIST, most methods achieve high accuracy, but DML-PU still achieves the best performance, with F1 scores of 99.39% and 95.96%, respectively.

[0122] Table 2: Main Results (F1 score, higher is better)

[0123]

[0124] On more challenging real-world datasets, such as CIFAR-10, EuroSAT, and PCAM, the advantages of DML-PU are even more pronounced. For example:

[0125] Compared to the Robust-PU, which has performed well recently, the DML-PU improved its F1 scores on CIFAR-10, EuroSAT, and PCAM by approximately 23.19%, 7.16%, and 14.99%, respectively.

[0126] Compared to LaGAM, which also focuses on representation learning, DML-PU shows more significant performance improvements on CIFAR-10, EuroSAT, and PCAM, reaching approximately 22.97%, 33.72%, and 22.87%, respectively. This indicates that the deep metric learning strategy employed by DML-PU, which directly optimizes sample relationships in the representation space, is more effective in PU scenarios than LaGAM's contrastive meta-learning and gradient mining strategies, especially when dealing with complex and diverse datasets, where it can generalize better.

[0127] Compared to Dist-PU, which utilizes 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 method is more robust in capturing complex data structures and distinguishing between positive and negative samples.

[0128] Overall, these results strongly demonstrate the superiority of DML-PU in PU learning tasks, showcasing its ability to outperform state-of-the-art methods, especially on complex datasets that demand higher levels of model discriminative and generalization capabilities.

[0129] Performance analysis of DML-PU and fully supervised models:

[0130] Table 2 also shows that the proposed DML-PU framework performs very close to or even reaches the level of fully supervised models on most datasets when using only a subset of positive and unlabeled samples.

[0131] On the CIFAR-10, MNIST, F-MNIST, and EuroSAT datasets, the F1 score of DML-PU is very close to that of the Supervised-All model trained with all negative samples, and even slightly outperforms the Supervised-Part model trained with only a subset of negative samples on CIFAR-10 and EuroSAT.

[0132] Of particular note is that on the PCAM dataset, the performance of DML-PU (76.35%) is not only close to that of Supervised-Part (76.90%), but also slightly lower than that of Supervised-All (80.24%). Considering the difficulty of PU learning, this is still a very good result. The relatively weak performance of Supervised-Part may be due to the limited number of negative samples used, which restricts the model's ability to learn discriminative features. While Supervised-All uses all negative samples, on a dataset like PCAM with extremely imbalanced classes (far fewer positive samples than negative samples), excessive imbalance may actually have a negative impact on model training.

[0133] The key to DML-PU's ability to achieve performance close to or even comparable to fully supervised models lies in its deep metric learning strategy, which effectively utilizes information inherent in unlabeled data to aid representation learning. Simultaneously, its carefully designed metric loss functions (positive center loss and self-consistent loss) guide the model to learn compact and discriminative feature representations, thus laying a solid foundation for subsequent classifier training. This demonstrates the effectiveness of the DML-PU framework in balancing the use of limited labeled information with a large amount of unlabeled information, as well as its robustness across different types of datasets.

[0134] Visual analysis:

[0135] like Figure 3 As shown, a visualization analysis was performed: To more intuitively understand the quality of feature representations learned by different methods, a visual comparison was made of the image representations obtained after training from the contrastive meta-learning-based gradient-aware mining method LaGAM, the distribution alignment method Dist-PU, and the proposed deep metric learning method DML-PU. The high-dimensional features were embedded and projected into a two-dimensional space using t-SNE dimensionality reduction, and the results were visualized on three benchmark datasets: CIFAR-10, MNIST, and EuroSAT. The results are as follows... Figure 3 (a)~ Figure 3 (c) Figure 4 (a)~ Figure 4 (c) and Figure 5 (a)~ Figure 5 As shown in (c).

[0136] from Figure 3 The visualization results show that DML-PU effectively clusters all positive samples (green dots) into a compact region, while clearly distributing negative samples (blue dots) outside this region. The reliable negative samples (red dots) selected are also mostly located far from the positive sample clusters. This indicates that the representation learned by DML-PU has strong discriminative power. On the MNIST dataset, where the categories are inherently distinguishable, all three methods demonstrated good discriminative performance, with clear separation between positive and negative sample clusters.

[0137] However, as Figure 3 , Figure 4 and Figure 5 As shown, on the more challenging CIFAR-10 and EuroSAT datasets, DML-PU significantly outperforms LaGAM and Dist-PU. LaGAM (relying on contrastive learning) and Dist-PU (relying on class prior assumptions) exhibit significant overlap and confusion between positive and negative sample clusters on these complex datasets, resulting in low discriminative power. In contrast, DML-PU directly optimizes the relationships between samples through deep metric learning, without relying on negative samples or strong prior assumptions. Therefore, it achieves better generalization ability and more robust discriminative performance on complex datasets, learning a cleaner and more compact representation of positive samples.

[0138] Ablation studies:

[0139] To verify the effectiveness of each component in the DML-PU framework, a series of ablation experiments were conducted. The results of the two learning tasks are as follows:

[0140] This study investigated the contributions of two core metric learning tasks in DML-PU—Positive-Centered metric learning (PC) and Self-Consistency metric learning (SC)—to the final classification performance. In this invention, methods using only the PC task are denoted as DML-PC, and methods using only the SC task are denoted as DML-SC. These methods are then compared with the complete DML-PU method, which uses both tasks simultaneously. The results are shown in Table 3.

[0141] Table 3: Ablation experiment results (F1 score) for the two learning tasks

[0142]

[0143] As shown in Table 3, when using DML-PC or DML-SC alone, the model's performance is significantly lower than that of the complete DML-PU method. This indicates that neither task alone can learn sufficiently discriminative representations for effective PU classification.

[0144] Interestingly, the DML-PU, formed by combining these two tasks, outperforms the sum of the performance of the two individual tasks. This strongly demonstrates that the strategies of positive centering metric learning and self-consistent metric learning are complementary and synergistic, and their combination can produce a synergistic effect, significantly improving the quality of representation learning and the final classification performance.

[0145] The effect of reliable negative sample count:

[0146] In the second stage of DML-PU, this invention requires using the learned metric function to filter reliable negative samples from unlabeled data to train the final classifier. This invention analyzes the impact of the number of reliable negative samples used to train the internal classifier on the final performance.

[0147] This invention evaluates configurations that select different proportions of negative samples relative to the number of labeled positive samples. The results were calculated as 1x, 3x (default setting), and 5x. The results are shown in Table 4.

[0148] Table 4: Impact of different numbers of reliable negative samples on performance (F1 score)

[0149]

[0150] As shown in Table 4, the performance of DML-PU remained very stable under different reliable negative sample selection ratios (1x, 3x, and 5x), without significant fluctuations. This consistency indicates that the method of this invention has good robustness to changes in the number of selected reliable negative samples. This suggests that the representation learned by DML-PU is good enough to allow subsequent classifiers to effectively learn from reliable negative sample distributions of different orders of magnitude without significantly impacting the final performance. The default selection of 3x the number of negative samples is a relatively balanced choice.

[0151] The impact of reliable positive samples:

[0152] This invention also explores methods for training the final classifier, in addition to using the original labeled positive samples. and the selected reliable negative samples In addition, can the learned metric function be further utilized in unlabeled data? The most reliable positive samples (i.e., those that are far from the center in the representation space) were identified. Very close unlabeled samples), and also add them to the classifier training, such as Figure 2 As shown. This invention conducted experiments, selecting the 200, 400, 600, and 800 samples with the highest confidence levels from the unlabeled data as additional "reliable positive samples" (denoted as RP200, RP400, RP600, and RP800), respectively, and comparing them with... and They were used together to train the classifier. The results are shown in Table 5.

[0153] Table 5: The impact of adding reliable positive samples on classification performance (F1 score)

[0154]

[0155] As shown in Table 5, adding the selected reliable positive samples to the classifier training did not bring significant performance improvement; in some cases, it even slightly decreased performance. This indicates that the original labeled positive samples... Sufficient positive sample supervision information has already been provided, and further screening for positive samples from unlabeled data may introduce noise or uncertainty. Therefore, the default DML-PU method of this invention (using only...) and The trained classifier is robust and effective enough that there is no need to rely on the extra step of sifting reliable positive samples from unlabeled data.

[0156] 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's F1 score rivals or even surpasses that of supervised models trained with fully labeled data. This fully demonstrates the effectiveness of the proposed dual-metric learning optimization strategy, which not only improves the quality of feature learning but also provides a more reliable negative sample foundation for subsequent classifier training, ultimately leading to a significant performance improvement. This provides a powerful and effective new approach for solving PU learning problems in practical applications.

[0157] This invention proposes a positive and negative unlabeled image classification system based on deep metric learning, comprising: an image acquisition module, a model output module, a negative sample acquisition module, and a training module.

[0158] The image acquisition module acquires labeled positive sample images and unlabeled images. Positive sample images are those matching the user's target category in product recommendations, while unlabeled images include both positive sample images and images not matching the user's target category. The model output module inputs the labeled positive sample images and unlabeled images into a deep metric learning model. Through positive center metric learning, it adjusts the labeled positive sample images in the deep feature space, minimizing the distance between the centers of the labeled positive sample images and the unlabeled images. It then generates an enhanced view of the unlabeled images and aligns it with the unlabeled images in the representation space by minimizing the distance, capturing... The semantic similarity between different views outputs relevant feature representations with positive and negative discrimination in all sample images. The negative sample acquisition module uses the relevant feature representations to calculate the dissimilarity between the center of each sample image and the center of the positive sample image, sorts all sample images in ascending order of dissimilarity, and selects sample images from all sorted sample images in a sequence that are multiples of the number of positive sample images as reliable negative samples. The training module uses the relevant feature representations as input, uses labeled positive sample images and reliable negative samples as supervision signals to train a binary classifier, and uses the trained binary classifier to classify the unlabeled positive and negative images to be detected.

[0159] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a program, and when the program is executed by the processor, the processor performs the steps of a method for classifying positive and negative unlabeled images based on deep metric learning.

[0160] According to the disclosed embodiments, the computer device can communicate with one or more external devices (e.g., keyboard, pointing device, Bluetooth communication, etc.) or with any device that enables the computing device to communicate with one or more other computing devices (e.g., router, demodulator, etc.).

[0161] The present invention provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the above-described method for classifying positive and negative unlabeled images based on deep metric learning.

[0162] The above description, in conjunction with specific preferred embodiments, provides a more detailed explanation of the present invention. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of the present invention, and all such deductions or substitutions should be considered to fall within the scope of protection of the present invention.

Claims

1. A method for classifying positive and negative unlabeled images based on deep metric learning, characterized in that, include: Obtain labeled positive sample images and unlabeled images; The positive sample images are those that match the user's target category in the product recommendations, and the unlabeled images include positive sample images and images that do not match the user's target category. Labeled positive sample images and unlabeled images are input into a 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 center of the labeled positive sample images and the center of the positive sample images. An enhanced view of the unlabeled images is generated. The enhanced view of the unlabeled images is aligned with the unlabeled images in the representation space by minimizing the distance. The semantic similarity between different views is captured, and the relevant feature representations with positive and negative discrimination in all sample images are output. Using the relevant features, the dissimilarity between the center of each sample image and the center of the positive sample image is calculated. All sample images are sorted in ascending order of the dissimilarity. From all sorted sample images, sample images that are multiple times the number of labeled positive sample images are selected as reliable negative samples. 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 a binary classifier. The trained binary classifier is then used to classify the unlabeled positive and negative images to be detected. The deep metric learning model includes two ResNet-18-based encoders, with the main encoder being... Used to perform centrality metric learning, auxiliary encoder Used to perform consistent alignment metric learning; The step of adjusting the labeled positive sample images in the depth 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 is as follows: Minimize the distance between each labeled positive sample image and the center of the positive sample image. The negative cosine similarity between the positive centrality samples is used to obtain the positive centrality loss. The positive centrality loss minimizes the distance between the centers of the labeled positive sample images. The specific expression is as follows: ; ; in, Measure the loss at the positive center. M P Let x be the set of labeled positive samples in the current batch, and let x be the image of a positive sample. The input positive sample image x is processed by the main encoder. The encoded feature representations are θ, which represents the parameters of the primary encoder, and φ, which represents the parameters of the auxiliary encoder. The center of the positive sample image.

2. The method for classifying positive and negative unlabeled images based on deep metric learning as described in claim 1, characterized in that, The process of aligning the enhanced view of the unlabeled image with the unlabeled image in the representation space with minimal distance specifically involves: 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, with the specific expression as follows: ; in, The loss is used as a measure of self-consistency. M U This is the set of unlabeled samples in the current batch. Input positive sample images x After auxiliary encoder The 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 with the distance minimized.

3. The method for classifying positive and negative unlabeled images based on deep metric learning as described in claim 2, characterized in that, After outputting the relevant feature representations with positive and negative discrimination in all sample images, the method further includes: The overall loss function of the deep metric learning model is obtained as follows: ; To minimize overall loss To achieve this, the main encoder is updated using stochastic gradient descent or its variants. parameters ; via main encoder parameters Exponential moving average update auxiliary encoder parameters The specific expression is: ; Where opt represents the optimizer and η is the learning rate. It is the momentum coefficient of the EMA. ; By updating the parameters, the optimal deep metric learning model is obtained, and the relevant feature representations are re-output using the optimal deep metric learning model.

4. The method for classifying positive and negative unlabeled images based on deep metric learning as described in claim 1, characterized in that, Using the aforementioned relevant features, the dissimilarity between the center of each sample image and the center of the positive sample image is calculated. All sample images are sorted in ascending order of the dissimilarity. From all sorted sample images, sample images that are proportional to the number of labeled positive sample images are selected sequentially as reliable negative samples. The specific expression is as follows: ; ; in, For dissimilarity, This is a reliable negative sample.

5. The method for classifying positive and negative unlabeled images based on deep metric learning as described in claim 1, characterized in that, The process involves using relevant feature representations as input and labeled positive sample images and reliable negative samples as supervisory signals to train a binary classifier. The specific expression is as follows: ; in, For the trained binary classifier, These are the weight parameters of the classifier. For bias, These are constraint parameters. The relevant features output by the main encoder.

6. A positive and negative unlabeled image classification system based on deep metric learning, characterized in that, include: The image acquisition module is used to acquire labeled positive sample images and unlabeled images; the positive sample images are images that match the user's target category in the product recommendations, and the unlabeled images include positive sample images and images that do not belong to the user's target category; The model output module is used to input labeled positive sample images and unlabeled images into the deep metric learning model. Through positive center metric learning, the labeled positive sample images are adjusted in the deep feature space to minimize the distance between the center of the labeled positive sample images and the center of the positive sample images. An enhanced view of the unlabeled images is generated. The enhanced view of the unlabeled images is aligned with the unlabeled images in the representation space by minimizing the distance, capturing the semantic similarity between different views, and outputting the relevant feature representations with positive and negative discrimination in all sample images. The negative sample acquisition module is used to calculate the dissimilarity between the center of 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 select sample images from all sorted sample images in order that are multiple times the number of labeled positive sample images as reliable negative samples. The training module takes relevant feature representations as input, uses labeled positive sample images and reliable negative samples as supervision signals to train a binary classifier, and uses the trained binary classifier to classify the unlabeled positive and negative images to be detected. The deep metric learning model includes two ResNet-18-based encoders, with the main encoder being... Used to perform centrality metric learning, auxiliary encoder Used to perform consistent alignment metric learning; The step of adjusting the labeled positive sample images in the depth 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 is as follows: Minimize the distance between each labeled positive sample image and the center of the positive sample image. The negative cosine similarity between the positive centrality samples is used to obtain the positive centrality loss. The positive centrality loss minimizes the distance between the centers of the labeled positive sample images. The specific expression is as follows: ; ; in, Measure the loss at the positive center. M P Let x be the set of labeled positive samples in the current batch, and let x be the image of a positive sample. The input positive sample image x is processed by the main encoder. The encoded feature representations are θ, which represents the parameters of the primary encoder, and φ, which represents the parameters of the auxiliary encoder. The center of the positive sample image.

7. A computer device, characterized in that, The system includes a memory and a processor, wherein the memory stores a program that, when executed by the processor, causes the processor to perform the steps of a method for classifying positive and negative unlabeled images based on deep metric learning as described in any one of claims 1 to 5.

8. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the positive and negative unlabeled image classification method based on deep metric learning as described in any one of claims 1 to 5.