MetaAlign: Coordinating Domain Alignment and Classification for Unsupervised Domain Adaptation
Abstract
For unsupervised domain adaptation (UDA), to alleviate the effect of domain shift, many approaches align the source and target domains in the feature space by adversarial learning or by explicitly aligning their statistics. However, the optimization objective of such domain alignment is generally not coordinated with that of the object classification task itself such that their descent directions for optimization may be inconsistent. This will reduce the effectiveness of domain alignment in improving the performance of UDA. In this paper, we aim to study and alleviate the optimization inconsistency problem between the domain alignment and classification tasks. We address this by proposing an effective meta-optimization based strategy dubbed MetaAlign, where we treat the domain alignment objective and the classification objective as the meta-train and meta-test tasks in a meta-learning scheme. MetaAlign encourages both tasks to be optimized in a coordinated way, which maximizes the inner product of the gradients of the two tasks during training. Experimental results demonstrate the effectiveness of our proposed method on top of various alignment-based baseline approaches, for tasks of object classification and object detection. MetaAlign helps achieve the state-of-the-art performance.
1 Introduction
With the advance of deep convolutional neural networks (CNN), computer vision tasks such as image classification and object detection have gained significant improvement [28, 48, 20]. In general, the trained models perform well on the testing dataset of which the distribution bears a resemblance to that of training dataset. However, in many practical scenarios, directly applying such trained models to a new domain usually suffers from significant performance degradation. There exist differences in data characteristics/distributions between the training and testing domains, which are known as domain shift [60, 56]. This makes it hard to directly transfer knowledge learned from source to target. Annotation on the samples of the target domain can alleviate this problem but is expensive and time-consuming. Without the requirement of annotation on target samples, unsupervised domain adaption (UDA) attracts a lot of attention, which allows us to learn to adapt the model trained on source to target by exploiting the unlabeled target samples.

There has been a large spectrum of UDA methods developed in the literature. The major line among them attempts to align the distributions of source and target domains by learning domain-invariant representations, through directly minimizing the discrepancy between feature distributions of two domains [62, 36, 57, 56, 16, 71] or adversarially learning to enforce the feature representations to be indistinguishable by a domain discriminator [14, 15, 43, 37, 67, 5, 9, 41]. The former category of methods usually align domain distributions by employing explicit distribution similarity metrics, e.g., momentum distance [44, 69], or the second-order correlation [56, 57, 45], between the source and target domains. The latter one borrows ideas from Generative Adversarial Networks [18] and use adversarial training to learn aligned feature representations. However, these alignment constraints/strategies are actually not designed specially for the object classification task. There is a lack of efficient coordination between the optimizations of these two tasks. During training, the optimization procedure of alignment may be inconsistent with that of the object classification task itself, which could hurt the learning of discriminative object features for classification and thus results in inferior object classification performance.
In this work, we aim to address this pervasive problem/challenge faced by alignment-based unsupervised domain adaptation methods, i.e., the optimization inconsistency between the domain alignment task and the classification task itself. We propose a meta-learning [53, 58] based method dubbed MetaAlign to mitigate such inconsistency. Particularly, as illustrated in Fig. 1 (b), we treat the domain alignment objective and the classification objective as two tasks in a meta-learning scheme, where we take one task as meta-train task to optimize the network and meanwhile we validate the optimization result on the other task (i.e., meta-test task) for the same set of samples, during training. Meta-optimization across these two tasks encourages both to be optimized in a coordinated way. The theoretical analysis reveals that MetaAlign achieves this optimization coordination by maximizing the inner product of the gradients of the two tasks during training.
We summarize our contributions as follows:
-
•
We pinpoint the problem/challenge in existing alignment-based UDA methods: the optimization inconsistency between the domain alignment task and the classification task itself. To address the problem, we propose a meta-optimization based strategy named MetaAlign to mitigate the inconsistency.
-
•
The proposed MetaAlign strategy is generic and can be applied to various domain alignment based UDA methods for object classification and detection to enforce domain alignment while preserving the discrimination power of features for the recognition task.
We validate the effectiveness of MetaAlign on the image classification (unsupervised domain adaptation and domain generalization) and object detection (unsupervised domain adaptation) tasks. For image classification, we implement MetaAlign on top of various domain alignment based UDA baselines. Extensive experimental results demonstrate the effectiveness and applicability of MetaAlign and we achieve the state-of-the-art performance.
2 Related Work
Unsupervised Domain Adaptation. Unsupervised Domain Adaptation (UDA) aims to transfer the knowledge from a labeled source domain to an unlabeled target domain. Abundant UDA works focus on object classification or use it for their investigations. The mainstream approaches tend to address UDA by learning domain-invariant representation, to which our proposed method belongs. These approaches can be categorized into two categories.
One category explicitly reduces the domain discrepancy measured by some distribution discrepancy metrics. [62, 36, 39, 68] measure the domain similarity in terms of Maximum Mean Discrepancy (MMD) [3], while [56, 57, 44] introduce metrics based on second- or higher-order statistics. Another popular line learns domain-invariant representation using adversarial training. It has been widely studied [9, 5, 37, 61, 52, 6, 65, 35, 51, 40] since the seminal work DANN [14, 15]. In general, a domain discriminator is trained to distinguish the source domain from the target domain, meanwhile a feature extractor is trained to fool the discriminator to arrive at aligned features. SymNets[71] designs symmetric object classifiers which also play a role of domain discriminator. CDAN [37] conditions the adversarial model on the discriminative information conveyed in the classifier predictions. MCD [51] and STAR [40] build an adversarial framework to reduce the domain gap measured by the collision of two reduplicated object classifiers. GVB [9] balances adversarial training via constructing bridge layers on both the generator and discriminator.
These approaches all directly optimize domain alignment and classification tasks, while ignoring the optimization inconsistency between these two objectives. We propose a meta-optimization based strategy to mitigate the inconsistency for better UDA.
UDA for Object Detection. Learning domain adaptive deep object detector was first studied in DA-Faster [7], where they perform image-level and instance-level alignments via adversarial leaning. SW-DA [50] reduces domain gap via aligning global-level and local-level features. Zhu et al.[73] propose to align domains at regions clustered by K-means. EPM [24] proposes the center-aware alignment based on the center map generated by an anchor-free detector [59]. Other variants exploit style-transfer [26], progressive alignment [25], and hierarchical alignment[74].
We also validate the effectiveness of our proposed MetaAlign on UDA for object detection task.
Neural Network Meta Learning. Meta-learning [53, 58] (a.k.a. learning to learn) has a long standing history. Recently, it has been widely applied to the optimization of deep neural networks [1, 34] and few-shot classification [27, 64]. Model-Agnostic Meta-Learning (MAML) [13] is proposed for few-shot learning and reinforcement learning, which aims to find good parameters initialization for fast adaptation to new tasks. [31, 46, 2] introduce meta-learning to Domain Generalization (DG) to synthesize the source-target domain shift during training. Li et al.[29] adopt MAML to provide better initialization condition for Multi-Source Domain Adaptation.
In this work, we pinpoint the underlying optimization inconsistency of the domain alignment objective and classification objective used for UDA. We are the first to mitigate it via a meta-optimization based strategy by treating the two objectives as meta-train and meta-test tasks respectively.
Domain Generalization. In contrast to UDA, Domain Generalization (DG) is applied in a more challenging scenario where target domain is inaccessible during training [42]. One category of methods for DG attempts to learn domain-invariant features [17, 33, 41], which borrows ideas from UDA. Li et al.[33] incorporate MMD as a constraint into the training of an adversarial autoencoder. Ghifary et al.[17] designs multi-task domain-specific decoders to help the training of the domain-invariant encoder. Matsuura et al.[41] use adversarial training to learn features invariant among predicted latent domains. Other categories exploit data augmentation [55, 66, 47], meta-learning [31, 2, 10], and auxiliary tasks [32].
Our MetaAlign can be applied to the first category of approaches for addressing the optimization inconsistency between domain alignment and classification.
3 Proposed MetaAlign for UDA
Problem Formulation: Unsupervised Domain Adaptation (UDA) aims to transfer the knowledge from labeled source domain to the unlabeled target domain. We mainly focus on object classification task but also investigate it for object detection. Without loss of generality, we take classification task as the instantiation to describe our approach.
For UDA classification, we denote the source domain as with labeled samples, where and denote the sample and its class label respectively. The target domain is denoted as with unlabeled samples. Both domains share the same label space with object classes. UDA is expected to train model on and , to obtain high accuracy on the target test set.
The mainstream UDAs aim to align the source and target domains to alleviate the domain gap. Such alignments are, in general, not designed specially for classification task, i.e., their optimization may not work harmoniously with that of object classification task. As a result, it may damage the discriminative power of features and thus impede attaining higher performance. To address this, as illustrated in Fig. 1, we introduce a meta-optimization based strategy MetaAlign to encourage the optimization consistency between domain alignment and object classification task itself.
To be self-included, we first describe several representative domain alignment based UDAs which we use as our baselines. Then, we introduce our MetaAlign to alleviate the above-mentioned optimization inconsistency problem.
3.1 Recap of Alignment Based UDAs


Domain alignment based UDAs include adversarial training based [14, 15, 37] and explicit distribution similarity metric based [36, 38, 44, 56]. The core idea of the former category is to train a domain discriminator to distinguish source domain features from target domain features, meanwhile train the feature network to fool the discriminator to implicitly align domains. The latter one explicitly reduces domain discrepancy w.r.t. distribution discrepancy metrics, like Maximum Mean Discrepancy (MMD) [38, 36], moment distance [44], and second-order correlations [56].
Adversarial Domain Adaptation. To align the domain distributions via adversarial training, such methods try to optimize the object classification loss and the domain alignment loss , simultaneously. Typically, the network is equipped with a feature extractor/generator , an object classifier , and a domain discriminator/classifier .
The specific object classification loss in the source domain is formulated as:
(1) |
where is a typical cross-entropy loss.
The domain discriminator is a two-class classification module, which aims to distinguish the target domain from source domain based on features from . Adversarially, aims to generate responses with aligned distributions for two domains to fool . Particularly, the domain classification loss can be formulated as:
(2) |
We define the domain alignment loss as . The more inseparable (larger ) two domains are, the smaller domain alignment loss is. During training, we train to maximize , meanwhile to minimize and :
(3) |
where we ignore the hyper-parameter (i.e., ) for balancing two losses, for simplicity. Actually, we keep same as that of the baselines [37, 9] in our experiments.
Fig. 2 (a) shows a seminal work DANN [14, 15], which constructs as a CNN feature extractor. The extracted features from the two domains are fed to two task branches and simultaneously. Gradient Reversal Layer (GRL) [14], which flips the gradients to from during gradient back propagation, is used to simplify adversarial training. We also take DANNPE [9], an improved variant of DANN, as another strong baseline. It differs from DANN in two key aspects : 1) the input of is the predicted classification probability; 2) is prioritized on those easy-to-transfer samples by re-weighting with the entropy of object class prediction. Please see Supplementary for more details about DANNPE.
Explicit Domain Alignment. Without introducing additional domain discrimination modules, these methods directly reduce the distribution discrepancy between the features of source domain and target domain w.r.t. some discrepancy measurements/metrics. MMD [3] is a representative distribution discrepancy metric. It has been widely employed as the explicit domain alignment constraint for UDA [19, 36, 38]. Fig. 2 (b) illustrates one UDA framework with MMD constraint. Following [33], the domain alignment loss becomes:
(4) |
where is the feature distribution of source domain. Please refer to Supplementary for more details.
3.2 Meta-learning to Align and
Adversarial UDAs have brought significant performance improvement on multiple benchmarks. They promote the domain alignment, thus reduce the domain gap and enhance the transferability of the models to target domain. The optimization objective of domain alignment is to reduce discrepancy of features between source domain and target domain. However, without explicit coordination with the task of classification, the optimization direction of alignment may be inconsistent with that of the classification task itself. Such inconsistency could hinder the optimization and lead to inferior performance.
The optimizations of domain alignment and classification can be considered as two tasks. In Fig. 3, we use DANNPE as our baseline to visualize the Grad-CAMs [54], which produce visual explanations for decisions and reflect the “important” region of the input for the predictions w.r.t. the domain alignment task. The second row (Base) denotes the Grad-CAMs obtained from the baseline, where the regions with higher responses indicate that their features are indistinguishable to (considering the GRL has flipped the gradients). We can see that Base attains alignment usually on regions irrelevant to objects (e.g., backgrounds) or only on small partial regions of objects. The features of some foreground objects are still not aligned well, which would impede the transferability of the models on classification. It is well known that the foreground object regions are most discriminative for object classification [54, 72]. Not aligning the features of foreground objects well would damage the performance of classification.
With the alignment objective and the classification objective separately assigned to the network, there is a lack of effective interaction between the domain alignment task and classification task. These two tasks may have different gradient descent directions of their optimizations, resulting in optimization inconsistency.
Method | ArCl | ArPr | ArRw | ClAr | ClPr | ClRw | PrAr | PrCl | PrRw | RwAr | RwCl | RwPr | Avg |
Source-Only [21] | 34.9 | 50.0 | 58.0 | 37.4 | 41.9 | 46.2 | 38.5 | 31.2 | 60.4 | 53.9 | 41.2 | 59.9 | 46.1 |
MCD(CVPR’18)[51] | 48.9 | 68.3 | 74.6 | 61.3 | 67.6 | 68.8 | 57.0 | 47.1 | 75.1 | 69.1 | 52.2 | 79.6 | 64.1 |
TAT(ICML’19)[35] | 51.6 | 69.5 | 75.4 | 59.4 | 69.5 | 68.6 | 59.5 | 50.5 | 76.8 | 70.9 | 56.6 | 81.6 | 65.8 |
ALDA(AAAI’20)[5] | 53.7 | 70.1 | 76.4 | 60.2 | 72.6 | 71.5 | 56.8 | 51.9 | 77.1 | 70.2 | 56.3 | 82.1 | 66.6 |
Sym(CVPR’19)[71] | 47.7 | 72.9 | 78.5 | 64.2 | 71.3 | 74.2 | 63.6 | 47.6 | 79.4 | 73.8 | 50.8 | 82.6 | 67.2 |
TADA(AAAI’19)[67] | 53.1 | 72.3 | 77.2 | 59.1 | 71.2 | 72.1 | 59.7 | 53.1 | 78.4 | 72.4 | 60.0 | 82.9 | 67.6 |
MDD(ICML’19)[70] | 54.9 | 73.7 | 77.8 | 60.0 | 71.4 | 71.8 | 61.2 | 53.6 | 78.1 | 72.5 | 60.2 | 82.3 | 68.1 |
BNM(CVPR’20)[8] | 56.2 | 73.7 | 79.0 | 63.1 | 73.6 | 74.0 | 62.4 | 54.8 | 80.7 | 72.4 | 58.9 | 83.5 | 69.4 |
MMD | 49.1 | 67.0 | 74.7 | 54.5 | 62.9 | 65.7 | 55.3 | 45.7 | 74.5 | 68.1 | 52.5 | 78.6 | 62.3 |
+MetaAlign | |||||||||||||
DANN(ICML’15)[15] | 45.8 | 63.4 | 71.9 | 53.6 | 61.9 | 62.6 | 49.1 | 39.7 | 73.0 | 64.6 | 47.8 | 77.8 | 59.2 |
+MetaAlign | |||||||||||||
CDAN(NeurIPS’18)[37] | 50.7 | 70.6 | 76.0 | 57.6 | 70.0 | 70.0 | 57.4 | 50.9 | 77.3 | 70.9 | 56.7 | 81.6 | 65.8 |
+MetaAlign | |||||||||||||
DANNPE | 54.7 | 72.8 | 78.5 | 62.3 | 71.1 | 73.1 | 61.0 | 53.0 | 80.0 | 72.8 | 56.5 | 83.4 | 68.3 |
+MetaAlign | |||||||||||||
GVB(CVPR’20)[9] | 57.0 | 74.7 | 79.8 | 64.6 | 74.1 | 74.6 | 65.2 | 55.1 | 81.0 | 74.6 | 59.7 | 84.3 | 70.4 |
+MetaAlign | |||||||||||||
One natural question to ask arises: how to easily incorporate the optimization consistency constraint for domain alignment and classification?
We propose to promote the optimization consistency between these two tasks by exploring a meta-optimization strategy. We draw inspiration from Model-Agnostic Meta-Learning (MAML) [13], which generally separates the samples into meta-train splits and meta-test splits, and uses meta-learning to train the model to be learned quickly on meta-test samples given the knowledge in meta-train. Meta-Learning Domain Generalization (MLDG) [31] simulates training-test domain shift during training by synthesizing virtual test domain, with meta-optimization objective requiring that steps to improve training domain performance should also improve testing domain performance.
In our work, we leverage meta-optimization to coordinate the domain alignment task and classification task. Particularly, rather than splitting the samples into meta-train and meta-test as in [13, 31], we treat the domain alignment task and classification task as meta-train (or meta-test) and meta-test (or meta-train) for the same set of samples.
A UDA network is jointly optimized with classification objective and domain alignment objective. The learnable network parameters consists of shared parameters , the parameters specific to domain alignment , and the parameters specific to classification . The general optimization objective can be formulated as:
(5) |
which does not handle the potential optimization inconsistency of the two tasks.
With the intuition that meta-test task (e.g., classification) will be used to evaluate the effect of the model optimization on meta-train task (e.g., domain alignment), the overall meta-optimization objective can be formulated as:
(6) |
which aims to optimize both the loss of meta-train , and that of meta-test after updating during meta-train by one gradient descent step: , where denotes the meta-learning rate. To alleviate the computational complexity, similar to [10, 13], we omit higher-order ones during the back-propagation of gradients.
This meta-optimization enables the explicit interaction between the two tasks. Following [31], we analyse Eq. (6) by approximating the second term using its first-order Taylor expansion as:
(7) |
Compared with the general optimization objective Eq. (5), the additional last term in Eq. (7) maximizes the dot product of and , which encourages the consistency of the optimization directions (gradients) of two tasks. In this way, both domain alignment and object classification are optimized in a coordinated way. We refer to our method as MetaAlign which Aligns the domain alignment task and classification task with a Meta-optimization strategy.
In Eq. (7), we place the consistency constraint on all the parameters (including different layers) shared by two tasks. Actually, different layers in a CNN learn features with different semantics. Intuitively, they should be treated differently when aligning their optimizations, where the optimization consistency for some layers may be more important than other layers. We propose to adaptively learn the importance levels for different groups of layers for better optimization. Particularly, we partition the layers into groups (e.g., each convolutional block of ResNet as a group) and learn a scalar weight for the group. The optimization objective is thus formulated as:
(8) |
where denotes the parameters of the group. To avoid trivial solution, we add constraint on : , where is a hyper-parameter. We denote the entire losses in Eq. (8) as for simplicity.
Method | A W | A D | W A | W D | D A | D W | Avg |
Source-Only [21] | 68.40.2 | 68.90.2 | 60.70.3 | 99.30.1 | 62.50.3 | 96.70.1 | 76.1 |
CDAN (NeurIPS’18) [37] | 94.10.1 | 92.90.2 | 69.30.3 | 100.0.0 | 71.00.3 | 98.60.1 | 87.7 |
TAT (ICML’19) [35] | 92.50.3 | 93.20.2 | 72.10.3 | 100.0.0 | 73.10.3 | 99.30.1 | 88.4 |
TADA (AAAI’19) [67] | 94.30.3 | 91.60.3 | 73.00.3 | 99.80.2 | 72.90.2 | 98.70.1 | 88.4 |
Sym (CVPR’19) [71] | 90.80.1 | 93.90.5 | 72.50.5 | 100.0.0 | 74.60.6 | 98.80.3 | 88.4 |
BNM (CVPR’20) [8] | 92.8 | 92.9 | 73.8 | 100.0 | 73.5 | 98.8 | 88.6 |
ALDA (AAAI’20) [5] | 95.60.5 | 94.00.4 | 72.50.2 | 100.0.0 | 72.20.4 | 97.70.1 | 88.7 |
MDD (ICML’19) [70] | 94.50.3 | 93.50.2 | 72.20.1 | 100.0.0 | 74.60.3 | 98.40.1 | 88.9 |
DANNPE | 92.50.5 | 89.90.3 | 71.10.3 | 99.90.1 | 70.70.4 | 98.50.3 | 87.0 |
+MetaAlign | |||||||
GVB (CVPR’20) [9] | 92.00.3 | 91.40.5 | 73.40.1 | 100.0.0 | 74.90.5 | 98.7.0 | 88.3 |
+MetaAlign |
Training. In practice, we can iteratively choose one of the two tasks (domain alignment task and object classification task) as meta-train while the other as meta-test. We describe the training procedure in Alg. 1. For simplicity, we only show one case, i.e., the domain alignment task and object classification task are taken as meta-train and meta-test respectively. The other case is similar.
4 Experiments
In this section, we validate the effectiveness of our proposed MetaAlign on UDA for classification in Sec. 4.1 and for object detection in Sec. 4.2. Besides, we further show its effectiveness on DG for classification in Sec. 4.3. Due to the space constraint, we refer readers to Supplementary for more details for all experiments.
4.1 UDA for Classification
4.1.1 Datasets and Settings
We conduct UDA experiments on two popular benchmarks Office31 [49] and Office-Home [63]. 1) Office31 is a standard benchmark for domain adaptative classification. It contains images of 31 categories, drawn from three domains: Amazon (A), Webcam (W), and DSLR (D). Following the typical setting [9, 71, 51], we evaluate the methods on one-source to one-target domain adaptation.
Source-Only DANNPE +MetaAlign w/o +MetaAlign 46.1 68.3 69.7 70.1
2) Office-Home is a more challenging recent dataset for UDA. It consists of images from 4 different domains: Art (Ar), Clip Art (Cl), Product (Pr), and Real-World (Rw). Each domain contains 65 object categories found typically in office and home environments. We evaluate our method in all the 12 one-source to one-target adaptation cases. All reported results are obtained from the average of multiple runs.

Source Target | AGG | MMD-AAE[33] (CVPR’18) | CrossGrad[55] (ICLR’18) | MetaReg[2] (NeurIPS’18) | JiGen[4] (CVPR’19) | MLDG[31] (AAAI’18) | MASF[10] (NeurIPS’19) | Epi-FCR[32] (ICCV’19) | MMLD[41] (AAAI’20) | DANNPE | +MetaAlign |
A,C,S P | 94.4 | 96.0 | 94.0 | 94.3 | 96.0 | 94.3 | 95.0 | 93.9 | 96.1 | 95.2 | 95.5 |
C,P,S A | 77.6 | 75.2 | 78.7 | 79.5 | 79.4 | 79.5 | 80.3 | 82.1 | 81.3 | 76.5 | 78.5 |
A,P,S C | 73.9 | 72.7 | 73.3 | 75.4 | 77.3 | 75.3 | 77.2 | 77.0 | 77.2 | 77.2 | 77.8 |
A,C,P S | 70.3 | 64.2 | 65.1 | 72.2 | 71.4 | 71.5 | 71.7 | 73.0 | 72.3 | 74.1 | 75.7 |
Avg. | 79.1 | 77.0 | 77.8 | 80.4 | 80.5 | 80.7 | 81.0 | 81.5 | 81.8 | 80.7 | 81.9 |
Methods bike bird car cat dog person mAP Source Only 68.8 46.8 37.2 32.7 21.3 60.7 44.6 BDC-Faster[50](CVPR’19) 68.6 48.3 47.2 26.5 21.7 60.5 45.5 WST+BSR[26](ICCV’19) 75.6 45.8 49.3 34.1 30.3 64.1 49.9 MAF[22](ICCV’19) 73.4 55.7 46.4 36.8 28.9 60.8 50.3 DT-UDA[25](CVPR’18) 82.8 47.0 40.2 34.6 35.3 62.5 50.4 ATF[23](ECCV‘20) 78.8 59.9 47.9 41.0 34.8 66.9 54.9 W-DA[50](CVPR’19) 66.4 53.7 43.8 37.9 31.9 65.3 49.8 W-DA+MetaAlign SW-DA[50](CVPR’19) 76.1 52.7 49.1 36.3 40.2 66.3 53.5 SW-DA+MetaAlign
4.1.2 Ablation Study
Effectiveness of MetaAlign on Various Baselines. Our proposed MetaAlign is generic which could be applied to alleviate the optimization inconsistency of most existing domain alignment based UDAs. We use various alignment-based UDAs as our baselines to validate the effectiveness of MeanAlign. Specifically, we adopt five baselines. 1) MMD, 2) DANN, and 3) DANNPE have been described in Sec. 3.1 in detail. 4) CDAN [37] aligns domain at class-level. 5) GVB [9] is a most recent state-of-the-art method with enhanced and . Note that MMD explicitly reduces the discrepancy of domains, while the others belong to adversarial learning based approaches.
Table 1 shows the comparisons on Office-Home. Our MetaAlign consistently improves the accuracy of all the five baselines, i.e., 1.0%, 3.9%, 2.0%, 1.8%, 0.9% on average for MMD, DANN, CDAN, DANNPE, GVB, respectively, regardless of the design differences on . With the help of MetaAlign, domain alignment and classification are optimized in a coordinated way, resulting in more efficient optimization.
Effectiveness of Re-weighting with in MetaAlign. In our design, in Eq. (8) are learned to allocate the levels of importance for different layer groups on the consistency constraint. We validate its effectiveness on top of the baseline DANNPE on Office-Home in Table 3. Our MetaAlign improves over DANNPE by 1.8% in accuracy. Without , the gain decreases to 1.4%.
Which Task as Meta-Train? We could treat any one of the two tasks as meta-train and the other as meta-test. We could also iteratively exchange their roles during training. Experimental results show their results are very close ( 0.3% accuracy). The explanation lies in that these settings have the same optimization objective as Eq. (7).
4.1.3 Comparisons with State-of-the-Arts
To compare with previous state-of-the-art UDAs, we incorporate our MetaAlign optimization strategy into the recent strong UDA method GVB [9], termed as GVB+MetaAlign. Table 1 and Table 2 show the comparisons with the state-of-the-art approaches on Office-Home and Office31, respectively. GVB+MetaAlign outperforms GVB and achieves the best performance on both datasets.
4.1.4 Feature Visualization
As analysed in Sec. 3.2, we expect MetaAlign to enforce the domain alignment task and object classification task to be optimized in a coordinated way. To validate it, we visualize the Grad-CAMs [54] w.r.t. the domain alignment task in Fig. 3. With MetaAlign, the domain alignment task focuses on the regions more related to foreground objects compared with Baseline. These regions play the most important role for object classification task [72, 54], which is also validated in the Supplementary. Aligning these features helps improve object classification accuracy indeed.
We also visualize the learned features by t-SNE [50], on task Pr Cl in Fig. 4. It is shown that Source-Only works well only in source domain but poorly in target domain without domain alignment. DANNPE aligns domains well via adversarial learning. Further, employing MetaAlign arrives at much better alignment results, where the clusters are more compact and less data points scatter at the boundaries between clusters. The visualization result further validates the effectiveness of MetaAlign for domain alignment based UDA.
4.2 Experiments on UDA for Object Detection
Adversarial learning has also been exploited in UDA for object detection [7, 50]. It is natural to align foreground objects across domains in this task, where the aforementioned optimization inconsistency issue still exists. Our MetaAlign is generic and is expected to work well for this task. We take a Faster RCNN[48] based SW-DA [50] as the baseline, and conduct UDA experiments from Pascal VOC [11, 12] to Watercolor2k [25]. All reported results are obtained from the average of multiple runs. Please refer to Supplementary for details about datasets, experimental settings, and the introduction of competitors. As shown in Table 5, our MetaAlign strategy improves the mAP of the two baselines W-DA (SW-DA without local alignment) and SW-DA by 2.3 (4.6%) and 1.9 (3.5%), respectively. The latter one achieves state-of-the-art performance, compared with recent methods. Note that the results on ‘bird’ are unstable due to the insufficient data (the number of bird bounding boxes are about 2.6% of all bounding boxes in the dataset). Some qualitative comparisons (see Supplementary) demonstrate MetaAlign improves the object classification accuracy of the predicted bounding boxes, thanks to the coordination between domain alignment and object classification. These validate that our MetaAlign strategy is compatible with UDAs for different vision tasks.
4.3 Experiments on Domain Generalization
Learning domain-invariant features is also widely explored in DG. Therefore we further apply our MetaAlign on DG to validate its generalizability. DANNPE is originally designed for UDA. However, its goal, to learn domain-invariant features, fits well with DG. Therefore we repurpose it as a baseline for DG to incorporate our MetaAlign. We perform experiments on PACS [30]. All reported results are obtained from the average of multiple runs. Please refer to Supplementary for more details about the dataset, settings, and the description of competitors. As shown in Table 4, DANNPE also works for DG with about 1.6% improvement over AGG. With our proposed MetaAlign strategy, the accuracy is further improved by 1.2%. We reckon that MetaAlign enforces the domain-invariant features and classification discriminative features to be learned in concert. DANNPE+MetaAlign outperforms previous state-of-the-art methods on the average accuracy, especially in the most challenging scenario where the target domain is Sketch. Sketch has the largest domain gap with other domains, therefore, more powerful domain-invariant features are required.
5 Conclusion
In this paper, we pinpoint the optimization inconsistency problem between the domain alignment task and the classification task itself in alignment-based UDAs. To mitigate it, we propose a meta-optimization based strategy named MetaAlign, which treats one of these two tasks as meta-train and the other as meta-test. The analysis of the optimization objective of MetaAlign reveals that the two tasks will be optimized in a coordinated way. The experimental results validate that MetaAlign is applicable to various alignment-based UDAs for classification and detection.
6 Acknowledgments
This work was supported in part by NSFC under Grant U1908209, 61632001 and the National Key Research and Development Program of China 2018AAA0101400.
References
- [1] Marcin Andrychowicz, Misha Denil, Sergio Gomez, Matthew W Hoffman, David Pfau, Tom Schaul, Brendan Shillingford, and Nando De Freitas. Learning to learn by gradient descent by gradient descent. In NeurIPS, pages 3981–3989, 2016.
- [2] Yogesh Balaji, Swami Sankaranarayanan, and Rama Chellappa. Metareg: Towards domain generalization using meta-regularization. In NeurIPS, pages 998–1008, 2018.
- [3] Karsten M Borgwardt, Arthur Gretton, Malte J Rasch, Hans-Peter Kriegel, Bernhard Schölkopf, and Alex J Smola. Integrating structured biological data by kernel maximum mean discrepancy. Bioinformatics, 22(14):e49–e57, 2006.
- [4] Fabio M Carlucci, Antonio D’Innocente, Silvia Bucci, Barbara Caputo, and Tatiana Tommasi. Domain generalization by solving jigsaw puzzles. In CVPR, pages 2229–2238, 2019.
- [5] Minghao Chen, Shuai Zhao, Haifeng Liu, and Deng Cai. Adversarial-learned loss for domain adaptation. In AAAI, pages 3521–3528, 2020.
- [6] Qingchao Chen, Yang Liu, Zhaowen Wang, Ian Wassell, and Kevin Chetty. Re-weighted adversarial adaptation network for unsupervised domain adaptation. In CVPR, pages 7976–7985, 2018.
- [7] Yuhua Chen, Wen Li, Christos Sakaridis, Dengxin Dai, and Luc Van Gool. Domain adaptive faster r-cnn for object detection in the wild. In CVPR, pages 3339–3348, 2018.
- [8] Shuhao Cui, Shuhui Wang, Junbao Zhuo, Liang Li, Qingming Huang, and Qi Tian. Towards discriminability and diversity: Batch nuclear-norm maximization under label insufficient situations. In CVPR, pages 3941–3950, 2020.
- [9] Shuhao Cui, Shuhui Wang, Junbao Zhuo, Chi Su, Qingming Huang, and Qi Tian. Gradually vanishing bridge for adversarial domain adaptation. In CVPR, pages 12455–12464, 2020.
- [10] Qi Dou, Daniel Coelho de Castro, Konstantinos Kamnitsas, and Ben Glocker. Domain generalization via model-agnostic learning of semantic features. In NeurIPS, pages 6450–6461, 2019.
- [11] M. Everingham, L. Van Gool, C. K. I. Williams, J. Winn, and A. Zisserman. The PASCAL Visual Object Classes Challenge 2007 (VOC2007) Results. http://www.pascal-network.org/challenges/VOC/voc2007/workshop/index.html.
- [12] M. Everingham, L. Van Gool, C. K. I. Williams, J. Winn, and A. Zisserman. The PASCAL Visual Object Classes Challenge 2012 (VOC2012) Results. http://www.pascal-network.org/challenges/VOC/voc2012/workshop/index.html.
- [13] Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In ICML, page 1126–1135, 2017.
- [14] Yaroslav Ganin and Victor Lempitsky. Unsupervised domain adaptation by backpropagation. In ICML, pages 1180–1189, 2015.
- [15] Yaroslav Ganin, Evgeniya Ustinova, Hana Ajakan, Pascal Germain, Hugo Larochelle, François Laviolette, Mario Marchand, and Victor Lempitsky. Domain-adversarial training of neural networks. Journal of Machine Learning Research, 17(1):2096–2030, 2016.
- [16] Bo Geng, Dacheng Tao, and Chao Xu. Daml: Domain adaptation metric learning. IEEE Transactions on Image Processing, 20(10):2980–2989, 2011.
- [17] Muhammad Ghifary, W Bastiaan Kleijn, Mengjie Zhang, and David Balduzzi. Domain generalization for object recognition with multi-task autoencoders. In ICCV, pages 2551–2559, 2015.
- [18] Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In NeurIPS, pages 2672–2680, 2014.
- [19] Arthur Gretton, Karsten Borgwardt, Malte Rasch, Bernhard Schölkopf, and Alex J Smola. A kernel method for the two-sample-problem. In NeurIPS, pages 513–520, 2007.
- [20] K. He, G. Gkioxari, P. Dollár, and R. Girshick. Mask r-cnn. In ICCV, pages 2980–2988, 2017.
- [21] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, pages 770–778, 2016.
- [22] Zhenwei He and Lei Zhang. Multi-adversarial faster-rcnn for unrestricted object detection. In ICCV, pages 6668–6677, 2019.
- [23] Zhenwei He and Lei Zhang. Domain adaptive object detection via asymmetric tri-way faster-rcnn. ECCV, 2020.
- [24] Cheng-Chun Hsu, Yi-Hsuan Tsai, Yen-Yu Lin, and Ming-Hsuan Yang. Every pixel matters: Center-aware feature alignment for domain adaptive object detector. In ECCV, pages 733–748.
- [25] Naoto Inoue, Ryosuke Furuta, Toshihiko Yamasaki, and Kiyoharu Aizawa. Cross-domain weakly-supervised object detection through progressive domain adaptation. In CVPR, pages 5001–5009, 2018.
- [26] Seunghyeon Kim, Jaehoon Choi, Taekyung Kim, and Changick Kim. Self-training and adversarial background regularization for unsupervised domain adaptive one-stage object detection. In ICCV, pages 6092–6101, 2019.
- [27] Gregory Koch, Richard Zemel, and Ruslan Salakhutdinov. Siamese neural networks for one-shot image recognition. In ICML deep learning workshop, 2015.
- [28] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E. Hinton. Imagenet classification with deep convolutional neural networks. In NeurIPS, page 1097–1105, 2012.
- [29] Da Li and Timothy Hospedales. Online meta-learning for multi-source and semi-supervised domain adaptation. In ECCV, pages 382–403, 2020.
- [30] Da Li, Yongxin Yang, Yi-Zhe Song, and Timothy M Hospedales. Deeper, broader and artier domain generalization. In ICCV, pages 5542–5550, 2017.
- [31] Da Li, Yongxin Yang, Yi-Zhe Song, and Timothy M Hospedales. Learning to generalize: Meta-learning for domain generalization. AAAI, 2018.
- [32] Da Li, Jianshu Zhang, Yongxin Yang, Cong Liu, Yi-Zhe Song, and Timothy M Hospedales. Episodic training for domain generalization. In ICCV, pages 1446–1455, 2019.
- [33] Haoliang Li, Sinno Jialin Pan, Shiqi Wang, and Alex C Kot. Domain generalization with adversarial feature learning. In CVPR, pages 5400–5409, 2018.
- [34] Ke Li and Jitendra Malik. Learning to optimize neural nets. arXiv preprint arXiv:1703.00441, 2017.
- [35] Hong Liu, Mingsheng Long, Jianmin Wang, and Michael Jordan. Transferable adversarial training: A general approach to adapting deep classifiers. In ICML, pages 4013–4022, 2019.
- [36] Mingsheng Long, Yue Cao, Jianmin Wang, and Michael Jordan. Learning transferable features with deep adaptation networks. In ICML, pages 97–105, 2015.
- [37] Mingsheng Long, Zhangjie Cao, Jianmin Wang, and Michael I Jordan. Conditional adversarial domain adaptation. In NeurIPS, pages 1645–1655, 2018.
- [38] Mingsheng Long, Han Zhu, Jianmin Wang, and Michael I Jordan. Unsupervised domain adaptation with residual transfer networks. In NeurIPS, pages 136–144, 2016.
- [39] Mingsheng Long, Han Zhu, Jianmin Wang, and Michael I Jordan. Deep transfer learning with joint adaptation networks. In ICML, pages 2208–2217, 2017.
- [40] Zhihe Lu, Yongxin Yang, Xiatian Zhu, Cong Liu, Yi-Zhe Song, and Tao Xiang. Stochastic classifiers for unsupervised domain adaptation. In CVPR, pages 9111–9120, 2020.
- [41] Toshihiko Matsuura and Tatsuya Harada. Domain generalization using a mixture of multiple latent domains. In AAAI, pages 11749–11756, 2020.
- [42] Krikamol Muandet, David Balduzzi, and Bernhard Schölkopf. Domain generalization via invariant feature representation. In ICML, pages 10–18, 2013.
- [43] Zhongyi Pei, Zhangjie Cao, Mingsheng Long, and Jianmin Wang. Multi-adversarial domain adaptation. In AAAI, 2018.
- [44] Xingchao Peng, Qinxun Bai, Xide Xia, Zijun Huang, Kate Saenko, and Bo Wang. Moment matching for multi-source domain adaptation. In ICCV, pages 1406–1415, 2019.
- [45] Xingchao Peng and Kate Saenko. Synthetic to real adaptation with generative correlation alignment networks. In WACV, pages 1982–1991, 2018.
- [46] Fengchun Qiao, Long Zhao, and Xi Peng. Learning to learn single domain generalization. In CVPR, pages 12556–12565, 2020.
- [47] Fengchun Qiao, Long Zhao, and Xi Peng. Learning to learn single domain generalization. In CVPR, pages 12556–12565, 2020.
- [48] Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. In NeurIPS, pages 91–99, 2015.
- [49] Kate Saenko, Brian Kulis, Mario Fritz, and Trevor Darrell. Adapting visual category models to new domains. In ECCV, pages 213–226, 2010.
- [50] Kuniaki Saito, Yoshitaka Ushiku, Tatsuya Harada, and Kate Saenko. Strong-weak distribution alignment for adaptive object detection. In CVPR, pages 6956–6965, 2019.
- [51] Kuniaki Saito, Kohei Watanabe, Yoshitaka Ushiku, and Tatsuya Harada. Maximum classifier discrepancy for unsupervised domain adaptation. In CVPR, pages 3723–3732, 2018.
- [52] Swami Sankaranarayanan, Yogesh Balaji, Carlos D Castillo, and Rama Chellappa. Generate to adapt: Aligning domains using generative adversarial networks. In CVPR, pages 8503–8512, 2018.
- [53] Jürgen Schmidhuber. On learning how to learn learning strategies. 1995.
- [54] Ramprasaath R Selvaraju, Michael Cogswell, Abhishek Das, Ramakrishna Vedantam, Devi Parikh, and Dhruv Batra. Grad-cam: Visual explanations from deep networks via gradient-based localization. In ICCV, pages 618–626, 2017.
- [55] Shiv Shankar, Vihari Piratla, Soumen Chakrabarti, Siddhartha Chaudhuri, Preethi Jyothi, and Sunita Sarawagi. Generalizing across domains via cross-gradient training. In ICLR, 2018.
- [56] Baochen Sun, Jiashi Feng, and Kate Saenko. Return of frustratingly easy domain adaptation. In AAAI, 2016.
- [57] Baochen Sun and Kate Saenko. Deep coral: Correlation alignment for deep domain adaptation. In ECCV, pages 443–450, 2016.
- [58] Sebastian Thrun and Lorien Pratt. Learning to learn. Springer Science & Business Media, 2012.
- [59] Zhi Tian, Chunhua Shen, Hao Chen, and Tong He. Fcos: Fully convolutional one-stage object detection. In ICCV, pages 9627–9636, 2019.
- [60] Antonio Torralba and Alexei A Efros. Unbiased look at dataset bias. In CVPR, pages 1521–1528, 2011.
- [61] Eric Tzeng, Judy Hoffman, Kate Saenko, and Trevor Darrell. Adversarial discriminative domain adaptation. In CVPR, pages 7167–7176, 2017.
- [62] Eric Tzeng, Judy Hoffman, Ning Zhang, Kate Saenko, and Trevor Darrell. Deep domain confusion: Maximizing for domain invariance. arXiv preprint arXiv:1412.3474, 2014.
- [63] Hemanth Venkateswara, Jose Eusebio, Shayok Chakraborty, and Sethuraman Panchanathan. Deep hashing network for unsupervised domain adaptation. In CVPR, pages 5018–5027, 2017.
- [64] Oriol Vinyals, Charles Blundell, Timothy Lillicrap, Daan Wierstra, et al. Matching networks for one shot learning. In NeurIPS, pages 3630–3638, 2016.
- [65] Riccardo Volpi, Pietro Morerio, Silvio Savarese, and Vittorio Murino. Adversarial feature augmentation for unsupervised domain adaptation. In CVPR, pages 5495–5504, 2018.
- [66] Riccardo Volpi, Hongseok Namkoong, Ozan Sener, John C Duchi, Vittorio Murino, and Silvio Savarese. Generalizing to unseen domains via adversarial data augmentation. In NeurIPS, pages 5334–5344, 2018.
- [67] Ximei Wang, Liang Li, Weirui Ye, Mingsheng Long, and Jianmin Wang. Transferable attention for domain adaptation. In AAAI, volume 33, pages 5345–5352, 2019.
- [68] Hongliang Yan, Yukang Ding, Peihua Li, Qilong Wang, Yong Xu, and Wangmeng Zuo. Mind the class weight bias: Weighted maximum mean discrepancy for unsupervised domain adaptation. In CVPR, pages 2272–2281, 2017.
- [69] Werner Zellinger, Thomas Grubinger, Edwin Lughofer, Thomas Natschläger, and Susanne Saminger-Platz. Central moment discrepancy (cmd) for domain-invariant representation learning. In ICLR, 2017.
- [70] Yuchen Zhang, Tianle Liu, Mingsheng Long, and Michael Jordan. Bridging theory and algorithm for domain adaptation. In ICML, pages 7404–7413, 2019.
- [71] Yabin Zhang, Hui Tang, Kui Jia, and Mingkui Tan. Domain-symmetric networks for adversarial domain adaptation. In CVPR, pages 5031–5040, 2019.
- [72] Bolei Zhou, Aditya Khosla, Agata Lapedriza, Aude Oliva, and Antonio Torralba. Learning deep features for discriminative localization. In CVPR, 2016.
- [73] Xinge Zhu, Jiangmiao Pang, Ceyuan Yang, Jianping Shi, and Dahua Lin. Adapting object detectors via selective cross-domain alignment. In CVPR, pages 687–696, 2019.
- [74] Chenfan Zhuang, Xintong Han, Weilin Huang, and Matthew Scott. ifan: Image-instance full alignment networks for adaptive object detection. In AAAI, volume 34, pages 13122–13129, 2020.
Appendix
Appendix 1 More Details of Baselines
In our main manuscript, we have briefly described several representative alignment-based methods, which we use as our baselines for validating the effectiveness of our MetaAlign. Here, we present more details of some baselines.
DANNPE. As shown in Fig. 5, DANNPE differs from DANN in two key aspects: 1) Similar to [37, 9], the predicted object classification probability/likelihood is treated as the input of domain discriminator , instead of the output feature of in DANN. 2) Following [37], we prioritize the discriminator on those easy-to-transfer samples by re-weighting the samples based on the entropy of object class prediction, with the weight defined as , where denotes the entropy of the object class prediction. As shown in Table 1 in our main manuscript, DANNPE significantly outperforms DANN.
MMD. We directly add the MMD constraint [3] on the output of to encourage the feature alignment between source domain and target domain data (see Fig. 2 (b) in our main manuscript). The complete MMD loss (i.e., Eq. (4) in the main manuscript) is formulated as:
(9) |
where , and denotes a kernel function. Following [33], we use the well-known characteristic kernel RBF, i.e., , where is the bandwidth parameter [33].



For MMD-based UDA, similar to Eq. (8) in the main manuscript, the optimization objective of MetaAlign is:
(10) |
Appendix 2 Experiments
We describe more details on the implementation, datasets, settings, competitors, and present more experimental results.
2.1 UDA for Classification
Implementation Details. We adopt ResNet-50 [21] pre-trained on ImageNet [28] as the feature extractor for all baselines. Following [9, 37], the domain classifier/discriminator is composed of three fully connected layers with inserted dropout and ReLU layers for stable training, followed by a sigmoid function to output the domain classification result. We divide the convolutional layers of the feature extractor into 4 groups (i.e., in Eq. (8)): the conv1 and conv2_x as the first group, conv3_x, conv4_x, conv5_x as the second to fourth groups respectively for simplicity.
2.2 UDA for Object Detection
Datasets and Experimental Setting. To simulate dissimilar domains, Pascal VOC [11, 12] and Watercolor2k [25] are treated as source and target domain respectively. 1) Pascal VOC [11, 12] is a well-known benchmark for object detection in real world scenario. In this dataset, 20 object classes with their corresponding bounding boxes are annotated. Following [50], we employ the split setting which uses Pascal VOC 2007 and 2012 as training and validation. 2) Watercolor2k [25] is a collection of 2K watercolor images. It contains 6 categories in common with Pascal VOC. 1K images are used for training and the other 1K for testing.
As in previous works [7, 50], we set the shorter side of the image to 600 pixels following the implementation of Faster RCNN[48] with ROI-alignment [20]. The meta learning rate is set to 0.01, which is 10 times the learning rate .
Competitors. We compare with the following methods: 1) Source Only trains model on source domain and directly tests on target domain. 2) BDC-Faster adopts the typical design of DANN, which takes the global features as input of the domain discriminator for adversarial learning. 3) WST+BSR [26] constructs self-training on easy samples to reduce the negative effects of inaccurate pseudo-labels. 4) MAF [22] incorporates multiple domain discriminators on hierarchical features. 5) DT-UDA [25] performs training on style-translated target images with predicted pseudo-labels. 6) ATF [23] designs an asymmetric tri-way model to alleviate the collapse and out-of-control risk of the source domain. 7) SW-DA [50] aligns both global-level features and local-level features between the source and target domains by adversarial learning, which we take as our baseline for evaluating MetaAlign.
Visualization Results. We have shown the performance comparison in Table 5 in our main manuscript. Here, we show the visualization of object detection results on the target dataset Watercolor2k [25] in Fig. 7. We can see that for the baseline scheme SW-DA, there are many false detections and missing detections. Thanks to the coordination between the domain alignment and the object detection optimization from our MetaAlign, the scheme SW-DA+MetaAlign achieves more accurate detections, where the false detections and missing detections are largely reduced.
2.3 Domain Generalization
Dataset and Settings. PACS [30] is a widely used benchmark for domain generalization. It contains 7 object categories from 4 domains (Photo, Art Painting, Cartoon and Sketch). We evaluate on this dataset under a commonly-used experimental protocol of leave-one-out [30, 4, 32], where three domains are used for training and the remaining one is considered as the target domain. The domain discriminator of DANNPE here is kept the same as that for UDA classification, except that the final layer is a FC layer with 3 neurons instead of 1 for distinguishing the three source domains.
Competitors. 1) AGG simply trains a model directly on the aggregation of all source domains. 2) MMD-AAE[33] equips an autoencoder with a MMD loss to train a domain-invariant encoder. 3) CrossGrad[55] is a typical data augmentation based DG method which perturbs in the input manifold to augment data. 4) MetaReg[2], 5) MLDG[31] and 6) MASF[10] utilize meta-learning, which separate the samples into meta-train splits and meta-test splits, to mimic domain shift during training on source domains. 7) JiGen imposes an auxiliary task of solving the Jigsaw puzzle on top of AGG. 8) Epi-FCR[32] introduces a new episodic training strategy. 9) MMLD[41] predicts the pseudo domain labels and uses them for the adversarial domain learning.