Single sample unsupervised domain adaptation method based on probabilistic link contrastive learning
Patent Information
- Application Number
- CN202410525376.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-29
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2044-04-29
AI Technical Summary
[0011]本发明提供一种基于概率链接对比学习的单样本无监督领域自适应方法,用以解决现有技术中存在的缺陷
[0079] This invention provides a single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning. By generating probabilistic links between target sample pairs based on intra-domain prototype contrastive learning, intra-domain probabilistic link-based contrastive learning is performed, improving the efficiency of discriminative feature learning. Furthermore, with the help of probabilistic links, contrastive learning can be performed on all target sample pairs, avoiding the inaccuracies and time-consuming nature of K-nearest neighbor search and significantly expanding the learning scope. The method calculates the probability of bidirectional matching between cluster pairs in the source and target domains and uses three different methods to measure the similarity between clusters. It also constructs cross-domain probabilistic links based on the probability of bidirectional matching and aligns semantically consistent cross-domain clusters through inter-domain probabilistic link-based contrastive learning, effectively improving the accuracy of domain alignment.
Smart Images

Figure CN118314437B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of domain adaptation technology, and in particular to a single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning. Background Technology
[0002] Domain adaptation aims to solve the problem of knowledge transfer from one domain (source domain) to another domain (target domain), enabling deep learning models to adapt to data from different domains. Domain adaptation technology has wide applications in object recognition and tracking in computer vision, medical imaging, and natural language processing.
[0003] Link-based contrastive learning is a machine learning technique used to improve data representation and feature learning. Its core idea is to define the relationships between samples by building links, so as to emphasize similarities and differences during the learning process.
[0004] In domain adaptation techniques, unsupervised domain adaptation (UDA) aims to address the domain shift problem. Its basic idea is to learn knowledge from a labeled source domain and transfer this knowledge to an unlabeled target domain, achieving adaptation by adjusting the data distribution. However, in some practical applications, obtaining sufficient source domain data is difficult, hindering the application of existing UDA methods. To address this issue, a series of new research directions have emerged, including: Few-shot UDA (FUDA) method 00: This method studies cases where the number of labeled source samples is very limited, but a large amount of unlabeled source data is still available; Source-free DA (SFDA) method 000: This method studies cases where, during the adaptation process, only a large amount of unlabeled target data and a model pre-trained from fully labeled source data are accessible.
[0005] References:
[0006] [1]Kim D, Saito K, Oh TH, et al.Cds: Cross-domain self-supervised pre-training[C] / / Proceedings of the IEEE / CVF International Conference on ComputerVision.2021:9123-9132.
[0007] [2] Yue
[0008] [3]Liang J, Hu D, Feng J. Do we really need to access the source data? source hypothesis transfer for unsupervised domain adaptation[C] / / International conference on machine learning.PMLR, 2020:6028-6039.
[0009] [4]Xie B, Li S, Lv F, et al. A collaborative alignment framework of transferable knowledge extraction for unsupervised domain adaptation[J]. IEEE Transactions on Knowledge and Data Engineering, 2022.
[0010] [5]Ding N, Xu Y, Tang Y, et al. Source-free domain adaptation viadistribution estimation[C] / / Proceedings of the IEEE / CVF Conference onComputer Vision and Pattern Recognition.2022:7212-7222. Summary of the Invention
[0011] This invention provides a single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning to address the shortcomings of existing technologies.
[0012] In a first aspect, the present invention provides a single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning, comprising:
[0013] Step 1: Obtain several image samples of different categories from the source domain, and obtain several unlabeled image samples of the same category as the source domain from the target domain;
[0014] Step 2: Extract normalized features from the source domain and the target domain using a shared feature encoder, and construct a source domain memory library in the source domain and a target domain memory library in the target domain, respectively.
[0015] Step 3: Determine each category in the source domain memory library as a cluster, take the unique sample of each cluster as the source domain category prototype, perform clustering calculation on the target domain memory library, and take the center of each cluster as the target domain category prototype;
[0016] Step 4: Perform contrastive learning based on clustering prototypes in the target domain, and use the prototype contrastive learning loss function to determine the prototype discriminative features;
[0017] Step 5: Perform probabilistic link-based contrastive learning within the target domain, transforming the sample-to-cluster mapping within the target domain into probabilistic links within the target domain, and constructing a contrastive learning loss function within the target domain based on the probabilistic links within the target domain.
[0018] Step 6: Perform inter-domain probabilistic link-based contrastive learning between the source domain and the target domain, transform the mapping between inter-domain samples and clusters into inter-domain bidirectional probabilistic links, and construct an inter-domain contrastive learning loss function based on the inter-domain bidirectional probabilistic links;
[0019] Step 7: Construct the overall loss function from the intra-domain contrastive learning loss function and the inter-domain contrastive learning loss function. If it is determined that the overall loss function has not converged, update the model weights, the source domain memory library, and the target domain memory library, and jump to step 3; otherwise, execute step 8.
[0020] Step 8: By calculating the maximum value of the normalized feature of any target domain and the memory feature of any source domain, the source domain feature label corresponding to each sample in the target domain is obtained, and the target domain classification is completed based on the source domain feature label.
[0021] According to the present invention, a single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning is provided, step 1 of which includes:
[0022] From the source domain Obtain N from s Image samples of different categories, Indicates sample Category tags;
[0023] From the target domain Obtain N from t Unlabeled image samples that share the same category as the source domain;
[0024] Where, N t >>N s .
[0025] According to the present invention, a single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning is provided, wherein step 2 includes:
[0026] A shared encoder F is used to extract normalized features f from the source domain and the target domain, respectively. i ;
[0027] Build a source domain memory library in the source domain Build the target domain memory library in the target domain N s N represents the number of image samples of different categories in the source domain. t This indicates the number of unlabeled image samples in the target domain;
[0028] By normalizing the feature f i For source domain memory library V s and target domain memory library V t Features v in i Initialize, and during model training, batch by batch with v i ←λv i +(1-λ)f i The momentum λ∈[0,1] is updated in this way.
[0029] According to the single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning provided by the present invention, step 3 includes:
[0030] Within the target domain, K clusters are obtained using K-means clustering based on the target domain features stored in the target domain memory. Cluster C t The cluster centers are
[0031] Each category in the source domain is treated as a cluster. Based on the source domain features stored in the source domain memory library, the unique sample features of each cluster are used as the prototype of the source domain category, i.e.
[0032] According to the single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning provided by the present invention, the prototype contrastive learning loss function in step 4... for:
[0033]
[0034] Where, p ik Indicates sample Does it belong to a cluster? When the condition is met At that time, p ik =1, otherwise p ik =0, K represents the number of clusters, N t This represents the number of unlabeled image samples in the target domain, where n represents the index of the current cluster. This represents the feature vector of the i-th sample. This represents the prototype of the cluster with index k. This represents the prototype of the cluster with index n.
[0035] According to the single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning provided by the present invention, step 5 includes:
[0036] Transform the sample-to-cluster mapping within the target domain into a probabilistic link within the target domain.
[0037]
[0038] in, Represents the i-th sample within the target domain. The probability of belonging to the k-th cluster, where τ is a temperature parameter representing the degree of concentration of the mapping distribution;
[0039] Determine the target sample pair The probability of being in the same cluster for:
[0040]
[0041] in, and Representing samples respectively and samples The probability of belonging to the k-th cluster;
[0042] Determine the target sample pair Non-cluster probability for:
[0043] Based on the probability of clustering Constructing the first loss function for intra-domain contrastive learning
[0044]
[0045] Based on non-cluster probability Constructing a second loss function for intra-domain contrastive learning
[0046]
[0047] According to the single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning provided by the present invention, step 6 includes:
[0048] Calculate the first one-way matching probability from the source domain to the target domain and the second one-way matching probability from the target domain to the source domain respectively, and construct the bidirectional probability link between the domains based on the first one-way matching probability and the second one-way matching probability.
[0049] Using the bidirectional probabilistic links between domains, a first probabilistic link is constructed between samples and clusters in the source domain and the target domain, and a second probabilistic link is constructed between samples and clusters in the target domain and the source domain. The inter-domain contrastive learning loss function is constructed based on the first probabilistic link and the second probabilistic link.
[0050] According to the present invention, a single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning calculates a first one-way matching probability from the source domain to the target domain and a second one-way matching probability from the target domain to the source domain, and constructs a bidirectional probabilistic link between the domains using the first one-way matching probability and the second one-way matching probability, including:
[0051] First one-way matching probability include:
[0052]
[0053] Where τ represents the temperature parameter. Indicates from cluster to cluster Similarity;
[0054] in Including prototype-level measurements
[0055]
[0056] Also includes sample-level measurements
[0057]
[0058] Measurements at the prototype level and sample level measurement Constructing hybrid measurements:
[0059]
[0060] Among them, P t (l) represents the sample The index of the cluster to which it belongs;
[0061] Similarly, the second one-way matching probability can be obtained.
[0062] Based on the first one-way matching probability and the second one-way matching probability Construct the inter-domain bidirectional probabilistic link and
[0063]
[0064] According to the present invention, a single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning is provided. This method utilizes the inter-domain bidirectional probabilistic links to construct a first probabilistic link between samples and clusters in the source domain and the target domain, and a second probabilistic link between samples and clusters in the target domain and the source domain. The inter-domain contrastive learning loss function is constructed based on the first and second probabilistic links, including:
[0065] The first probabilistic link includes cross-domain matching links between source domain samples and target domain clusters. And cross-domain non-matching links between source domain samples and target domain clusters. in:
[0066]
[0067]
[0068] The second probabilistic link includes cross-domain matching links between target domain samples and source domain clusters. And cross-domain non-matching links between target domain samples and source domain clusters. in:
[0069]
[0070] in, Represents target domain samples The probability of belonging to the k-th cluster. This represents a bidirectional probabilistic link between the k-th cluster in the target domain and the i-th cluster in the source domain;
[0071]
[0072] Bidirectional matching probability of cluster pairs from source domain to target domain Constructing a matching and contrastive learning loss function from the source domain to the target domain.
[0073]
[0074] Bidirectional non-matching probability of cluster pairs between source and target domains Constructing a non-matching contrastive learning loss function from the source domain to the target domain
[0075]
[0076] Similarly, the probability of bidirectional cluster pair matching between the target domain and the source domain. Constructing a matching and contrastive learning loss function from the target domain to the source domain Bidirectional non-matching probability of cluster pairs between target domain and source domain Constructing a non-matching contrastive learning loss function from the target domain to the source domain
[0077] comprehensive and Obtain the inter-domain contrastive learning loss function
[0078] In a second aspect, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements a single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning as described above.
[0079] This invention provides a single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning. By generating probabilistic links between target sample pairs based on intra-domain prototype contrastive learning, intra-domain probabilistic link-based contrastive learning is performed, improving the efficiency of discriminative feature learning. Furthermore, with the help of probabilistic links, contrastive learning can be performed on all target sample pairs, avoiding the inaccuracies and time-consuming nature of K-nearest neighbor search and significantly expanding the learning scope. The method calculates the probability of bidirectional matching between cluster pairs in the source and target domains and uses three different methods to measure the similarity between clusters. It also constructs cross-domain probabilistic links based on the probability of bidirectional matching and aligns semantically consistent cross-domain clusters through inter-domain probabilistic link-based contrastive learning, effectively improving the accuracy of domain alignment. Attached Figure Description
[0080] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0081] Figure 1 This is one of the flowcharts of the single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning provided by the present invention;
[0082] Figure 2 This is the second flowchart of the single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning provided by this invention.
[0083] Figure 3 This is the overall model architecture diagram provided by the present invention;
[0084] Figure 4 This is a schematic diagram of the inter-domain probabilistic link construction method provided by the present invention, wherein, Figure 4 In the diagram, (a) represents the i-th sample from the source domain. To the j-th cluster of the target domain The probability of a match between them. Figure 4 In the diagram, (b) represents the j-th sample in the target domain. To the i-th cluster in the source domain The probability of a match between them;
[0085] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0086] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this 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 this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0087] This invention proposes a one-shot unsupervised domain adaptive model (OSUDA) as an example, where the source domain consists of only one sample from each category, and the target domain contains a large number of unlabeled samples. Taking a real-world surveillance video face recognition task as an example, each person has only one clear, frontal registered image (source domain), and the goal is to identify faces with blurred angles captured by surveillance cameras mounted at high altitudes (target domain). Due to privacy concerns, it is difficult to obtain additional high-quality images to meet the large amount of unlabeled source data required for OSUDA, or to learn the pre-trained model required for SFDA. Therefore, OSUDA faces a more severe dual challenge: (1) the scarcity of source samples hinders discriminative feature learning, and (2) the quantitative gap between source and target data makes it difficult to align domain distributions. These challenges hinder the direct application of existing methods in the OSUDA environment, thus prompting this invention to explore tailored solutions for new problems.
[0088] Figure 1This is one of the flowcharts illustrating the single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning provided in this embodiment of the invention, such as... Figure 1 As shown, it includes:
[0089] Step 1: Obtain several image samples of different categories from the source domain, and obtain several unlabeled image samples of the same category as the source domain from the target domain;
[0090] Step 2: Extract normalized features from the source domain and the target domain using a shared feature encoder, and construct a source domain memory library in the source domain and a target domain memory library in the target domain, respectively.
[0091] Step 3: Determine each category in the source domain memory library as a cluster, take the unique sample of each cluster as the source domain category prototype, perform clustering calculation on the target domain memory library, and take the center of each cluster as the target domain category prototype;
[0092] Step 4: Perform contrastive learning based on clustering prototypes in the target domain, and use the prototype contrastive learning loss function to determine the prototype discriminative features;
[0093] Step 5: Perform probabilistic link-based contrastive learning within the target domain, transforming the sample-to-cluster mapping within the target domain into probabilistic links within the target domain, and constructing a contrastive learning loss function within the target domain based on the probabilistic links within the target domain.
[0094] Step 6: Perform inter-domain probabilistic link-based contrastive learning between the source domain and the target domain, transform the mapping between inter-domain samples and clusters into inter-domain bidirectional probabilistic links, and construct an inter-domain contrastive learning loss function based on the inter-domain bidirectional probabilistic links;
[0095] Step 7: Construct the overall loss function from the intra-domain contrastive learning loss function and the inter-domain contrastive learning loss function. If it is determined that the overall loss function has not converged, update the model weights, the source domain memory library, and the target domain memory library, and jump to step 3; otherwise, execute step 8.
[0096] Step 8: By calculating the maximum value of the normalized feature of any target domain and the memory feature of any source domain, the source domain feature label corresponding to each sample in the target domain is obtained, and the target domain classification is completed based on the source domain feature label.
[0097] The probabilistic linked basis contrastive learning algorithm for single-sample unsupervised domain adaptation tasks proposed in this invention is a method for addressing the unsupervised domain adaptation problem in scenarios where the source domain consists of only one sample from each class, while the target domain contains a large number of unlabeled samples. It solves the domain offset problem by generating intra-domain probabilistic links for discriminative feature learning and constructing cross-domain probabilistic links for domain alignment.
[0098] Specifically, the implementation process steps are as follows: Figure 2 As shown, it includes:
[0099] Step 1, Data Preparation, from the source domain Get N s 100 samples, each from a different category, and from the target domain. Obtain N from t N unlabeled samples that share the same set of categories as the source domain, where N t >>N s ;
[0100] Step 2, using a shared encoder F, such as Figure 4 As shown in the overall model architecture diagram, normalized features f are extracted from the source domain and the target domain, respectively. i Furthermore, source memory banks are constructed in both the source and target domains. and the target memory bank To store the value of each sample feature, where N s and N t These represent the number of samples in the source and target domains, respectively. The feature v in the memory database... i via f i Initialize and perform batches with v during model training. i ←λv i +(1-λ)f i The momentum λ∈[0,1] is updated in this way.
[0101] Step 3: Within the target domain, perform K-means clustering based on the target domain features stored in the target domain memory to obtain K clusters. Clusters The cluster center is defined as These cluster centers are also called the prototypes of the corresponding categories; and since there is only one sample for each category in the source domain, each category is directly regarded as a cluster in the source domain, i.e. Simultaneously, based on the source domain features stored in the source domain memory library, the unique sample features in each cluster are regarded as the prototype of that category, i.e.
[0102] Step 4: Perform contrastive learning based on clustering prototypes in the target domain to learn discriminative features. The contrastive learning loss function is as follows:
[0103]
[0104] Where p ik Indicates sample Does it belong to a cluster? That is, when the conditions are met At that time, p ik =1, otherwise p ik =0, K represents the number of clusters, N t This represents the number of unlabeled image samples in the target domain, where n represents the index of the current cluster. This represents the feature vector of the i-th sample. This represents the prototype of the cluster with index k. This represents the prototype of the cluster with index n.
[0105] Step 5, based on prototype contrastive learning, performs probabilistic link-based contrastive learning within the target domain to make samples within the same cluster more closely connected, while simultaneously amplifying the differences between samples in different clusters. This includes the following sub-steps:
[0106] Step 5.1 softens the mapping from samples to clusters within the target domain into probabilistic form, as shown in the following formula:
[0107]
[0108] in, Represents the i-th sample within the target domain. The membership distribution belonging to the k-th cluster is determined by the temperature parameter τ, which in turn determines the degree of concentration of the mapping distribution.
[0109] And construct target sample pairs based on this probability membership. The link between q ij The construction details are as follows:
[0110] Target sample pairs The probability of belonging to the same cluster (must-link) is defined as:
[0111]
[0112] in, and Representing samples respectively and samples The probability of belonging to the k-th cluster. Similarly, The probability of not belonging to the same cluster (cannot-link) is defined as:
[0113]
[0114] Step 5.2, based on probabilistic link q ij The loss function for intra-domain contrastive learning is constructed as follows:
[0115]
[0116] The loss function for intra-domain contrastive learning based on cannot-link is as follows:
[0117]
[0118] in, Bring two samples belonging to the same cluster closer together. Two samples that do not belong to the same cluster are pushed apart. Since must-link and cannot-link represent two different but related constraints on the same target sample set, only one needs to be retained during training.
[0119] Step 6: Perform inter-domain probabilistic link-based contrastive learning between the source and target domains to align semantically consistent clusters between the two domains. The inter-domain probabilistic links are constructed as follows: Figure 4 As shown, where, Figure 4 In the diagram, (a) represents the i-th sample from the source domain. To the j-th cluster of the target domain The probability of a match between them. Figure 4 In the diagram, (b) represents the j-th sample in the target domain. To the i-th cluster in the source domain The probability of a match between them includes the following sub-steps:
[0120] Step 6.1, Calculate the source domain cluster To target domain cluster The probability of a one-way match between them is calculated using the following formula:
[0121]
[0122] Where τ represents the temperature parameter. Indicates from cluster to cluster The similarity was calculated using three different methods, with the formulas as follows:
[0123] Prototype-level measurement:
[0124]
[0125] Sample-level measurement:
[0126]
[0127] Mixed measurements:
[0128]
[0129] Among them, P t (l) represents the sample The index of the cluster to which it belongs.
[0130] Similarly, the target domain cluster can be calculated using the method described above. To source domain cluster One-way matching probability between The source domain cluster is calculated based on the unidirectional matching probability in both directions. and target domain cluster The probability of a two-way match between them is calculated using the following formula:
[0131]
[0132] Step 6.2: Based on the bidirectional matching probability of cluster pairs in Step 6.1, construct the probability link r between samples and clusters across domains. ij and r ji And based on this link, a loss function for inter-domain contrastive learning is constructed. Since each cluster in the source domain contains only one sample, the i-th sample in the source domain... To the j-th cluster of the target domain The probability of a mutual match (must-link) between cluster pairs, which is the bidirectional matching probability between cluster pairs from the source domain to the target domain, is defined as:
[0133]
[0134] Similarly, the i-th sample in the source domain To the j-th cluster of the target domain The probability that two elements are not a match (cannot-link) is defined as:
[0135]
[0136]
[0137] Because in principle, the target domain samples It may belong to any target domain cluster, therefore the j-th sample in the target domain To the i-th cluster in the source domain The probability of a match between two elements (must-link) is defined as:
[0138] in, Represents target domain samples The probability of belonging to the k-th cluster. This represents a bidirectional probability link between the k-th cluster in the target domain and the i-th cluster in the source domain. Similarly, the j-th sample in the target domain... To the i-th cluster in the source domain The probability that two elements are not a match (cannot-link) is defined as:
[0139]
[0140] The source-to-target domain contrastive learning loss function based on must-link is as follows:
[0141]
[0142] The contrastive learning loss function from the source domain to the target domain based on the not-link is as follows:
[0143]
[0144] in, Bringing the source domain samples and target domain clusters that match each other closer together. Push source domain samples and target domain clusters that do not match each other further away.
[0145] Similarly, the contrastive learning loss from the target domain to the source domain can be constructed using the method described above. and Finally, the loss functions in both directions are combined to obtain the total loss function for inter-domain link-based contrastive learning. In order to simplify the training process, during the training process Only select combinations of loss functions based on either must-link or cannot-link in both directions.
[0146] Step 7: Determine whether the overall loss function of the model has converged. If not, update the model weights, update the two memory databases with the features extracted by the current model, and jump to step 3; otherwise, execute step 8.
[0147] Step 8, through calculation To obtain each sample in the target domain The corresponding source domain feature label j is used to perform a classification task in the target domain.
[0148] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute a single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning. The method includes: Step 1, obtaining several image samples of different categories from the source domain and several unlabeled image samples of the same category as the source domain from the target domain; Step 2, extracting normalized features from the source domain and the target domain respectively using a shared feature encoder, constructing a source domain memory library in the source domain and a target domain memory library in the target domain; Step 3, determining each category in the source domain memory library as a cluster, using the unique sample of each cluster as the source domain category prototype, and applying this to the target domain memory library. Step 4: Perform clustering calculations, using the center of each cluster as the target domain category prototype; Step 5: Perform contrastive learning based on the cluster prototypes in the target domain, using the prototype contrastive learning loss function to determine the prototype discriminative features; Step 6: Perform probabilistic link-based contrastive learning in the target domain, transforming the sample-to-cluster mapping in the target domain into probabilistic links within the target domain, and constructing a target domain contrastive learning loss function based on the probabilistic links within the target domain; Step 7: Perform inter-domain probabilistic link-based contrastive learning between the source domain and the target domain, transforming the mapping between inter-domain samples and clusters into bidirectional inter-domain probabilistic links, and constructing an inter-domain contrastive learning loss function based on the bidirectional inter-domain probabilistic links;
[0149] Step 7: Construct the overall loss function from the intra-domain contrastive learning loss function and the inter-domain contrastive learning loss function. If it is determined that the overall loss function has not converged, update the model weights, the source domain memory library, and the target domain memory library, and jump to step 3; otherwise, execute step 8.
[0150] Step 8: By calculating the maximum value of the normalized feature of any target domain and the memory feature of any source domain, the source domain feature label corresponding to each sample in the target domain is obtained, and the target domain classification is completed based on the source domain feature label.
[0151] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0152] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0153] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0154] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning, characterized in that, include: Step 1: Obtain several image samples of different categories from the source domain, and obtain several unlabeled image samples of the same category as the source domain from the target domain; Step 2: Extract normalized features from the source domain and the target domain using a shared feature encoder, and construct a source domain memory library in the source domain and a target domain memory library in the target domain, respectively. Step 3: Determine each category in the source domain memory library as a cluster, take the unique sample of each cluster as the source domain category prototype, perform clustering calculation on the target domain memory library, and take the center of each cluster as the target domain category prototype; Step 4: Perform contrastive learning based on clustering prototypes in the target domain, and use the prototype contrastive learning loss function to determine the prototype discriminative features; Step 5: Perform probabilistic link-based contrastive learning within the target domain, transforming the sample-to-cluster mapping within the target domain into probabilistic links within the target domain, and constructing a contrastive learning loss function within the target domain based on the probabilistic links within the target domain. Step 6: Perform inter-domain probabilistic link-based contrastive learning between the source domain and the target domain, transform the mapping between inter-domain samples and clusters into inter-domain bidirectional probabilistic links, and construct an inter-domain contrastive learning loss function based on the inter-domain bidirectional probabilistic links; Step 7: Construct the overall loss function from the intra-domain contrastive learning loss function and the inter-domain contrastive learning loss function. If it is determined that the overall loss function has not converged, update the model weights, the source domain memory library, and the target domain memory library, and jump to step 3; otherwise, execute step 8. Step 8: By calculating the maximum value of the normalized feature of any target domain and the memory feature of any source domain, the source domain feature label corresponding to each sample in the target domain is obtained, and the target domain classification is completed based on the source domain feature label.
2. The single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning according to claim 1, characterized in that, Step 1 includes: From the source domain Obtain N from s Image samples of different categories, Indicates sample Category tags; From the target domain Obtain N from t Unlabeled image samples that share the same category as the source domain; Where, N t >>N s .
3. The single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning according to claim 1, characterized in that, Step 2 includes: A shared encoder F is used to extract normalized features f from the source domain and the target domain, respectively. i ; Build a source domain memory library in the source domain Build the target domain memory library in the target domain N s N represents the number of image samples of different categories in the source domain. t This indicates the number of unlabeled image samples in the target domain; By normalizing the feature f i For source domain memory library V s and target domain memory library V t Feature b in i Initialize, and during model training, batch by batch with v i ←λv i +(1-λ)f i The momentum λ∈[0,1] is updated in this way.
4. The single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning according to claim 1, characterized in that, Step 3 includes: Within the target domain, K clusters are obtained using K-means clustering based on the target domain features stored in the target domain memory. Cluster C t The cluster centers are Each category in the source domain is treated as a cluster. Based on the source domain features stored in the source domain memory library, the unique sample features of each cluster are used as the prototype of the source domain category, i.e.
5. The single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning according to claim 1, characterized in that, Prototype contrastive learning loss function in step 4 for: Where, p ik Indicates sample Does it belong to a cluster? When the condition is met At that time, p ik =1, otherwise p ik =0, K represents the number of clusters, N t This represents the number of unlabeled image samples in the target domain, where n represents the index of the current cluster. This represents the feature vector of the i-th sample. This represents the prototype of the cluster with index k. This represents the prototype of the cluster with index n.
6. The single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning according to claim 1, characterized in that, Step 5 includes: Transform the sample-to-cluster mapping within the target domain into a probabilistic link within the target domain. in, Represents the i-th sample within the target domain. The probability of belonging to the k-th cluster, where τ is a temperature parameter representing the degree of concentration of the mapping distribution; Determine the target sample pair The probability of being in the same cluster for: in, and Representing samples respectively and samples The probability of belonging to the k-th cluster; Determine the target sample pair Non-cluster probability for: Based on the probability of clustering Constructing the first loss function for intra-domain contrastive learning Based on non-cluster probability Constructing a second loss function for intra-domain contrastive learning 7. The single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning according to claim 1, characterized in that, Step 6 includes: Calculate the first one-way matching probability from the source domain to the target domain and the second one-way matching probability from the target domain to the source domain respectively, and construct the bidirectional probability link between the domains based on the first one-way matching probability and the second one-way matching probability. Using the bidirectional probabilistic links between domains, a first probabilistic link is constructed between samples and clusters in the source domain and the target domain, and a second probabilistic link is constructed between samples and clusters in the target domain and the source domain. The inter-domain contrastive learning loss function is constructed based on the first probabilistic link and the second probabilistic link.
8. The single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning according to claim 7, characterized in that, Calculate the first one-way matching probability from the source domain to the target domain and the second one-way matching probability from the target domain to the source domain, respectively. Construct the bidirectional probability link between the domains based on the first and second one-way matching probabilities, including: First one-way matching probability include: Where τ represents the temperature parameter. Indicates from cluster to cluster Similarity; in Including prototype-level measurements Also includes sample-level measurements Measurements at the prototype level and sample level measurement Constructing hybrid measurements: Among them, P t (l) represents the sample The index of the cluster to which it belongs; Similarly, the second one-way matching probability can be obtained. Based on the first one-way matching probability and the second one-way matching probability Construct the inter-domain bidirectional probabilistic link and 9. The single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning according to claim 7, characterized in that, Utilizing the bidirectional inter-domain probabilistic links, a first probabilistic link is constructed between samples and clusters in the source domain and the target domain, and a second probabilistic link is constructed between samples and clusters in the target domain and the source domain. Based on the first and second probabilistic links, the inter-domain contrastive learning loss function is constructed, including: The first probabilistic link includes cross-domain matching links between source domain samples and target domain clusters. And cross-domain non-matching links between source domain samples and target domain clusters. in: The second probabilistic link includes cross-domain matching links between target domain samples and source domain clusters. And cross-domain non-matching links between target domain samples and source domain clusters. in: in, Represents target domain samples The probability of belonging to the k-th cluster. This represents a bidirectional probabilistic link between the k-th cluster in the target domain and the i-th cluster in the source domain; Bidirectional matching probability of cluster pairs from source domain to target domain Constructing a matching and contrastive learning loss function from the source domain to the target domain. Bidirectional non-matching probability of cluster pairs between source and target domains Constructing a non-matching contrastive learning loss function from the source domain to the target domain Similarly, the probability of bidirectional cluster pair matching between the target domain and the source domain. Constructing a matching and contrastive learning loss function from the target domain to the source domain Bidirectional non-matching probability of cluster pairs between target domain and source domain Constructing a non-matching contrastive learning loss function from the target domain to the source domain comprehensive and Obtain the inter-domain contrastive learning loss function 10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the single-sample unsupervised domain adaptation method based on probabilistic link contrastive learning as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Unsupervised domain adaptation method based on double unbalanced scene
CN114444605A