Training Methods for Domain-Adaptive Neural Networks

By filtering pseudo labels through voting strategies, constructing multiple loss functions and adaptive attenuation rates, the problems of pseudo label accuracy and training efficiency in unsupervised domain adaptation are solved, and the recognition ability and adaptability of the model in the target domain are improved.

CN114139676BActive Publication Date: 2025-10-03FUJITSU LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010911149.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-02
Publication Date
2025-10-03
Estimated Expiration
2041-04-03

AI Technical Summary

Technical Problem

Existing unsupervised domain adaptation methods have poor performance in the target domain, insufficient pseudo-label accuracy, fixed decay rate in knowledge distillation leading to poor performance, and complex and inefficient training process.

Method used

A voting strategy is adopted to filter pseudo labels, and semantic alignment, cross entropy, contrastive learning and data distillation loss functions are constructed. The decay rate is adaptively adjusted, and the self-ensemble teacher model is improved to improve pseudo label accuracy and model performance.

Benefits of technology

The model recognition ability of the target domain is improved, the accuracy of pseudo labels and training efficiency are improved, and the adaptability and recognition performance of the model in the target domain are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114139676B_ABST
    Figure CN114139676B_ABST
Patent Text Reader

Abstract

Disclosed is a training method for a domain adaptive neural network, comprising: extracting features from source data and target data; predicting a first label for the target data based on the extracted features; determining a second label for the target data based on the distance between the class center of each class on the source data set and the features of the target data; selecting target data in the target data set whose first label is the same as the second label, and using the first or second label as a pseudo-label for the selected target data; calculating the class center of each class on the target data set based on the selected target data; constructing a first loss function based on the distance between the class center of the source data set and the calculated class center of the target data set; constructing a second loss function based on the selected target data and its pseudo-label; constructing a third loss function for the source data in the source data set and the selected target data; and training the neural network based on the first to third loss functions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates generally to domain adaptation, and more particularly to a neural network and a training method thereof for unsupervised domain adaptation. Background Art

[0002] Unsupervised domain adaptation involves migrating a model trained on labeled source data to a target domain with unlabeled data, while maintaining the model's performance in the target domain as much as possible. Due to dataset bias between the source and target domains and the lack of labeled data in the target domain, models trained on labeled source data often perform poorly in the target domain. Unsupervised domain adaptation training utilizes both labeled data from the source domain and unlabeled data from the target domain, effectively mitigating domain discrepancies and improving model robustness.

[0003] Currently, mainstream approaches to unsupervised domain adaptation include methods that learn domain-invariant features, exemplified by adversarial training. A typical adversarial training approach is the domain adversarial neural network. In this approach, a domain discriminator is added after the feature extraction network to determine whether features originate from the source or target domain. A gradient reversal layer is then added between the feature extraction network and the domain discriminator. This gradient reversal layer enables the feature extraction network to learn domain-invariant features while minimizing the domain discriminator's loss function.

[0004] In addition, knowledge distillation has recently been introduced to the problem of unsupervised domain adaptation, and many new methods have been developed, such as: using a self-ensembled average teacher model to guide the student model to learn the unlabeled data of the target domain; using the self-ensembled teacher model to obtain more accurate pseudo-labels of the target data; distilling data similar to the target data from the source data to fine-tune the pre-trained model; aligning the features of the source and target domains at the semantic level (category level), that is, bringing the average features (class centers) of the same categories in the source and target domains closer.

[0005] The following is a brief introduction to these existing methods.

[0006] Figure 1 Figure 2 shows the architecture of a typical domain adversarial neural network. Figure 1 As shown, the domain adversarial neural network includes feature extractor F, classifier C s And domain discriminator D. The domain discriminator D is connected to the feature extractor F through the gradient reversal layer. The gradient reversal layer multiplies the gradient by a specific negative number and then returns it to the feature extractor F. s Represents the labeled source data, I t Represents the unlabeled target data, and both are input to the feature extractor F. The features extracted by the feature extractor F for the source data are input to the classifier Cs , to predict the category of the source data. In addition, the features extracted by the feature extractor F for both the source data and the target data are input to the domain discriminator D, which determines whether the currently processed data is from the source domain or the target domain based on the input features. The classification cross entropy loss function L for the source domain is used in the training of the domain adversarial neural network. c And the binary cross entropy loss function L in domain discrimination adv , so that the loss function L c and L adv With minimization as the goal, training is performed according to the standard back-propagation algorithm, so that the feature extractor F learns domain-invariant features.

[0007] Figure 2 The architecture of the self-ensemble teacher model is shown, where the teacher network is constructed using the exponential moving average of the parameters of the student network. Figure 2 In, x Si represents the labeled source data, x Ti represents the unlabeled target data, y Si represents the true label of the source data, z Ti represents the predicted probability of the student network for the target data, represents the predicted probability of the teacher network for the target data.

[0008] The premise of this scheme is that the prediction accuracy of the teacher network is higher than that of the student network, and the student network can learn the implicit knowledge of the target data from the prediction probability of the teacher network, so this is a knowledge distillation method. Si , using the predicted probability z based on the student network Ti and the true label y Si Cross entropy loss function. For target data x Ti , using the predicted probability of the teacher network and the predicted probability z of the student network Ti The mean square error of is used as the loss function. Then, the above two loss functions are weightedly added to obtain the final loss function.

[0009] In addition, regarding feature alignment at the semantic level, the following loss functions have been proposed:

[0010]

[0011]

[0012] Among them, X s,k Indicates the source domain X s All data samples belonging to the kth class (determined according to the true label), X t,k Represents the target domain Xt All data samples in λ are labeled as class k (determined by pseudo labels). s,k represents the class center of the kth class in the source domain, that is, the average value of the feature F of all source data belonging to the kth class. Similarly, λ t,k represents the class center of the kth class in the target domain, that is, the average value of the feature F of all target data marked as the kth class. The pseudo label of the target data is obtained by using the classifier to predict the category of the target data. The semantic alignment loss function L shown in mathematical formula (1) is a (X s ,X t ) represents the distance between the class centers of the same category in the source and target domains.

[0013] Although the above methods have achieved good results, they still have some issues that need to be improved. First, for semantic alignment, the correctness of the pseudo-labels of the target data has a greater impact on the class center in the target domain. For some data located around the interface, if the pseudo-labels are wrong, the calculation results of the class center will have a large deviation. Second, for contrastive learning, incorrect pseudo-labels will undermine the constraints of intra-class data sample aggregation and inter-class data sample separation. In addition, for the self-ensemble average teacher model, a fixed decay rate is often used in the exponential moving average. However, the performance of the current model is changing, and the fixed decay rate cannot adjust the integration rate according to the performance of the current model. In addition, for fine-tuning using distilled data, this method requires two stages, which adds the operation of intermediate switching and cannot complete the training in one step. Summary of the Invention

[0014] According to one aspect of the present invention, a method for training a domain adaptive neural network implemented by a computer is provided, wherein the domain adaptive neural network includes a first feature extraction unit, a first classification unit, and a discrimination unit, wherein the computer includes a memory and a processor storing instructions, and the instructions, when executed by the processor, cause the processor to execute the method, wherein the method includes: extracting a first feature for source data in a labeled source data set by the first feature extraction unit, and predicting the probability of the source data belonging to each of a plurality of categories based on the first feature by the first classification unit; extracting a second feature for target data in an unlabeled target data set by the first feature extraction unit, and predicting the probability of the target data belonging to each of the categories based on the second feature by the first classification unit, and determining the category corresponding to the maximum probability as the first label of the target data ; Calculate the distance between the class center of the source data set for each category and the feature of the target data, and determine the category corresponding to the class center closest to the class center as the second label of the target data; Select target data in the target data set for which the first label and the second label are the same, wherein the first label or the second label is used as the pseudo label of the selected target data; Calculate the class center of the target data set for each category based on the selected target data; Construct a first loss function based on the distance between the class center of the source data set and the calculated class center of the target data set; Construct a second loss function based on the selected target data and its pseudo label; Construct a third loss function for the source data in the source data set and the selected target data; Train the domain adaptive neural network based on the first loss function, the second loss function and the third loss function.

[0015] According to another aspect of the present invention, there is provided an apparatus for training a domain adaptive neural network, the domain adaptive neural network comprising: a first feature extraction unit for extracting a first feature for source data in a labeled source data set, and a second feature for target data in an unlabeled target data set; a first classification unit for predicting the probability that the source data belongs to each of a plurality of categories based on the first feature, and for predicting the probability that the target data belongs to each of the categories based on the second feature, and determining the category corresponding to the maximum probability as the first label of the target data; and a discrimination unit for determining the probability that the currently input data is the source data based on the first feature and the second feature; the apparatus comprising: a memory storing a program; and one or more processors for performing the following operations by executing the program: calculating the probability of the source data set; The method comprises the following steps: calculating the distance between the class center of each class and the feature of the target data, and determining the class corresponding to the class center closest to the class center as the second label of the target data; selecting target data in the target data set for which the first label and the second label are the same, wherein the first label or the second label is used as a pseudo label for the selected target data; calculating the class center of each class of the target data set based on the selected target data; constructing a first loss function based on the distance between the class center of the source data set and the calculated class center of the target data set; constructing a second loss function based on the selected target data and its pseudo label; constructing a third loss function for the source data in the source data set and the selected target data; and training the domain adaptive neural network based on the first loss function, the second loss function and the third loss function.

[0016] According to another aspect of the present invention, there is provided a storage medium storing a program for training a domain adaptive neural network, wherein the domain adaptive neural network includes a first feature extraction unit, a first classification unit, and a discrimination unit, and when the program is executed by a computer, the computer executes a method comprising the following steps: the first feature extraction unit extracts a first feature for source data in a labeled source data set, and the first classification unit predicts the probability that the source data belongs to each of a plurality of categories based on the first feature; the first feature extraction unit extracts a second feature for target data in an unlabeled target data set, and the first classification unit predicts the probability that the target data belongs to each of the categories based on the second feature, and determines the category corresponding to the maximum probability as the first label of the target data; and calculates the probability of the source data set for each of the categories. The method comprises the following steps: calculating the distance between the class center of each category and the feature of the target data, and determining the category corresponding to the class center closest to the class center as the second label of the target data; selecting target data in the target data set for which the first label and the second label are the same, wherein the first label or the second label is used as a pseudo label for the selected target data; calculating the class center of the target data set for each category based on the selected target data; constructing a first loss function based on the distance between the class center of the source data set and the calculated class center of the target data set; constructing a second loss function based on the selected target data and its pseudo label; constructing a third loss function for the source data in the source data set and the selected target data; and training the domain adaptive neural network based on the first loss function, the second loss function and the third loss function. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 Schematic diagram of the architecture of existing domain adversarial neural networks.

[0018] Figure 2 The architecture of the existing self-ensemble teacher model is schematically shown.

[0019] Figure 3 The architecture of the domain adaptive neural network according to the present invention is schematically shown.

[0020] Figure 4 The architecture of the self-integrated teacher model according to the present invention is schematically shown.

[0021] Figure 5 The curve for the weight λ1 is shown.

[0022] Figure 6 The curve of the weight λ2 is shown.

[0023] Figure 7 A flowchart of a method for generating a preferred target data set according to the present invention is shown.

[0024] Figure 8 A flowchart of a method for training a domain adaptive neural network according to the present invention is shown.

[0025] Figure 9 A modular block diagram of a training device for a domain adaptive neural network according to the present invention is shown.

[0026] Figure 10 A block diagram showing an exemplary configuration of computer hardware for implementing the present invention is shown. DETAILED DESCRIPTION

[0027] Figure 3 The architecture of the neural network for unsupervised domain adaptation according to the present invention is schematically shown. Figure 3 As shown, the neural network includes reference Figure 1 The domain adversarial neural network described includes a first feature extractor 310, a first classifier 320, a domain discriminator 330, and a gradient reversal layer (not shown). In addition, the neural network also includes a second feature extractor 310_T and a second classifier 320_T. It should be noted that, as a known technology, Figure 3 The feature extractors 310, 310_T, classifiers 320, 320_T, and domain discriminator 330 in FIG can all be implemented by convolutional neural networks. The structure of the convolutional neural networks that implement these units will not be described in detail herein.

[0028] The first feature extractor 310 and the first classifier 320 form a student network, and the second feature extractor 310_T and the second classifier 320_T form a teacher network. The parameters of the second (teacher) feature extractor 310_T are the exponential moving average of the parameters of the first (student) feature extractor 310, and the parameters of the second (teacher) classifier 320_T are the exponential moving average of the parameters of the first (student) classifier 320.

[0029] Source data X s and target data X t is input to each of the first feature extractor 310 and the second feature extractor 310_T. The first feature extractor 310 will extract the source data X s and target data X t The extracted features are input to the first classifier 320, and the second feature extractor 310_T will be used for the source data X s and target data X t The extracted features are input to the second classifier 320_T.

[0030] exist Figure 3In the training of the domain adaptive neural network shown in FIG, the present invention proposes multiple loss functions, which will be described in detail below.

[0031] As one aspect of the present invention, a voting strategy is proposed to improve the accuracy of the pseudo labels of target data. The voting strategy refers to using at least two prediction methods to vote on the predicted labels of target data. As an example, for target data Use the classifier to predict its category label to obtain the prediction result In addition, the class center nearest neighbor algorithm is used to predict its label to obtain the prediction result l d , as shown in the following mathematical formulas (2) and (3).

[0032]

[0033]

[0034] Among them, λ s,k represents the class center of the kth class in the source domain, that is, the average value of the features of all source data belonging to the kth class, K represents the number of all classes in the source domain, l d Indicates that among all K class centers in the source domain, The class corresponding to the closest class center.

[0035] If the predicted label l c and predicted label l d If the target data is consistent, Select and predict label l c or l d As the target data If the predicted label l c and predicted label l d If they are inconsistent, the target data will be discarded All selected target data Constructing the optimal target data set Compared to the case where only classifier prediction or only class center nearest neighbor prediction is performed, the dataset filtered in this way The accuracy of the pseudo label of each target data in is higher. Therefore, the voting strategy according to the present invention can effectively screen out target data with more accurate prediction results.

[0036] It should be noted that the classifier prediction and class center nearest neighbor prediction described above are merely examples of at least two different prediction methods, but the present invention is not limited thereto, and those skilled in the art can easily conceive of adopting other appropriate prediction methods.

[0037] Then, based on the selected target dataset To build for training Figure 3 The semantic alignment loss function L of the neural network shown a ( Figure 3 Specifically, taking the kth class among the K predetermined classes as an example, we first calculate the class center λ of the kth class in the source domain according to formula (2): s,k , and calculate the preferred target data set according to the following mathematical formula (4) The class center λ of the kth class in t,k , and then calculate the class center λ according to mathematical formula (5) s,k With class center λ t,k The distance between In this way, the distance between the class center of the source domain and the class center of the target domain is calculated for all K categories as the semantic alignment loss function. Minimization is the goal.

[0038]

[0039]

[0040] Since the target dataset is preferred The pseudo labels of the target data in the dataset have higher accuracy, so the The target domain class center λ is calculated t,k More accurate, thus helping to improve the role of semantic alignment loss function.

[0041] In addition, the preferred target dataset can be used The target data and its pseudo labels in are used to construct the training Figure 3 The cross entropy loss function of the first classifier 320 is shown as ( Figure 3 in ), also known as the second loss function, is specifically shown in the following mathematical formula (6):

[0042]

[0043] in, Indicates that the target dataset is selected Target data in When predicting a label, the prediction result is the probability of its pseudo label.

[0044] In the prior art, only the source data with real labels are used to train the first classifier 320. However, in the present invention, the target data set is preferably The accuracy of the pseudo-label of the target data in is higher, so the present invention further utilizes the preferred target data set Training the first classifier 320 helps improve the network model's ability to identify target data.

[0045] In addition, the target dataset is optimized The target data in can be used together with the source data for contrastive learning to achieve the following effects: constraining the intra-class features to make them more compact, while pushing the inter-class features apart to increase the distance between the features of different classes. In this regard, the contrastive learning loss function L can be constructed as shown in mathematical formula (7): con ( Figure 3 ), also called the third loss function.

[0046]

[0047] Among them, x i or x j Represents the source dataset and the preferred target dataset A data sample in f(x i ) and f(x j ) represents the characteristics of the data sample. ij is an indicator variable, when x i and x j For the same type of data, δ ij is 1; when x i and x j When the data are of different types, δ ij is 0. d(f(x i ),f(x j )) represents data x i and data x j The distance between features. m is a constant, for example, m=3.

[0048] As mentioned above, the knowledge distillation method currently used for unsupervised domain adaptation uses exponential moving average to construct the teacher network. However, the decay rate is usually set to a fixed value, making it difficult to obtain a teacher network with good performance. Specifically, exponential moving average refers to slowly updating the parameters of the teacher network according to a certain decay rate, as shown in the following mathematical formula (8):

[0049] T t =decay*T t-1 +(1-decay)*S, -(8)

[0050] Among them, S represents the current parameters of the student network, T t represents the current parameters of the teacher network (updated parameters), T t-1 represents the previous parameters of the teacher network (parameters that have not been updated), and the decay rate decay is usually fixed to 0.99.

[0051] As another aspect of the present invention, the present invention proposes a self-learning decay rate to improve the performance of the teacher model. "Self-learning" means that the decay rate is a learnable parameter or the output of a learnt network. In the present invention, a differentiable variable can be used as the decay rate, or the output of a fully connected layer can be used as the decay rate. In the latter case, for example, the fully connected layer can be set at the same level as the output layer of the second classifier 320_T, so that the fully connected layer is connected to the previous layer of the output layer in parallel with the output layer. The decay rate set in these two ways is no longer a fixed value, and it can adjust the rate of integration according to the performance of the model changes, thereby helping to improve the performance of knowledge distillation.

[0052] Furthermore, as another aspect of the present invention, data distillation based on a domain discriminator is proposed. Specifically, when training a classifier using source data using a cross-entropy loss function, a higher weight is assigned to source data that is similar to the target data. This allows source data with high similarity to the target data to play a greater role in training, resulting in a trained classifier that achieves better performance in the target domain.

[0053] The output of the domain discriminator can be used to determine which source data has a high similarity to the target data. The domain discriminator predicts the probability that the current data is the source data. Therefore, the lower this probability, the greater the similarity between the current data and the target data. In other words, there is an inverse relationship between the probability output by the domain discriminator and the similarity. Therefore, the output of the domain discriminator can be used to weight the source data.

[0054] Based on this principle, we can construct Figure 3 The data distillation loss function L for the neural network shown dd ( Figure 3 (not shown), also known as the fourth loss function, as shown in the following mathematical formula (9) or (10):

[0055] L dd =∑-(1-p d )log(p s ) -(9)

[0056] or

[0057] L dd =∑-(1 / p d )log(p s ) -(10)

[0058] Among them, p s Indicates the probability that the predicted result is the true label when predicting the label of the source data. drepresents the probability that the source data determined by the domain discriminator comes from the source domain, 1-p d or 1 / p d Indicates the weight given to the source data.

[0059] When the domain discriminator determines the probability p d When it is smaller (indicating that the current source data and target data have a high similarity), then 1-p d or 1 / p d The value of is large, so the weight given to the current source data is large. Therefore, the current source data (similar to the target data) can play a greater role in training.

[0060] In addition, as another aspect of the present invention, the present invention also improves Figure 2 The architecture of the self-ensemble teacher model shown. Figure 4 The improved network architecture is shown.

[0061] like Figure 4 As shown, the source data x Si and target data x Ti is input not only to the student network but also to the teacher network. Figure 2 In the teacher network, only the target data x is input Ti Therefore, the present invention not only performs distillation learning on the target domain, but also performs distillation learning on the source domain.

[0062] exist Figure 4 middle, y Si Represents the source data x Si The true label, z Ti Represents the student network for the target data x Ti The predicted probability (ie the target data x Ti The probability of belonging to each category), Represents the teacher network for the target data x Ti The predicted probability, z Si Represents the student network for the source data x Si The predicted probability (i.e. the source data x Si The probability of belonging to each category), Represents the teacher network for the source data x Si The predicted probability. In addition, Figure 4 Student networks in Figure 3 The first feature extractor 310 and the first classifier 320 shown, Figure 4 The teacher network in Figure 3 The second feature extractor 310_T and the second classifier 320_T shown in FIG. 3 , the above-mentioned respective prediction probabilities can be generated by the first classifier 320 or the second classifier 320_T.

[0063] Based on the above prediction probabilities, we can construct Figure 3 The knowledge distillation loss function L of the neural network shown kd (include Figure 3 L in kd-s and L kd-t ), also known as the fifth loss function, is shown in the following mathematical formula (11):

[0064]

[0065] in, The first classifier 320 and the second classifier 320_T are respectively for the source data x Si The mean squared error of the predicted probability, The first classifier 320 and the second classifier 320_T are respectively for the target data x Ti The mean square error of the predicted probability. n represents the number of source data, and m represents the number of target data.

[0066] Based on the first to fifth loss functions discussed above, we can construct Figure 3 The final loss function L of the neural network shown is shown in mathematical formula (12):

[0067]

[0068] Among them, L c-s Represents the classification cross entropy loss function for the source data, and Figure 1 The loss function L shown in c Same. adv represents the binary cross entropy loss function of the domain discriminator, and Figure 1 The loss function L shown in adv Same. Since the loss function L c-s and L adv It is a loss function known in the prior art, so its detailed description will be omitted in this article.

[0069] In addition, λ1 and λ2 in equation (12) are the fourth loss function L kd And the fifth loss function L dd The weighted value can be used to control the degree to which the fourth loss function and the fifth loss function work during the training process. Specifically, the weight λ1 can be determined according to mathematical formula (13):

[0070] λ1=α·p n -(13)

[0071] Where p = step / total step, that is, the quotient of the current iteration step divided by the total number of training steps, so p can represent the training progress. α and n represent hyperparameters, for example, α = 200 and n = 10 can be set. Figure 5 The figure shows the curve of the weight λ1 changing with the increase of the number of training steps (assuming that the total number of training steps is 5000).

[0072] The weight λ2 can be determined according to formula (14):

[0073] λ2=α·min((2p) n ,1) -(14)

[0074] Wherein, p has the same meaning as p in equation (13). α and n represent hyperparameters, for example, α=5 and n=10 can be set. Figure 6 The figure shows the curve of the weight λ2 changing with the increase of the number of training steps (assuming that the total number of training steps is 5000).

[0075] like Figure 5 and Figure 6 As shown in Figure 2, at the beginning of training, since the predictions of the classifier and the domain discriminator are inaccurate, it is preferred to set the values ​​of λ1 and λ2 to be small. As the training progresses, the predictions of the teacher network's classifier and domain discriminator gradually become accurate, so the values ​​of λ1 and λ2 can be gradually increased to make the knowledge distillation loss function L kd And the data distillation loss function L dd Can play a greater role.

[0076] Figure 7 FIG. 1 is a flow chart showing a method for generating a preferred target data set according to the present invention. Figure 9 The preferred target data set generation unit 960 is executed.

[0077] like Figure 7 As shown, in step S710, the first feature extractor 310 extracts features from the source data, and the first classifier 320 predicts the probability that the source data belongs to each of a plurality of predetermined categories based on the extracted features. The category corresponding to the maximum probability is determined as the label of the source data.

[0078] In step S720, the first feature extractor 310 extracts features from the target data, and the first classifier 320 predicts the probability of the target data belonging to each category based on the extracted features. The category corresponding to the maximum probability will be determined as the first label of the target data.

[0079] In step S730, according to equations (2) and (3), a cluster center nearest neighbor algorithm is used to determine the second label of the target data.

[0080] In step S740, target data for which the first label and the second label are the same are selected, and the first label or the second label is used as a pseudo label for the selected target data. Then, all the selected target data can constitute a preferred target data set.

[0081] Figure 8 FIG. 4 is a flow chart showing a method for training a domain adaptive neural network according to the present invention. Figure 9 A modular block diagram of a training device for a domain adaptive neural network according to the present invention is shown.

[0082] like Figure 8 As shown, in step S810, according to mathematical formulas (2), (4) and (5), a first loss function L is constructed based on the distance between the class center of the source data set and the class center of the preferred target data set. a (Semantic alignment loss function). This step can be done by Figure 9 The first loss function generating unit 910 in is executed.

[0083] In step S820, according to formula (6), a second loss function is constructed based on the target data in the preferred target data set and its pseudo label. (cross entropy loss function). This step can be done by Figure 9 The second loss function generation unit 920 in is executed.

[0084] In step S830, according to formula (7), a third loss function L is constructed for the source data in the source data set and the target data in the preferred target data set. con (Comparative learning loss function). This step can be done by Figure 9 The third loss function generating unit 930 in is executed.

[0085] Combine Figure 9 As you can see, through Figure 7 The preferred target data set generated by the method shown is used to construct the first loss function to the third loss function.

[0086] Then, in step S840, according to equation (9) or (10), a fourth loss function L is constructed based on the probability output by the domain discriminator. dd (Data distillation loss function). This step can be done by Figure 9 The fourth loss function generating unit 940 in is executed.

[0087] In step S850, the second (teacher) feature extractor 310_T extracts features of the source data and the target data, and the second (teacher) classifier 320_T predicts labels of the source data and the target data. Then, in step S860, according to equation (11), a fifth loss function L is constructed based on the prediction results of the first classifier 320 and the second classifier 320_T. kd (Knowledge distillation loss function). Step S860 can be done by Figure 9 The fifth loss function generating unit 950 in is executed.

[0088] Then, in step S870, according to formula (12), the neural network is trained based on the weighted combination of the first to fifth loss functions. This step can be done by Figure 9 The training unit 970 in is executed.

[0089] It should be noted that it is not necessary to follow Figure 8 For example, the order of generating the first to fifth loss functions may be different from that shown in the figure, or may be generated simultaneously.

[0090] The present inventors have conducted tests on MNIST, USPS, and SVHN (all well-known character datasets), including domain adaptation in three directions: MNIST→USPS, USPS→MNIST, and SVHN→MNIST. Table 1 below shows a performance comparison between the present invention's solution and existing technologies (such as ADDA and DANN). The values ​​in Table 1 represent classification accuracy; higher accuracy indicates better solution performance. As can be seen, the present invention's solution performs comparable to or even better than existing solutions.

[0091] MNIST → USPS USPS → MNIST SVHN→MNIST source only 81.6±0.02 52.1±0.1 73.8±0.06 DANN 77.1±1.8 73.0±2.0 73.9 ADDA 89.4±0.2 90.1±0.8 76.0±1.8 CAT+RevGrad 94.0±0.7 96.0±0.9 98.8±0.02 The present invention 96.5±0.01 96.1±0.0 98.3±0.0

[0092] In particular, the “source only” in Table 1 represents a scheme that uses only source data for training without using target data. It is the simplest scheme and serves as a benchmark for comparison. Figure 1The domain adversarial neural network shown, ADDA (Adversarial Discriminative Domain Adaptation) stands for Adversarial Discriminative Domain Adaptation. CAT+RevGrad is described in the following technical paper: “Cluster Alignment with a Teacher for Unsupervised Domain Adaptation[C]”, Deng Z et al., Proceedings of the IEEE International Conference on Computer Vision, 2019: 9944–9953.

[0093] The unsupervised domain adaptation technology according to the present invention can be applied to a wide range of fields. The following only provides representative application scenarios by way of example.

[0094] [Application Scenario 1] Semantic Segmentation

[0095] Semantic segmentation involves marking parts of an image that represent different objects with different colors. In semantic segmentation applications, real-world images rarely come with labels, as manual labeling is very expensive. In this case, an alternative approach is to use images from scenes in simulation environments (such as 3D games) for training. Since it is easy to programmatically automatically label objects in simulation environments, labeled data is readily available. In this way, the model is trained using labeled data generated in the simulation environment, and the trained model is then used to process images from the real world. However, since simulation environments are unlikely to be completely identical to the real world, the performance of models trained using data from simulation environments will be significantly reduced when processing images from the real world.

[0096] In this case, using the domain adaptation technology of the present invention, training can be performed based on labeled simulation environment data and unlabeled real environment data, thereby improving the performance of the model in processing real environment images.

[0097] [Application Scenario 2] Handwritten Character Recognition

[0098] Handwritten characters typically include numbers and text (such as Chinese and Japanese). Labeled character sets such as MNIST, USPS, and SVHN are commonly used for handwritten character recognition. Models are typically trained using these labeled character data. However, when the trained model is applied to real (unlabeled) handwritten character recognition, its accuracy may decrease.

[0099] In this case, using the domain adaptation technology of the present invention, training can be performed based on labeled source data and unlabeled target data, thereby improving the performance of the model in processing target data.

[0100] [Application Scenario 3] Classification and Prediction of Time Series Data

[0101] For example, predictions for time series data include air pollution index predictions, ICU length of stay (LOS) predictions, and stock market forecasts. For example, using time series data for the PM 2.5 index, a prediction model can be trained using a labeled training set of samples. After training, the trained model can be applied to actual predictions. For example, using unlabeled data from the 24 hours prior to the current moment to predict the PM 2.5 index range three days from now, the model can be used.

[0102] In this scenario, by using the domain adaptation technology of the present invention, the model can be trained based on labeled data and unlabeled data, thereby improving the prediction accuracy of the model.

[0103] [Application Scenario 4] Classification and Prediction of Tabular Data

[0104] Tabular data may include financial data, such as online lending data. In this example, in order to predict whether a borrower is likely to default on a loan, a prediction model may be constructed and trained using the method according to the present invention.

[0105] [Application Scenario 5] Image Recognition

[0106] Similar to semantic segmentation, image recognition or classification applications also face the high cost of labeling real-world image datasets. Therefore, the domain adaptation techniques of the present invention can be used to select a labeled dataset (such as ImageNet) as a source dataset and train on this source dataset and an unlabeled target dataset to obtain a model with satisfactory performance.

[0107] The methods described in the above embodiments can be implemented by software, hardware, or a combination of software and hardware. The programs included in the software can be stored in advance in a storage medium provided inside or outside the device. As an example, during execution, these programs are written to a random access memory (RAM) and executed by a processor (e.g., a CPU), thereby implementing the various methods and processes described herein.

[0108] Figure 10This block diagram shows an example configuration of computer hardware that executes the method of the present invention according to a program. This computer hardware is an example of an apparatus for training the domain-adaptive neural network of the present invention. In addition, the domain-adaptive neural network of the present invention can also be implemented based on this computer hardware.

[0109] like Figure 10 As shown, in a computer 1000 , a central processing unit (CPU) 1001 , a read only memory (ROM) 1002 , and a random access memory (RAM) 1003 are connected to one another via a bus 1004 .

[0110] An input / output interface 1005 is further connected to the bus 1004. The following components are connected to the input / output interface 1005: an input unit 1006 formed of a keyboard, a mouse, a microphone, etc.; an output unit 1007 formed of a display, a speaker, etc.; a storage unit 1008 formed of a hard disk, a non-volatile memory, etc.; a communication unit 1009 formed of a network interface card (such as a local area network (LAN) card, a modem, etc.); and a drive 1010 for driving a removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory.

[0111] In the computer having the above-described structure, the CPU 1001 loads the program stored in the storage unit 1008 into the RAM 1003 via the input / output interface 1005 and the bus 1004 and executes the program, so as to perform the method described above.

[0112] The program to be executed by the computer (CPU 1001) can be recorded on a removable medium 1011 as a package medium, and the package medium is formed in the form of, for example, a magnetic disk (including a floppy disk), an optical disk (including a compact disc-read only memory (CD-ROM)), a digital versatile disc (DVD), etc.), a magneto-optical disk, or a semiconductor memory. In addition, the program to be executed by the computer (CPU 1001) can also be provided via a wired or wireless transmission medium such as a local area network, the Internet, or digital satellite broadcasting.

[0113] When the removable medium 1011 is mounted in the drive 1010, the program can be installed in the storage unit 1008 via the input / output interface 1005. In addition, the program can be received by the communication unit 1009 via a wired or wireless transmission medium and installed in the storage unit 1008. Alternatively, the program can be pre-installed in the ROM 1002 or the storage unit 1008.

[0114] The program executed by the computer may be a program that performs processing in accordance with the sequence described in this specification, or may be a program that performs processing in parallel or when necessary, such as when called.

[0115] The units or devices described herein are only logical and do not strictly correspond to physical devices or entities. For example, the functions of each unit described herein may be implemented by multiple physical entities, or the functions of multiple units described herein may be implemented by a single physical entity. In addition, the features, components, elements, steps, etc. described in one embodiment are not limited to that embodiment, but may also be applied to other embodiments, for example, replacing specific features, components, elements, steps, etc. in other embodiments, or combining them.

[0116] The scope of the present invention is not limited to the specific embodiments described herein. It should be understood by those skilled in the art that, depending on design requirements and other factors, various modifications or variations may be made to the embodiments herein without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.

[0117] Note:

[0118] (1) A method for training a domain adaptive neural network implemented by a computer, wherein the domain adaptive neural network includes a first feature extraction unit, a first classification unit, and a discrimination unit, wherein the computer includes a memory storing instructions and a processor, wherein the instructions, when executed by the processor, cause the processor to perform the method, the method comprising:

[0119] The first feature extraction unit extracts a first feature from source data in the labeled source data set, and the first classification unit predicts a probability that the source data belongs to each of a plurality of categories based on the first feature;

[0120] The first feature extraction unit extracts a second feature for target data in the unlabeled target data set, and the first classification unit predicts the probability that the target data belongs to each of the categories based on the second feature, and determines the category corresponding to the maximum probability as the first label of the target data;

[0121] Calculating the distance between the class center of each class of the source data set and the feature of the target data, and determining the class corresponding to the class center with the closest distance as the second label of the target data;

[0122] Selecting target data in the target data set for which the first label and the second label are the same, wherein the first label or the second label is used as a pseudo label for the selected target data;

[0123] Calculating a class center for each class of the target data set based on the selected target data;

[0124] constructing a first loss function based on the distance between the class center of the source data set and the calculated class center of the target data set;

[0125] Constructing a second loss function based on the selected target data and its pseudo label;

[0126] Constructing a third loss function for the source data in the source data set and the selected target data;

[0127] The domain adaptive neural network is trained based on the first loss function, the second loss function, and the third loss function.

[0128] (2) The method according to (1), further comprising:

[0129] Determining, by the discrimination unit, a probability that the currently input data is the source data based on the first feature and the second feature;

[0130] constructing a fourth loss function based on the probability determined by the discriminant unit;

[0131] The domain adaptive neural network is trained based on the fourth loss function.

[0132] (3) The method according to (2), wherein the fourth loss function is constructed based on one of the following:

[0133] the inverse of the probability determined by the discriminant unit, and

[0134] 1 minus the difference in probabilities determined by the discriminant unit.

[0135] (4) The method according to (2), wherein the domain adaptive neural network further includes a second feature extraction unit and a second classification unit, and the method further includes:

[0136] The second feature extraction unit extracts a third feature from the source data, and the second classification unit predicts a probability that the source data belongs to each category based on the third feature;

[0137] The second feature extraction unit extracts a fourth feature from the target data, and the second classification unit predicts a probability that the target data belongs to each of the categories based on the fourth feature;

[0138] Constructing a fifth loss function based on the probability predicted by the first classification unit and the probability predicted by the second classification unit;

[0139] The domain adaptation neural network is trained based on the fifth loss function.

[0140] (5). The method according to (4), wherein the fifth loss function is constructed based on the mean square error of the probabilities predicted by the first classification unit and the second classification unit for the source data and the mean square error of the probabilities predicted by the first classification unit and the second classification unit for the target data.

[0141] (6) The method according to (4), wherein the parameters of the second feature extraction unit are the exponential moving average of the parameters of the first feature extraction unit, and the parameters of the second classification unit are the exponential moving average of the parameters of the first classification unit,

[0142] The decay rate used in the exponential moving average is obtained by one of the following methods:

[0143] Using a differentiable variable as the decay rate;

[0144] The decay rate is generated using a fully connected layer, wherein the fully connected layer is arranged to be connected to a previous layer of the output layer of the second classification unit in parallel.

[0145] (7) The method according to (4), wherein the domain adaptive neural network is trained based on a weighted combination of the first loss function, the second loss function, the third loss function, the fourth loss function, and the fifth loss function,

[0146] As the training progresses, the weights of the fourth loss function and the fifth loss function are gradually increased.

[0147] (8) The method according to (1), wherein the second loss function is a cross entropy loss function used to train the first classification unit.

[0148] (9) The method according to (1), wherein the discrimination unit is connected to the first feature extraction unit via a gradient reversal unit, and the discrimination unit and the first feature extraction unit operate in a mutually adversarial manner.

[0149] (10) The method according to (1), wherein the domain adaptive neural network is used to perform image recognition, and the source data and the target data are image data, or

[0150] The domain adaptive neural network is used to process financial data, and the source data and the target data are tabular data, or

[0151] The domain adaptive neural network is used to process environmental meteorological data or medical data, and the source data and the target data are time series data or image data.

[0152] (11) A device for training a domain adaptive neural network, the domain adaptive neural network comprising:

[0153] a first feature extraction unit configured to extract a first feature from source data in a labeled source data set and a second feature from target data in an unlabeled target data set;

[0154] a first classification unit that predicts a probability that the source data belongs to each of a plurality of categories based on the first feature, and predicts a probability that the target data belongs to each of the categories based on the second feature, and determines a category corresponding to a maximum probability as a first label of the target data; and

[0155] a discriminant unit, which determines a probability that the currently input data is the source data based on the first feature and the second feature;

[0156] The device comprises:

[0157] a memory storing a program; and

[0158] One or more processors, which, by executing the program, perform the following operations:

[0159] Calculating the distance between the class center of each class of the source data set and the feature of the target data, and determining the class corresponding to the class center with the closest distance as the second label of the target data;

[0160] Selecting target data in the target data set for which the first label and the second label are the same, wherein the first label or the second label is used as a pseudo label for the selected target data;

[0161] Calculating a class center for each class of the target data set based on the selected target data;

[0162] constructing a first loss function based on the distance between the class center of the source data set and the calculated class center of the target data set;

[0163] Constructing a second loss function based on the selected target data and its pseudo label;

[0164] Constructing a third loss function for the source data in the source data set and the selected target data;

[0165] The domain adaptive neural network is trained based on the first loss function, the second loss function, and the third loss function.

[0166] (12) A device for training a domain adaptive neural network, the domain adaptive neural network comprising:

[0167] a first feature extraction unit configured to extract a first feature from source data in a labeled source data set and a second feature from target data in an unlabeled target data set;

[0168] a first classification unit that predicts a probability that the source data belongs to each of a plurality of categories based on the first feature, predicts a probability that the target data belongs to each of the categories based on the second feature, and determines a category corresponding to a maximum probability as a first label of the target data; and

[0169] a discriminant unit, which determines a probability that the currently input data is the source data based on the first feature and the second feature;

[0170] The device comprises:

[0171] A preferred target data set generating unit is configured to: calculate the distance between the class center of each class in the source data set and the feature of the target data, and determine the class corresponding to the class center with the closest distance as the second label of the target data; select target data in the target data set for which the first label and the second label determined are the same, to form a preferred target data set, wherein the first label or the second label is used as a pseudo label for the selected target data;

[0172] A first loss function generating unit is configured to: calculate the class center of the target data set for each class based on the target data in the preferred target data set; construct a first loss function based on the distance between the class center of the source data set and the calculated class center of the target data set;

[0173] A second loss function generating unit, configured to construct a second loss function based on the target data in the preferred target data set and its pseudo label;

[0174] a third loss function generating unit configured to construct a third loss function for the source data in the source data set and the target data in the preferred target data set;

[0175] A training unit is configured to train the domain adaptive neural network based on the first loss function, the second loss function, and the third loss function.

[0176] (13) A storage medium storing a program for training a domain adaptive neural network, wherein the domain adaptive neural network includes a first feature extraction unit, a first classification unit, and a discrimination unit, wherein when the program is executed by a computer, the computer performs a method comprising the following steps:

[0177] The first feature extraction unit extracts a first feature from source data in the labeled source data set, and the first classification unit predicts a probability that the source data belongs to each of a plurality of categories based on the first feature;

[0178] The first feature extraction unit extracts a second feature for target data in the unlabeled target data set, and the first classification unit predicts the probability that the target data belongs to each of the categories based on the second feature, and determines the category corresponding to the maximum probability as the first label of the target data;

[0179] Calculating the distance between the class center of each class of the source data set and the feature of the target data, and determining the class corresponding to the class center with the closest distance as the second label of the target data;

[0180] Selecting target data in the target data set for which the first label and the second label are the same, wherein the first label or the second label is used as a pseudo label for the selected target data;

[0181] Calculating a class center for each class of the target data set based on the selected target data;

[0182] constructing a first loss function based on the distance between the class center of the source data set and the calculated class center of the target data set;

[0183] Constructing a second loss function based on the selected target data and its pseudo label;

[0184] Constructing a third loss function for the source data in the source data set and the selected target data;

[0185] The domain adaptive neural network is trained based on the first loss function, the second loss function, and the third loss function.

Claims

1. A computer-implemented method for training a domain adaptive neural network, wherein the domain adaptive neural network comprises a first feature extraction unit, a first classification unit, and a discrimination unit, wherein: The computer includes a memory storing instructions and a processor, wherein the instructions, when executed by the processor, cause the processor to perform the method, the method comprising: The first feature extraction unit extracts a first feature from source data in the labeled source data set, and the first classification unit predicts a probability that the source data belongs to each of a plurality of categories based on the first feature; The first feature extraction unit extracts a second feature for target data in the unlabeled target data set, and the first classification unit predicts the probability that the target data belongs to each of the categories based on the second feature, and determines the category corresponding to the maximum probability as the first label of the target data; Calculating the distance between the class center of each class of the source data set and the feature of the target data, and determining the class corresponding to the class center with the closest distance as the second label of the target data; Selecting target data in the target data set for which the first label and the second label are the same, wherein the first label or the second label is used as a pseudo label for the selected target data; Calculating a class center for each class of the target data set based on the selected target data; constructing a first loss function based on the distance between the class center of the source data set and the calculated class center of the target data set; Constructing a second loss function based on the selected target data and its pseudo label; Constructing a third loss function for the source data in the source data set and the selected target data; training the domain adaptive neural network based on the first loss function, the second loss function, and the third loss function, The source data and the target data include any one of image data, handwritten character data, time series data and table data.

2. The method according to claim 1, further comprising: Determining, by the discrimination unit, a probability that the currently input data is the source data based on the first feature and the second feature; constructing a fourth loss function based on the probability determined by the discriminant unit; The domain adaptive neural network is trained based on the fourth loss function.

3. The method according to claim 2, wherein: The fourth loss function is constructed based on one of the following: the inverse of the probability determined by the discriminant unit, and 1 minus the difference in probabilities determined by the discriminant unit.

4. The method according to claim 2, wherein: The domain adaptive neural network further includes a second feature extraction unit and a second classification unit, and the method further includes: The second feature extraction unit extracts a third feature from the source data, and the second classification unit predicts a probability that the source data belongs to each category based on the third feature; The second feature extraction unit extracts a fourth feature from the target data, and the second classification unit predicts a probability that the target data belongs to each of the categories based on the fourth feature; Constructing a fifth loss function based on the probability predicted by the first classification unit and the probability predicted by the second classification unit; The domain adaptation neural network is trained based on the fifth loss function.

5. The method according to claim 4, wherein The fifth loss function is constructed based on the mean square error of the probabilities predicted by the first classification unit and the second classification unit for the source data and the mean square error of the probabilities predicted by the first classification unit and the second classification unit for the target data.

6. The method according to claim 4, wherein: The parameters of the second feature extraction unit are the exponential moving average of the parameters of the first feature extraction unit, and the parameters of the second classification unit are the exponential moving average of the parameters of the first classification unit, The decay rate used in the exponential moving average is obtained by one of the following methods: Using a differentiable variable as the decay rate; The decay rate is generated using a fully connected layer, wherein the fully connected layer is arranged to be connected to a previous layer of the output layer of the second classification unit in parallel.

7. The method according to claim 4, wherein: training the domain adaptive neural network based on a weighted combination of the first loss function, the second loss function, the third loss function, the fourth loss function, and the fifth loss function, As the training progresses, the weights of the fourth loss function and the fifth loss function are gradually increased.

8. The method according to claim 1, wherein The second loss function is a cross entropy loss function used to train the first classification unit.

9. An apparatus for training a domain adaptive neural network, the domain adaptive neural network comprising: a first feature extraction unit configured to extract a first feature from source data in a labeled source data set, and to extract a second feature from target data in an unlabeled target data set; a first classification unit configured to predict a probability that the source data belongs to each of a plurality of categories based on the first feature, and to predict a probability that the target data belongs to each of the categories based on the second feature, and to determine a category corresponding to a maximum probability as a first label of the target data; as well as a discriminant unit configured to determine a probability that currently input data is source data based on the first feature and the second feature; The device comprises: a memory storing a program; and One or more processors, which, by executing the program, perform the following operations: Calculating the distance between the class center of each class of the source data set and the feature of the target data, and determining the class corresponding to the class center with the closest distance as the second label of the target data; Selecting target data in the target data set for which the first label and the second label are the same, wherein the first label or the second label is used as a pseudo label for the selected target data; Calculating a class center for each class of the target data set based on the selected target data; constructing a first loss function based on the distance between the class center of the source data set and the calculated class center of the target data set; Constructing a second loss function based on the selected target data and its pseudo label; Constructing a third loss function for the source data in the source data set and the selected target data; training the domain adaptive neural network based on the first loss function, the second loss function, and the third loss function, The source data and the target data include any one of image data, handwritten character data, time series data and table data.

10. A storage medium storing a program for training a domain adaptive neural network, wherein the domain adaptive neural network comprises a first feature extraction unit, a first classification unit, and a discrimination unit, wherein when the program is executed by a computer, the computer executes the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Sample classification method, device, storage medium and computer equipment

    CN110991538A

  • Training method and device of image classification model

    CN111507419A