Self-supervision domain adaptation method based on meta-learning
Technical Field
The invention belongs to the field of computer vision and image processing, and particularly relates to an unsupervised domain adaptation method based on meta-learning and image reconstruction, which can enable a source domain image classification task and a target domain image reconstruction task to tend to be consistent in a parameter updating direction of a feature extraction network, namely, the parameter updating direction of source domain image category information to the feature extraction network tends to tend to the parameter updating direction of the feature extraction network by utilizing information such as the spatial relationship, illumination and the like of an object in a target domain image, so that the features obtained by the feature extraction network are domain-invariant features, and the domain adaptation of a source domain and a target domain is realized.
Background
In recent years, supervised learning based on a deep neural network has been applied in many aspects, and is widely applied in the fields of image classification, target detection, semantic segmentation, natural language processing and the like, and the combination of artificial intelligence technology and real life is greatly promoted. However, many supervised learning methods usually assume that probability distributions of a training set sample and a test set sample obey the same distribution, and in addition, in order to make a network have better generalization performance and avoid an overfitting problem, a large number of labeled training samples are usually required in a training stage in a supervised learning mode. However, with the advent of the big data era, the data scale is increasing, and the problems of statistical property difference among different data sets, high labor cost of data annotation and the like are gradually revealed. In order to solve the above problems, unsupervised domain adaptation methods are widely studied. Unsupervised domain adaptation is a method to resolve the distribution differences between source and target domains by learning some generalizable knowledge in tagged source domain data and applying it to the task on untagged target domain data to improve the performance of the network on the target domain.
At present, many unsupervised domain adaptation methods mostly focus on aligning the feature probability distribution of source domain data and target domain data by adopting a distance measurement-based or countermeasure learning-based mode, so that the inter-domain difference is reduced, and a network can learn a domain-invariant feature space. However, these methods only perform distribution alignment from the whole of the source domain data and the target domain data, and do not pay attention to the influence of the intrinsic characteristics of the target domain data on the knowledge migration in the domain adaptation process, so the self-supervision domain adaptation method based on image reconstruction and the like performs joint training on the network by setting self-supervision tasks such as image reconstruction, image rotation angle prediction, image restoration and the like on the non-labeled target domain data in cooperation with the labeled source domain data, that is, assists the network to migrate the knowledge learned from the source domain data to the target domain by mining the intrinsic characteristics of the target domain data, and in addition, because the method based on image reconstruction keeps the integrity of the data while extracting the migratable characteristics in the domain adaptation, it is ensured that the information for improving the performance of a specific task in the target domain data is not damaged, and the original distribution of the target domain data is kept as much as possible in the knowledge migration process of the source domain data, the learned knowledge in the source domain data can thus be better applied in the target domain tasks. However, in the domain adaptation process, many existing unsupervised domain adaptation methods simply update parameters of the feature extraction network through specific tasks such as an unsupervised task and image classification respectively, whether the update directions of the two types of tasks to the parameters of the feature extraction network are consistent or not is not considered, negative effects may be caused to feature learning of the specific tasks such as the image classification by the supervised task, the specific tasks such as the unsupervised task and the image classification can be respectively used as a trainer and a tester through meta-learning, and the parameters of the tester network are updated through a loss function in the trainer, so that the update directions of the two types of tasks to the parameters of the network tend to be consistent.
Disclosure of Invention
Aiming at the defects in the prior art, the invention provides a self-supervision domain adaptation method based on Meta learning (Meta learning).
A self-supervision domain adaptation method based on meta-learning comprises the following steps:
step 1, setting a trainer and a tester:
and taking the reconstruction process of the target domain sample as a trainer in meta-learning, and taking the classification process of the source domain sample as a tester in the meta-learning.
Step 2, performing an image reconstruction task by using the target domain sample and calculating reconstruction loss:
inputting the label-free target domain sample into a feature extraction network to obtain target domain sample features, inputting the target domain sample features into an image reconstruction network to reconstruct images and calculating reconstruction loss.
And 3, updating parameters of the feature extraction network:
the parameters of the characteristic extraction network in the trainer are updated together with the parameters of the characteristic extraction network in the trainer due to weight sharing, namely, the parameter updating direction of the network in the tester tends to the parameter updating direction of the network in the trainer.
Step 4, performing a classification task by using the source domain samples and calculating a classification loss:
and inputting the source domain data with the labels into the feature extraction network after the parameters are updated to obtain the source domain data features, and then inputting the source domain data features into a classification network to perform an image classification task and calculate the classification loss.
Step 5, calculating a total loss function and updating parameters of all networks:
and calculating a total loss function, and updating parameters of the feature extraction network, the reconstruction network and the classification network in the trainer and the tester.
The invention has the following beneficial effects:
(1) the target domain image reconstruction is used as an automatic supervision task in the domain adaptation process, the supervision information is the target domain image, and no additional target domain image marking information is needed, so that a large amount of manual marking cost is saved; in addition, the reconstruction process of the target domain image enables the network to learn richer high-level semantic information in the target domain image, so that the network can assist the network to transfer the knowledge learned in the source domain data to the target domain by utilizing the intrinsic characteristics of the target domain data, and the performance of the domain adaptation method is improved.
(2) By introducing the meta-learning strategy into the self-supervision domain adaptation, the updating directions of the target domain self-supervision task, the source domain classification and other specific tasks to the network parameters tend to be consistent, so that the network can better extract domain invariant features, the problem of negative migration caused by the inconsistency of the updating directions of the domain adaptation task and the specific tasks to the network parameters is solved, and the domain adaptation performance is improved.
Drawings
Fig. 1 is a flowchart of an adaptive method for an adaptive domain based on meta-learning according to the present invention.
Fig. 2 is a network diagram of an adaptive method for an autonomous domain based on meta-learning according to the present invention.
Fig. 3 is a schematic diagram of basic units of a ResNet network.
Fig. 4 is a schematic view of a fully connected layer structure.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
As shown in fig. 1, a method for adaptive self-supervision domain based on meta-learning includes the following steps:
step 1, setting a trainer and a tester: as shown in fig. 2, target domain samples xtThe reconstruction process of (2) is used as a Meta-trainer (Meta-train) in Meta-learning, and the source domain sample x is used as a Meta-trainersAs a Meta-tester (Meta-test) in Meta-learning. The source domain with the label therein is denoted as S ═ { Xs,Ys},xs∈XsAnd ys∈YsRespectively representing source domain samples and corresponding labels, and an unlabeled target domain is denoted as T ═ XtIn which xt∈XtRepresenting a target domain sample.
Step 2, performing an image reconstruction task by using the target domain sample and calculating reconstruction loss:
target domain samples x to be unlabeled
tObtaining target domain sample characteristics f by input characteristic extraction network G
tThen the target domain sample characteristics f
tThe input image reconstruction network D carries out image reconstruction to obtain a target domain reconstruction sample
And meterCalculating reconstruction loss L
r. The feature extraction network G adopts a ResNet-50 structure, the basic unit of ResNet is shown in figure 3, the output of the previous layer is added with the output calculated by the current layer through jumping, and the summed result is input into the activation function as the output of the current layer. Obtaining target domain sample characteristics f through the characteristic extraction process of ResNet-50
t=G(x
t). The image reconstruction network D adopts a decoder structure and carries out a series of upsampling on the target domain sample characteristics f
tReduced to the original size, i.e.
The reconstruction loss is:
wherein N istIs the number of samples in the target domain, and j is the jth sample in the target domain.
And 3, updating parameters of the feature extraction network:
using reconstruction loss L in the trainerrUpdating parameters of the feature extraction network G, namely:
wherein
The parameters of the network are extracted for the current features,
extracting the parameters of the network for the updated features, alpha is the learning rate,
are the parameters of the decoder D and,
representation of parameters
And (5) solving the gradient, wherein a random gradient descent algorithm is adopted for gradient descent. Due to weight sharing, the parameter theta of the feature extraction network G in the tester and the parameter theta of the feature extraction network G in the trainer are updated together, namely, the parameter updating direction of a specific task such as image classification in the tester to the network is forced to trend to the parameter updating direction of an automatic supervision image reconstruction task in the trainer to the network.
Step 4, performing a classification task by using the source domain samples and calculating a classification loss: source domain data x to be tagged
sThe input parameter updated feature extraction network G obtains the source domain data feature f
sThen the source domain data is characterized by f
sAnd inputting the image into a classification network C to perform an image classification task and calculating a classification loss. The classification network C adopts a structure of multiple fully-connected layers and a softmax layer, a schematic diagram of the fully-connected layer structure is shown in FIG. 4, each node of the classification network C is connected with all nodes of the previous layer and used for integrating the extracted features and outputting image prediction tags through the softmax layer
Namely, it is
Is classified as
N
sIs the number of samples in the source domain, and k is the kth sample in the source domain.
Step 5, calculating a total loss function and updating parameters of all networks:
calculating a total loss function L, and updating parameters of a feature extraction network G, a reconstruction network D and a classification network C in the trainer and the tester, namely:
where β is the learning rate, { θG,θD,θC}tFor the parameters of the network at the current moment, the total loss function is as follows:
wherein, theta
CExpressing the parameters of the classification network, lambda is a hyper-parameter and is used for controlling the influence of the image reconstruction task and the image classification task on the network parameter updating, L
r(θ
G,θ
D) Expressed in a network parameter of theta
GAnd theta
DThe loss of the image reconstruction obtained by the calculation,
expressed in the network parameters of
And theta
CThe calculated image classification loss.