Transfer learning method combining intra-class feature alignment and flexible hyperparameter metric learning
By combining the transfer learning method of intra-class feature alignment and flexible hyperparameter metric learning, the distribution shift problem in cross-domain learning is solved, and the classification accuracy and task accuracy of the target domain are improved.
Patent Information
- Application Number
- CN202310923660.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-26
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2043-07-26
AI Technical Summary
Traditional machine learning models are susceptible to distribution shift problems in cross-domain learning, especially when the marginal label distributions in different domains are significantly different, which leads to feature distribution shift and increased target error.
A transfer learning method that combines intra-class feature alignment with flexible hyperparameter metric learning dynamically adjusts the model loss function to adapt to the target domain by minimizing the distance between samples of the same class and maximizing the distance between samples of different classes in a low-dimensional space, and changing the marginal hyperparameters to variable parameters.
It improves the classification accuracy of the target domain, reduces feature distribution shift, enhances intra-class correlation and category discrimination, and achieves higher cross-domain task accuracy.
Smart Images

Figure CN117056771B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine learning, and in particular to a transfer learning method combining intra-class feature alignment with flexible hyperparameter metric learning. Background Art
[0002] With the enhancement of computer capabilities and the advancement of algorithms, machine learning methods have become a powerful tool for finding the intrinsic connections of data. However, in order to achieve good classification results, traditional machine learning models often rely on the source domain (training set) and the target domain (test set) having the same distribution. In general, the distribution of data is often different, which easily leads to distribution shift. How to solve the distribution shift problem is the key. Transfer learning domain adaptation is one of the powerful means to solve such cross-domain learning problems. Unsupervised domain adaptation mainly includes the study of features and distance metrics. Based on the feature processing and distance metric levels, the present invention improves the classification accuracy of the target domain classifier by combining feature alignment with variable hyperparameter metric learning.
[0003] Feature processing methods use intra-class feature alignment to ensure that features have good intra-class correlation and category discrimination. Some researchers have proposed directly aligning the features of each pair of samples in the source and target domains and calculating the transferability of each source sample. The results show that aligning the feature distribution to the prior distribution can improve adaptability in image recognition tasks. However, the workload of aligning each pair of sample features is enormous, which can cause the feature extractor to ignore the intrinsic structural information of the data, affecting the accuracy of the algorithm. To this end, some researchers have proposed a substructure-based unsupervised domain adaptation framework. Through optimal transfer theory, this framework avoids the situation where feature alignment is too coarse and misses details. Although feature alignment methods have made great contributions to unsupervised domain adaptation, there is still a problem that needs to be explored. When the marginal label distributions of different domains are significantly different, blindly minimizing the distribution difference between source and target features will only increase the target error. Summary of the Invention
[0004] In order to address the deficiencies mentioned in the above background technology, the purpose of the present invention is to solve the problem of feature distribution offset that is easily generated when reducing cross-domain distribution differences in unsupervised domain adaptation. Based on feature processing and metric learning, the present invention proposes a transfer learning method that combines intra-class feature alignment and flexible hyperparameter metric learning, aiming to identify the potential structural information of the data and improve the recognition accuracy of target samples by increasing intra-class feature alignment and dynamically improving marginal hyperparameters.
[0005] In order to solve the above technical problems, the technical solution provided by the present invention is:
[0006] A transfer learning method that combines intra-class feature alignment with flexible hyperparameter metric learning mainly includes the following steps:
[0007] Step (1): Target domain sample selection and initial prediction label generation
[0008] Specifically, the source domain of the original high-dimensional space (in is the source domain, is the corresponding label) in the source domain sample X S , and the target domain (in is the target sample X in the target domain) T , we first use an unsupervised domain adaptation method to learn the domain-invariant projection matrix p∈i from the source and target domains m ×d , and get the domain invariant feature F S =pX S and F T =pX T Then, the target sample labels are updated using the weak classifier trained on the source domain Finally, the inner iteration is performed until convergence, generating improved labels for the target domain for the next cycle of the outer iteration.
[0009] Step (2): Intra-class and inter-class feature alignment and iterative update of predicted labels
[0010] Specifically, in order to obtain a more effective loss term to improve the category discrimination of the learned features, the source domain and the target domain are first mapped to the feature representation F of the low-dimensional space respectively. Si ,F Sj , minimize the distance between the two features of the same sample to reduce the intra-class divergence D of the features (S) Secondly, the intra-class distance loss term for the target domain samples can be expressed as D using the pre-label of the target domain samples. (T) In addition to making the projection distance between samples of the same category as small as possible, the projection distance between samples of different categories should be as large as possible, so as to increase the category discrimination of the learned features. The generated prediction label and the target domain sample class distance loss term D (T) And the target domain sample category discrimination As input, we use the domain classifier to iteratively update the target domain prediction label. Step (3): Flexible hyperparameter metric learning and iterative update of prediction labels
[0011] Specifically, in order to make the model loss optimization dynamically adjusted according to different tasks, the fixed edge hyperparameters in the distance metric function are first improved to variable parameters and embedded into the algorithm framework, respectively reducing the distance between the edge distribution of the two domains and the projection center of the conditional distribution. And the edge distribution projection distance loss function is recorded as Second, the marginal hyperparameter β * The random data matrix H of the source and target domain samples and the marginal distribution distance metric matrix V M It can be used as a variable parameter to adapt to the neural network, making the model more suitable for the target domain classifier. Finally, the edge hyperparameter β * Will be along with the random data matrix H of the source domain and target domain samples, and the marginal distribution distance metric matrix V C It changes with the change of , which will be used as a variable parameter to adapt to the neural network, making the model more suitable for the target domain classifier. And conditional distribution projection distance loss function As input, we use the domain classifier to iteratively update the target domain prediction label.
[0012] Step (4): Hybrid loss function and target domain final prediction label
[0013] To achieve the natural transfer of labels and transfer more accurate pre-labels to samples with small weights, we first calculate the directed distance between the target domain samples and the domain classifier to determine how close the target domain samples are to the source domain samples. Since samples closer to the source domain share more common attributes, these target domain samples are given greater weights. Secondly, through manifold regularization, the target domain samples with large weights transfer their more accurate pre-labels to samples with small weights, completing the natural transfer of labels. These two parts are then unified into the hybrid loss function D. all As input, use the domain classifier to get the final predicted label of the target domain Here, the classification hyperplane H(w,b)={x|w T x=b} is the target domain classifier, where w is a vector perpendicular to the hyperplane and b is a constant.
[0014] Compared with the existing unsupervised domain adaptation algorithm based on feature alignment, the present invention has the following characteristics:
[0015] This paper extends feature divergence mining to the intra-class level and measures the scatter of each class, which ensures that the required features have good intra-class correlation and class discrimination. Secondly, this paper replaces the fixed hyperparameters in the loss function of the model distance metric with continuously variable hyperparameters. This is combined with the sample geometry of the target domain to form a hybrid loss structure, which enables the model loss optimization to dynamically adjust according to the changes of different tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to clearly illustrate the technical solution of the present invention and show the results of comparison with the processing effects of other existing algorithms, the following is a brief introduction to the drawings required in the content of the invention.
[0017] Figure 1 This is the overall structure diagram of the algorithm of the present invention.
[0018] Figure 2 Schematic diagram of intra-class and inter-class feature alignment.
[0019] Figure 3 Schematic diagram of flexible hyperparameter metric learning. DETAILED DESCRIPTION
[0020] The following is a detailed description of an embodiment of the present invention in conjunction with the accompanying drawings: This embodiment is implemented on the premise of the technical solution of the present invention, and provides a detailed implementation plan and specific operation process.
[0021] This embodiment provides a transfer learning method that combines intra-class feature alignment with flexible hyperparameter metric learning, such as Figure 1 As shown in the figure, the proposed method includes the following four steps: (1) First, the source domain difference and target domain uncertainty criteria are used to select the target domain samples that need to be labeled, thereby reducing the number of samples that need to be labeled. (2) In the source domain high-dimensional feature input stage, an intra-class alignment term is added to accurately measure the differences between different feature distributions. (3) The marginal hyperparameters in the distance metric loss function are improved to continuously variable parameters, focusing on the data structure information that is easily overlooked. (4) A hybrid loss function and a target domain classifier are formed to classify the target domain samples.
[0022] Specifically:
[0023] Step (1) constructs a transfer learning unsupervised domain adaptation classification model based on the CDELM algorithm. The objective function of the CDELM framework contains three parts: 1) prediction loss on source domain samples; 2) projected maximum mean deviation distance loss between the source domain and the target domain; 3) manifold regularization term of the target domain samples. The objective function of the CDELM is:
[0024]
[0025] Where β is the marginal hyperparameter, e Si is the prediction error vector of the i-th source domain sample, h(x Si ),h(x Tj ) is the random data of source domain and target domain samples, y Si ,f(x Tj ) are the true label vector and predicted label vector of the i-th source domain sample and the j-th target domain sample, respectively. is the projected MMD distance between the source domain and the target domain, αij represents the pairwise similarity between the i-th and j-th target domain samples, and C, λ, and γ>0 control the influence of the prediction error of the source domain data, the projected MMD distance between the two domains, and the prediction consistency of similar target domain samples, respectively.
[0026] Step (2) Target domain sample selection and initial prediction label generation:
[0027] Specifically, the source domain of the original high-dimensional space (in is the source domain, is the corresponding label) in the source domain sample X S , and the target domain (in is the target sample X in the target domain) T , we first use an unsupervised domain adaptation method to learn the domain-invariant projection matrix p∈i from the source and target domains m ×d , and get the domain invariant feature F S =pX S and F T =pX T .
[0028] The source domain samples, source domain labels, target domain samples and domain invariant features are used as input, and the weak classifier trained on the source domain is used to obtain and update the current model's predicted labels for the target domain data.
[0029] Finally, the inner iteration is performed until convergence, generating the target domain prediction label for the next cycle of the outer iteration Improved labeling;
[0030] Step (3) Intra-class and inter-class feature alignment and iterative update of predicted labels:
[0031] Specifically, in order to obtain a more effective loss term to improve the category discrimination of the learned features, the source domain and the target domain are first mapped to the feature representation F of the low-dimensional space respectively. Si ,F Sj , minimize the distance between the two features of the same sample to reduce the intra-class divergence D of the features (S) ;
[0032]
[0033] Among them, M is the total number of source domain sample feature categories, n s is the total number of source domain samples, is the number of source domain samples belonging to the mth class of features, y Si ,y Sj is the source domain label of any two features, F Si,F Sj is the feature representation of these two samples mapped into the low-dimensional space. When the number of categories is uneven, if the distance term of each category in formula (1) is not restricted, the category with a large number of samples will dominate, thus ignoring the role of the category with small samples. Therefore, in order to balance the influence of different categories, different penalty coefficients are added to the distance term of each category.
[0034] Secondly, for the intra-class distance loss term of the target domain sample, the pre-label of the target domain sample is expressed as D (T) ;
[0035]
[0036] Among them, K is the total number of target domain sample feature categories, n t is the total number of target domain samples, is the number of target domain samples belonging to the kth class feature, y Ti ,y Tj is the target domain label of any two features, F Ti ,F Tj is the feature representation of these two samples mapped into low-dimensional space. Similarly, in order to avoid the dominance of large sample features and the neglect of the role of small sample features, different penalty coefficients are added to the distance terms of each category.
[0037] In addition to making the projection distance between samples of the same category as small as possible, the projection distance between samples of different categories should be as large as possible, so as to increase the category discrimination of the learned features.
[0038]
[0039] Here, ρ is a loss term that balances the intra-class and inter-class divergence of features. It minimizes the intra-class dispersion of sample features and maximizes the inter-class divergence, so that the desired features have good intra-class correlation and class distinction, clustering similar features together while separating different class features as much as possible.
[0040] The generated prediction label and the target domain sample class distance loss term D (T) And the target domain sample category discrimination As input, we use the domain classifier to iteratively update the target domain prediction label.
[0041] Step (4) Flexible hyperparameter metric learning and iterative update of prediction labels:
[0042] Specifically, in order to make the model loss optimization dynamically adjusted according to different tasks, we first traverse the maximum mean deviation, maximum mean kernel deviation, and CORAL distance metric loss functions to calculate the sample distance loss of each category, and determine the distance loss function with the minimum distance. We calculate different edge hyperparameters, iteratively update the edge hyperparameters in the original distance loss calculation, and obtain the edge probability loss by measuring the distance between the true distribution of the source domain and the target domain samples and their estimated distribution through the maximum mean deviation. Then, we reduce the distance between the projection centers of the edge probability loss of the two domains to obtain the edge distribution projection distance loss function.
[0043]
[0044] Among them, f(x Si )=h(x Si )β,f(x Tj )=h(x Tj )β. f(x Si ),f(x Tj ) represent the source domain and target domain classifiers respectively, h(x Si ),h(x Tj ) is the random data of source domain and target domain samples, and β is the edge hyperparameter in the hidden layer. s ,n t are the number of samples corresponding to the source domain and the target domain, respectively.
[0045] Similarly, the conditional probability distribution distance metric function It can be expressed as,
[0046]
[0047] Among them, in order to test the accuracy of the source domain classifier, the concept of pre-label is added, y Si and y° Tj Represent the source domain samples x Si , target domain sample x Tj The true labels and pre-labels. Indicates the number of samples of the source domain data belonging to the kth category, Indicates the number of samples whose pre-label of the target domain sample is the kth class, n c is the number of sample categories. In order to test the accuracy of the source domain classifier, the concept of pre-label is added, y Si and y° Tj Represent the source domain samples x Si , target domain sample x Tj The true labels and pre-labels. Indicates the number of samples of the source domain data belonging to the kth category, Indicates the number of samples whose pre-label of the target domain sample is the kth class, n c is the number of sample categories. Similarly, in order to facilitate subsequent calculations, through mathematical formula transformation, Expressed in matrix form,
[0048]
[0049] in, is a (n s +n t )×(n s +n t )-dimensional conditional distribution distance metric matrix, Each element in can be represented as,
[0050]
[0051] Where j and k represent the number of rows and columns of the conditional distribution distance metric matrix respectively. The marginal hyperparameter β * Will be along with the random data matrix H of the source domain and target domain samples, and the marginal distribution distance metric matrix V C The model changes with the changes of , making the model more adaptable to the target domain classifier.
[0052] Step (5) Hybrid loss function and target domain final prediction label:
[0053] To achieve natural label transfer, more accurate pre-labels are transferred to samples with small weights. First, the directed distance between the target domain sample and the domain classifier is calculated to determine the proximity of the target domain sample to the source domain sample. Since samples closer to the source domain share more common attributes, these target domain samples are given greater weight. Second, through manifold regularization, the target domain samples with large weights transfer their more accurate pre-labels to samples with small weights, completing the natural label transfer. These two components are then unified into the hybrid loss function.
[0054]
[0055] Among them, n t represents the number of target domain samples, f S (x Ti ),f T (x Ti ) represent the source domain and target domain classifiers for the target domain sample x Ti predictions. is the weight given to the source domain classifier to predict the target domain samples, π ij Used to measure sample x Ti and x TjThe first part of the loss function weights the predictions of the source domain classifier on the target domain samples. The second part uses the geometric structure of the target domain samples to help transfer the predicted labels from the samples with larger weights to the samples with smaller weights, further improving the classification accuracy. Here, the classification hyperplane H(w,b)={x|w T x=b} is the target domain classifier, where w is a vector perpendicular to the hyperplane and b is a constant.
[0056] To validate the performance of our method, experiments were conducted on the Office+Caltech256 dataset, a public dataset for transfer learning. The Office+Caltech256 dataset is one of the most commonly used unsupervised domain adaptation datasets. It consists of four domains: Amazon (merchant images from shopping websites, abbreviated as A), Webcam (low-resolution images from webcams, abbreviated as W), DSLR (high-resolution images from digital SLR cameras, abbreviated as D), and Caltech256 (an image dataset collected and compiled by the California Institute of Technology, abbreviated as C). Our method uses all 10 common categories from these four domains: backpack, bicycle, computer keyboard, laptop, computer monitor, computer mouse, coffee cup, and video projector. There are a total of 2533 images, with 8 to 151 images per domain per category. This example uses the 4096-dimensional DeCAF6 features of the samples. Two sub-datasets are randomly selected as the source and target domains to form 12 cross-domain tasks, namely, 'A->W', 'A->D', 'A->C', ..., 'C->W', and 'C->D'. The results of the example are shown in Table 1.
[0057] Table 1 Accuracy comparison on Office+Caltech256 (DeCAF6 features) dataset (%)
[0058]
[0059] As can be seen from Table 1, the average classification accuracy of this method for all domain adaptation tasks in the embodiment is higher than that of other algorithms, reaching 80.82%. It is 6.28%, 6.26%, 4.11% and 3.25% higher than the DANN, JAN, AIFT and SSDA methods respectively, and achieved the best results in 9 of the 12 cross-domain tasks, with the smallest mean square error. Among them, the W domain and the D domain have great similarities, but they are quite different from the A domain. However, the method of the present invention still achieved the highest classification accuracy in the 'A->W' task. This shows that the present invention can improve the classification accuracy of target samples through intra-class feature alignment and flexible hyperparameters.
[0060] The embodiments described above are merely descriptions of preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should fall within the scope of protection determined by the claims of the present invention.
Claims
1. A transfer learning method combining intra-class feature alignment and flexible hyperparameter metric learning, characterized in that: The following steps are involved: Step (1) constructing a transfer learning unsupervised domain adaptation classification model based on the CDELM algorithm, wherein the objective function of the CDELM framework includes three parts: 1) prediction loss on source domain samples; 2) projected maximum mean deviation distance loss of the source domain and target domain; 3) manifold regularization term of target domain samples, where both source domain samples and target domain samples are images; Step (2) Target domain sample selection and initial prediction label generation: Select the labeled source domain data and unlabeled target domain data in the transfer learning unsupervised domain adaptation public dataset, and obtain the source domain of the original high-dimensional space The source domain samples X in S and target domain The target sample X in T , where the source domain is D S Indicates that X Si is the i-th sample in the source domain, y Si is the i-th label of the source domain, and the target domain is D t Indicates that X Tj is the jth sample in the target domain; First, the multi-core maximum mean deviation function is used to reduce the distance between the source domain data features and the target domain data features, so that the transfer learning unsupervised domain adaptation classification model transforms the orthogonal projection of the feature vectors of the source domain and the target domain into a domain-invariant projection matrix p, and then obtains the domain-invariant feature F S =pX S and F T =pX T ; The source domain samples, source domain labels, target domain samples and domain invariant features are used as input, and the weak classifier trained on the source domain is used to obtain and update the current model's predicted labels for the target domain data. Finally, the inner iteration is performed until convergence, generating the target domain prediction label for the next cycle of the outer iteration Improved labeling; Step (3) Intra-class and inter-class feature alignment and iterative update of predicted labels: First, the source domain and the target domain are mapped to the feature representation F of the low-dimensional space respectively. Si ,F Sj , minimize the distance between the two features of the same sample to reduce the intra-class divergence D of the features (S) ; Secondly, the distance loss of each class in the target domain sample is calculated by the distance metric function of the maximum mean deviation, and the distance loss term within the target domain sample class is expressed as D (T) ; Reduce the projection distance between samples of the same category in the unsupervised domain adaptation public dataset for transfer learning, increase the projection distance between samples of different categories, and thus increase the category discrimination of the learned features The generated prediction label and the target domain sample class distance loss term D (T) And the target domain sample category discrimination As input, we use the domain classifier to iteratively update the target domain prediction label. Step (4) Flexible hyperparameter metric learning and iterative update of prediction labels: First, we traverse the maximum mean deviation, maximum mean kernel deviation, and CORAL distance metric loss functions to calculate the sample distance loss of each category, and determine the distance loss function with the minimum distance. We calculate different edge hyperparameters, iteratively update the edge hyperparameters in the original distance loss calculation, and obtain the edge probability loss by measuring the distance between the true distribution of the source domain and the target domain samples and their estimated distribution through the maximum mean deviation. Then, we reduce the distance between the projection centers of the edge probability loss of the two domains to obtain the edge distribution projection distance loss function. where f(x Si )=h(x Si )β,f(x Tj )=h(x Tj )β,f(x Si ),f(x Tj ) represent the source domain and target domain classifiers respectively, h(x Si ),h(x Tj ) is the random data of source domain and target domain samples, β is the edge hyperparameter in the hidden layer, n s ,n t are the number of samples corresponding to the source domain and the target domain respectively; Similarly, the conditional probability loss is obtained by measuring the distance between the source domain and target domain samples and the true distribution of the label and its estimated distribution by the maximum mean deviation, and then reducing the distance between the projection centers of the conditional probability loss of the two domains to obtain the conditional distribution projection distance loss function Among them, the distribution between data and labels is projected onto the hyperplane to obtain the conditional distribution projection distance loss. Minimizing the loss can maximize the distribution of data and labels. Si and y° Tj Represent the source domain samples x Si , target domain sample x Tj The true labels and pre-labels of Indicates the number of samples of the source domain data belonging to the kth category, Indicates the number of samples whose pre-label of the target domain sample is the kth class, n c is the number of categories of samples; Project the marginal distribution into the distance loss function And conditional distribution projection distance loss function As input, we use the domain classifier to iteratively update the target domain prediction label. Step (5) Hybrid loss function and target domain final prediction label: First, the hyperplane obtained from model training is the domain classifier. The target domain samples are projected onto the hyperplane. Its bi-norm is the directed distance from the sample to the domain classifier. The predicted label is one-hot encoded. By calculating the directed distance from the target domain sample to the domain classifier, the distance between the target domain sample and the source domain sample is obtained, and the target domain sample is given a greater weight. Secondly, by adding manifold-related terms to the regularization term of the model, the target domain sample label prediction results with large weights will be more accurate. Therefore, the first two terms of the unique hot labels of the large-weight samples are assigned to the small-weight samples to complete the natural transfer of labels. The two parts are unified into the hybrid loss function as input, and the domain classifier is used to obtain the final predicted label of the target domain.
2. The transfer learning method combining intra-class feature alignment and flexible hyperparameter metric learning according to claim 1, characterized in that: The objective function of the CDELM is: h(x Tj )β=f(x Tj ),j=1,...,n t Where β is the marginal hyperparameter, e Si is the prediction error vector of the i-th source domain sample, h(x Si ),h(x Tj ) is the random data of source domain and target domain samples, y Si ,f(x Tj ) are the true label vector and predicted label vector of the i-th source domain sample and the j-th target domain sample, respectively. is the projected MMD distance between the source domain and the target domain, α ij represents the pairwise similarity between the i-th and j-th target domain samples, and C, λ, and γ>0 control the influence of the prediction error of the source domain data, the projected MMD distance between the two domains, and the prediction consistency of similar target domain samples, respectively.
3. The transfer learning method combining intra-class feature alignment and flexible hyperparameter metric learning according to claim 1, characterized in that: In the step (4), Expressed in matrix form, in, is a (n s +n t )×(n s +n t )-dimensional conditional distribution distance metric matrix, Each element in can be represented as, Among them, j, k represent the number of rows and columns of the conditional distribution distance metric matrix, and the marginal hyperparameter β * Will be along with the random data matrix H of the source domain and target domain samples, and the marginal distribution distance metric matrix V C changes with the changes.
4. The transfer learning method combining intra-class feature alignment and flexible hyperparameter metric learning according to claim 1, characterized in that: The target domain classifier is expressed as: H(w,b)={x|w T x=b}, where w is a vector perpendicular to the hyperplane and b is a constant.