{'fraction_non_alphanumeric': 0.03577848451327434, 'fraction_numerical': 0.014829922566371681, 'mean_word_length': 4.766194937213474, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Discriminative Adversarial Domain Adaptation

Given labeled instances on a source domain and unlabeled ones on a target domain, unsupervised domain adaptation aims to learn a task classifier that can well classify target instances. Recent advances rely on domain-adversarial training of deep networks to learn domain-invariant features. However, due to an issue of mode collapse induced by the separate design of task and domain classifiers, these methods are limited in aligning the joint distributions of feature and category across domains. To overcome it, we propose a novel adversarial learning method termed Discriminative Adversarial Domain Adaptation (DADA). Based on an integrated category and domain classifier, DADA has a novel adversarial objective that encourages a mutually inhibitory relation between category and domain predictions for any input instance. We show that under practical conditions, it defines a minimax game that can promote the joint distribution alignment. Except for the traditional closed set domain adaptation, we also extend DADA for extremely challenging problem settings of partial and open set domain adaptation. Experiments show the efficacy of our proposed methods and we achieve the new state of the art for all the three settings on benchmark datasets.


Introduction
Many machine learning tasks are advanced by large-scale learning of deep models, with image classification (Russakovsky et al. 2015) as one of the prominent examples. A key factor to achieve such advancements is the availability of massive labeled data on the domains of the tasks of interest. For many other tasks, however, training instances on the corresponding domains are either difficult to collect, or their labeling costs prohibitively. To address the scarcity of labeled data for these target tasks/domains, a general strategy is to leverage the massively available labeled data on related source ones via domain adaptation (Pan and Yang 2010). Even though the source and target tasks share the same label space (i.e. closed set domain adaptation), domain adaptation still suffers from the shift in data distributions. The main objective of domain adaptation is thus to learn domaininvariant features, so that task classifiers learned from the source data can be readily applied to the target domain. In this work, we focus on the unsupervised setting where training instances on the target domain are completely unlabeled.
Recent domain adaptation methods are largely built on modern deep architectures. They rely on great model capacities of these networks to learn hierarchical features that are empirically shown to be more transferable across domains (Yosinski et al. 2014;Zhang, Tang, and Jia 2018). Among them, those based on domain-adversarial training (Ganin et al. 2016;Wang et al. 2019) achieve the current state of the art. Based on the seminal work of DANN (Ganin et al. 2016), they typically augment a classification network with an additional domain classifier. The domain classifier takes features from the feature extractor of the classification network as inputs, which is trained to differentiate between instances from the two domains. By playing a minimax game (Goodfellow et al. 2014), adversarial training aims to learn domain-invariant features.
Such domain-adversarial networks can largely reduce the domain discrepancy. However, the separate design of task and domain classifiers has the following shortcomings. Firstly, feature distributions can only be aligned to a certain level, since model capacity of the feature extractor could be large enough to compensate for the less aligned feature distributions. More importantly, given practical difficulties of aligning the source and target distributions with high granularity to the category level (especially for complex distributions with multi-mode structures), the task classifier obtained by minimizing the empirical source risk cannot well generalize to the target data due to an issue of mode collapse (Kurmi and Namboodiri 2019;Tran et al. 2019), i.e., the joint distributions of feature and category are not well aligned across the source and target domains.
Recent methods (Kurmi and Namboodiri 2019;Tran et al. 2019) take the first step to address the above shortcomings by jointly parameterizing the task and domain classifiers into an integrated one. To further push this line, based on such a classifier, we propose a novel adversarial learning method termed Discriminative Adversarial Domain Adaptation (DADA), which encourages a mutually inhibitory relation between its domain prediction and category prediction for any input instance, as illustrated in Figure 1. This dis-criminative interaction between category and domain predictions underlies the ability of DADA to reduce domain discrepancy at both the feature and category levels. Intuitively, the adversarial training of DADA mainly conducts competition between the domain neuron (output) and the true category neuron (output). Different from the work (Tran et al. 2019) whose mechanism to align the joint distributions is rather implicit, DADA enables explicit alignment between the joint distributions, thus improving the classification of target data. Except for closed set domain adaptation, we also extend DADA for partial domain adaptation , i.e. the target label space is subsumed by the source one, and open set domain adaptation (Saito et al. 2018c), i.e. the source label space is subsumed by the target one. Our main contributions can be summarized as follows.
• We propose in this work a novel adversarial learning method, termed DADA, for closed set domain adaptation. Based on an integrated category and domain classifier, DADA has a novel adversarial objective that encourages a mutually inhibitory relation between category and domain predictions for any input instance, which can promote the joint distribution alignment across domains. • For more realistic partial domain adaptation, we extend DADA by a reliable category-level weighting mechanism, termed DADA-P, which can significantly reduce the negative influence of outlier source instances. • For more challenging open set domain adaptation, we extend DADA by balancing the joint distribution alignment in the shared label space with the classification of outlier target instances, termed DADA-O. • Experiments show the efficacy of our proposed methods and we achieve the new state of the art for all the three adaptation settings on benchmark datasets.

Related Works
Closed Set Domain Adaptation After the seminal work of DANN (Ganin et al. 2016), ADDA (Tzeng et al. 2017) proposes an untied weight sharing strategy to align the target feature distribution to a fixed source one. SimNet (Pinheiro 2018) replaces the standard FC-based cross-entropy classifier by a similarity-based one. MADA (Pei et al. 2018) and CDAN ) integrate the discriminative category information into domain-adversarial training. VADA (Shu et al. 2018) reduces the cluster assumption violation to constrain domain-adversarial training. Some methods Wen et al. 2019) focus on transferable regions to learn domain-invariant features and task classifier. TAT ) enhances the discriminability of features to guarantee the adaptability. Some methods (Saito et al. 2018b;Lee et al. 2019) utilize category predictions from two task classifiers to measure the domain discrepancy. The most related works (Kurmi and Namboodiri 2019;Tran et al. 2019) to us propose joint parameterization of the task and domain classifiers, which implicitly align the joint distributions. Differently, our proposed DADA makes the joint distribution alignment more explicit, thus promoting classification on the target domain.
Partial Domain Adaptation The work  weights each source instance by its importance to the target domain based on one domain classifier, and then trains another domain classifier on target and weighted source instances. The works  reduce the contribution of outlier source instances to the task or domain classifiers by utilizing category predictions. Differently, DADA-P weights the proposed source discriminative adversarial loss by a reliable category confidence.
Open Set Domain Adaptation Previous research (Jain, Scheirer, and Boult 2014) proposes to reject an instance as the unknown category by threshold filtering. The work (Saito et al. 2018c) proposes to utilize adversarial training for both domain adaptation and unknown outlier detection. Differently, DADA-O balances the joint distribution alignment in the shared label space with the outlier rejection.

Method
Given {(x s i , y s i )} ns i=1 of labeled instances sampled from the source domain D s , and {x t j } nt j=1 of unlabeled instances sampled from the target domain D t , the objective of unsupervised domain adaptation is to learn a feature extractor G(·) and a task classifier C(·) such that the expected target risk E (x t ,y t )∼Dt [L cls (C(G(x t )), y t )] is low for a certain classification loss function L cls (·). The domains D s and D t are assumed to have different distributions. To achieve a low target risk, a typical strategy is to learn G(·) and C(·) by minimizing the sum of the source risk and some notion of distance between the source and target domain distributions, inspired by domain adaptation theories (Ben-David et al. 2007;. This strategy is based on a simple rational that the source risk would become a good indicator of the target risk when the distance between the two distributions is getting closer. While most of existing methods use distance measures based on the marginal distributions, it is arguably better to use those based on the joint distributions. The above strategy is generally implemented by domainadversarial learning (Ganin et al. 2016;Wang et al. 2019), where separate task classifier C(·) and domain classifier D(·) are typically stacked on top of the feature extractor G(·). As discussed before, this type of design has the following shortcomings: (1) model capacity of G(·) could be large enough to make D(G(x s )) and D(G(x t )) hardly differentiable for any instance, even though the marginal feature distributions are not well aligned; (2) more importantly, it is difficult to align the source and target distributions with high granularity to the category level (especially for complex distributions with multi-mode structures), and thus C(·) obtained by minimizing the empirical source risk cannot perfectly generalize to the target data due to an issue of mode collapse, i.e. the joint distributions are not well aligned.
To alleviate the above shortcomings, inspired by semisupervised learning methods based on GANs (Salimans et al. 2016;Dai et al. 2017), the recent work (Tran et al. 2019) proposes joint parameterization of C(·) and D(·) into an integrated one F (·). Suppose the classification task of interest has K categories, F (·) is formed simply by augmenting the last FC layer of C(·) with one additional neuron. , which includes a feature extractor G(·) and an integrated category and domain classifier F (·). The blue and orange colors denote G(·) and F (·), and the losses applied to them, respectively. Note that DADA explicitly establishes a discriminative interaction between category and domain predictions. Please refer to the main text for how the adversarial training objective of DADA is defined.
Denote p(x) ∈ [0, 1] K+1 as the output vector of class probabilities of F (G(x)) for an instance x, and p k (x), k ∈ {1, . . . , K + 1}, as its k th element. The k th element of the conditional probability vectorp(x) is written as follows For ease of subsequent notations, we also write p s . Then, such a network is trained by the classification-aware adversarial learning objective where λ balances category classification and domain adversarial losses. The mechanism of this objective to align the joint distributions across domains is rather implicit.
To make it more explicit, based on the integrated classifier F (·), we propose a novel adversarial learning method termed Discriminative Adversarial Domain Adaptation (DADA), which explicitly enables a discriminative interplay of predictions among the domain and K categories for any input instance, as illustrated in Figure 1. This discriminative interaction underlies the ability of DADA to promote the joint distribution alignment, as explained shortly.

Discriminative Adversarial Learning
To establish a direct interaction between category and domain predictions, we propose a novel source discriminative adversarial loss that is tailored to the design of the integrated classifier F (·). The proposed loss is inspired by the principle of binary cross-entropy loss. It is written as Intuitively, the proposed loss (3) establishes a mutually inhibitory relation between p y s (x s ) of the prediction on the true category of x s , and p K+1 (x s ) of the prediction on the domain of x s . We first discuss how the proposed loss (3) works during adversarial training, and we show that under practical conditions, minimizing (3) over the classifier F (·) has the effects of discriminating among task categories while distinguishing the source domain from the target one, and maximizing (3) over the feature extractor G(·) can discriminatively align the source domain to the target one.
Discussion We first write the gradient formulas of L s on any source instance x s w.r.t. p s y s and p s K+1 as Since both p s y s and p s K+1 are among the K + 1 output probabilities of the classifier F (G(x s )), we always have p s y s ≤ 1−p s K+1 and p s K+1 ≤ 1−p s y s , suggesting ∇ p s y s ≤ 0. When the loss (3) is minimized over F (·) via stochastic gradient descent (SGD), we have the update p s y s ← p s y s −η∇ p s y s where η is the learning rate, and since ∇ p s y s ≤ 0, p s y s increases; when it is maximized over G(·) via stochastic gradient ascent (SGA), we have the update p s y s ← p s y s +η∇ p s y s , and since ∇ p s y s ≤ 0, p s y s decreases. Then, we discuss the change of p s K+1 in two cases: (1) in case of p s y s > 0.5 that guarantees ∇ p s K+1 > 0, when minimizing the loss (3) over (2) in case of p s y s < 0.5 that guarantees ∇ p s K+1 < 0, when minimizing the loss (3) over F (·) by SGD update, we have increased p s K+1 , and when maximizing it over G(·) by SGA update, we have decreased p s K+1 , as shown in Figure 2. For discriminative adversarial domain adaptation, we expect that (1) when minimizing the proposed loss (3) over F (·), task categories of the source domain is discriminative and the source domain is distinctive from the target one, which can be achieved when p s y s increases and p s K+1 decreases; (2) when maximizing it over G(·), the source domain is aligned to the target one while retains discriminability, which can be achieved when p s y s decreases and p s K+1 Figure 2: Changes of p s y s and p s K+1 when minimizing and maximizing the loss (3) in the two cases.
increases in the case of p s y s > 0.5. To meet the expectations, the condition of p s y s > 0.5 for all source instances should be always satisfied. This is practically achieved by pre-training DADA on the labeled source data using a Kway cross-entropy loss, and maintaining in the adversarial training of DADA the same supervision signal. We present in the supplemental material empirical evidence on benchmark datasets that shows the efficacy of our used scheme.
To achieve the joint distribution alignment, the explicit interplay between category and domain predictions for any target instance should also be created. Motivated by recent works (Pei et al. 2018;Long et al. 2018b) which alleviate the issue of mode collapse by aligning each instance to several most related categories, we propose a target discriminative adversarial loss based on the design of the integrated classifier F (·), by using the conditional category probabilities to weight the domain predictions. It is written as where the k th element of the domain prediction vectorp k for the k th category is written as followŝ An intuitive explanation for our proposed (4) is provided in the supplemental material. Established knowledge from cluster analysis (Nalewajski 2012) indicates that we can estimate clusters with a low probability of error only if the conditional entropy is small. To this end, we adopt the entropy minimization principle (Grandvalet and Bengio 2005), which is written as where H(·) computes the entropy of a probability vector. Combining (3), (4), and (6) gives the following minimax problem of our proposed DADA min where λ is a hyper-parameter that trade-offs the adversarial domain adaptation objective with the entropy minimization one in the unified optimization problem. Note that in the minimization problem of (7), L t em serves as a regularizer for learning F (·) to avoid the trivial solution (i.e. all instances are assigned to the same category), and in the maximization problem of (7), it helps learn more target-discriminative features, which can alleviate the negative effect of adversarial feature adaptation on the adaptability .
By optimizing (7), the joint distribution alignment can be enhanced. This ability comes from the better use of discriminative information from both the source and target domains. Concretely, DADA constrains the domain classifier so that it clearly/explicitly knows the classification boundary, thus reducing false alignment between different categories. By deceiving such a strong domain classifier, DADA can learn a feature extractor that better aligns the two domains. We also theoretically prove in the supplemental material that DADA can better bound the expected target error.

Extension for Partial Domain Adaptation
Partial domain adaptation is a more realistic setting, where the target label space is subsumed by the source one. The false alignment between the outlier source categories and the target domain is unavoidable. To address it, existing methods Cao et al. 2018b) utilize the category or domain predictions, to decrease the contribution of source outliers to the training of task or domain classifiers. Inspired by these ideas, we extend DADA for partial domain adaptation by using a reliable categorylevel weighting mechanism, which is termed DADA-P.
Concretely, we average the conditional probability vectors p(x t ) ∈ [0, 1] K over all target data and then normalize the averaged vectorc ∈ [0, 1] K by dividing its largest element. The category weight vector c ∈ [0, 1] K with c k as its k th element is derived by a convex combination of the normalized vector and an all-ones vector 1, as follows where λ ∈ [0, 1] is to suppress the detection noise of outlier source categories in the early stage of training. Then, we apply the category weight vector c to the proposed discriminative adversarial loss for any source instance, leading to (9) Since predicted probabilities on the outlier source categories are more likely to increase when minimizing −L t em over F (·), which incurs negative transfer. To avoid it, we minimize L t em over F (·) and the objective of DADA-P is min By optimizing it, DADA-P can simultaneously alleviate negative transfer and promote the joint distribution alignment across domains in the shared label space.

Extension for Open Set Domain Adaptation
Open set domain adaptation is a very challenging setting, where the source label space is subsumed by the target one. We denominate the shared category and all unshared categories between the two domains as the "known category" and "unknown category" respectively. The goal of open set domain adaptation is to correctly classify any target instance as the known or unknown category. The false alignment between the known and unknown categories is inevitable. To this end, the work (Saito et al. 2018c) proposes to make a pseudo decision boundary for the unknown category, which enables the feature extractor to reject some target instances as outliers. Inspired by this work, we extend DADA for open set domain adaptation by training the classifier to classify all target instances as the unknown category with a small probability q, which is termed DADA-O. Assuming the predicted probability on the unknown category as the K th element of p(x t ), i.e., p K (x t ), the modified target adversarial loss when minimized over the integrated classifier F (·) is where 0 < q < 0.5. When maximized over the feature extractor G(·), we still use the discriminative loss L t G in (4). Replacing L t F in (7) with (11) gives the overall adversarial objective of DADA-O, which can achieve a balance between domain adaptation and outlier rejection.
We utilize all target instances to obtain the concept of "unknown", which is very helpful for the classification of unknown target instances as the unknown category but can cause the misclassification of known target instances as the unknown category. This issue can be alleviated by selecting an appropriate q. If q is too small, the unknown target instances cannot be correctly classified; if q is too large, the known target instances can be misclassified. By choosing an appropriate q, the feature extractor can separate the unknown target instances from the known ones while aligning the joint distributions in the shared label space.

Experiments Datasets and Implementation Details
Office-31 (Saenko et al. 2010) is a popular benchmark domain adaptation dataset consisting of 4, 110 images of 31 categories collected from three domains: Amazon (A), Webcam (W), and DSLR (D). We evaluate on six settings. Syn2Real (Peng et al. 2018) is the largest benchmark. Syn2Real-C has over 280K images of 12 shared categories in the combined training, validation, and testing domains. The 152, 397 images on the training domain are synthetic ones by rendering 3D models. The validation and test domains comprise real images, and the validation one has 55, 388 images. We use the training domain as the source domain and validation one as the target domain. For partial domain adaptation, we choose images of the first 6 categories (in alphabetical order) in the validation domain as the target domain and form the setting: Synthetic 12 → Real 6. For open set domain adaptation, we evaluate on Syn2Real-O, which includes two domains. The training/synthetic domain uses synthetic images from the 12 categories of Syn2Real-C as "known". The validation/real domain uses images of the 12 categories from the validation domain of Syn2Real-C as "known", and 50k images from 69 other categories as "unknown". We use the training and validation domains of Syn2Real-O as the source and target domains respectively. Implementation Details We follow standard evaluation protocols for unsupervised domain adaptation (Ganin et al. 2016;Wang et al. 2019): we use all labeled source and all unlabeled target instances as the training data. For all tasks of Office-31 and Synthetic 12 → Real 6, based on ResNet-50 (He et al. 2016), we report the classification result on the target domain of mean(±standard deviation) over three random trials. For other tasks of Syn2Real, we evaluate the accuracy of each category based on ResNet-101 and ResNet-152 (for closed and open set domain adaptation respectively). For each base network, we use all its layers up to the second last one as the feature extractor G(·), and set the neuron number of its last FC layer as K + 1 to have the integrated classifier F (·). Exceptionally, we follow the work (Peng et al. 2018) and replace the last FC layer of ResNet-152 with three FC layers of 512 neurons. All base networks are pre-trained on ImageNet (Russakovsky et al. 2015). We firstly pre-train them on the labeled source data, and then fine-tune them on both the labeled source data and unlabeled target data via adversarial training, where we maintain the same supervision signal as the pre-training.

Analysis Ablation Study
We conduct ablation studies on Office-31 to investigate the effects of key components of our proposed DADA based on ResNet-50. Our ablation studies start with the very baseline termed "No Adaptation" that simply finetunes a ResNet-50 on the source data. To validate the mutually inhibitory relation enabled by DADA, we use DANN (Ganin et al. 2016) and DANN-CA (Tran et al. 2019) respectively as the second and third baselines. To investigate how the entropy minimization principle helps learn more targetdiscriminative features, we remove the entropy minimization loss (6) from our main minimax problem (7), denoted as "DADA (w/o em)". To know effects of the proposed source and target discriminative adversarial losses (3) and (4), we   remove both (6) and (4) from (7), denoted as "DADA (w/o em + w/o td)". Results in Table 1 show that although DANN improves over "No Adaptation", its result is much worse than DANN-CA, verifying the efficacy of the design of the integrated classifier F (·). "DADA (w/o em + w/o td)" improves over DANN-CA and "DADA (w/o em)" improves over "DADA (w/o em + w/o td)", showing the efficacy of our proposed discriminative adversarial learning. DADA significantly outperforms DANN and DANN-CA, confirming the efficacy of the proposed mutually inhibitory relation between the category and domain predictions in aligning the joint distributions of feature and category across domains. Table 1 also confirms that entropy minimization is helpful to learn more target-discriminative features. Quantitative Comparison To compare the efficacy of different methods in reducing domain discrepancy at the category level, we visualize the average probability on the true category over all target instances by task classifiers of No Adaptation, DANN, DANN-CA, and DADA on A → W in Figure 3. Note that here we use labels of the target data for the quantization of category-level domain discrepancy. Figure 3 shows that our proposed DADA gives the predicted probability on the true category of any target instance a better chance to approach 1, meaning that target instances are more likely to be correctly classified by DADA, i.e., a better category-level domain alignment.

Results
Closed Set Domain Adaptation We compare in Tables 2  and 3 our proposed method with existing ones on Office-31 and Syn2Real-C based on ResNet-50 and ResNet-101 respectively. Whenever available, results of existing methods are quoted from their respective papers or the recent works (Pei et al. 2018;Long et al. 2018b;Liu et al. 2019;Saito et al. 2018b). Our proposed DADA outperforms existing methods, testifying the efficacy of DADA in aligning the joint distributions of feature and category across domains. Partial Domain Adaptation We compare in Table 5 our proposed method to existing ones on Syn2Real-C based on ResNet-50. Results of existing methods are quoted from the work ). Our proposed DADA-P substantially outperforms all comparative methods by +15.53%, showing the effectiveness of DADA-P on reducing the neg-    (He et al. 2016) 45.26 DAN  47.60 DANN (Ganin et al. 2016) 51.01 RTN (Long et al. 2016) 50.04 PADA  53.53 DADA-P 69.06 ative influence of source outliers while promoting the joint distribution alignment in the shared label space. Open Set Domain Adaptation We compare in Table 4 our proposed method with existing ones on Syn2Real-O based on ResNet-152. Results of existing methods are quoted from the recent work (Peng et al. 2018). Our proposed DADA-O outperforms all comparative methods in both evaluation metrics of Known and Mean, showing the efficacy of DADA-O in both aligning joint distributions of the known instances and identifying the unknown target instances. It is noteworthy that DADA-O improves over the state-of-theart method AODA by a large margin when the known-tounknown ratio in the target domain is much smaller than 1, i.e. the false alignment between the known source and unknown target instances will be much more serious. This observation confirms the efficacy of DADA-O. We provide more results and analysis for the three problem settings in the supplemental material.

Conclusion
We propose a novel adversarial learning method termed Discriminative Adversarial Domain Adaptation (DADA) to overcome the limitation in aligning the joint distributions of feature and category across domains, which is due to an issue of mode collapse induced by the separate design of task and domain classifiers. Based on an integrated task and domain classifier, DADA has a novel adversarial objective that encourages a mutually inhibitory relation between the category and domain predictions, which can promote the joint distribution alignment. Unlike previous methods, DADA explicitly enables a discriminative interaction between category and domain predictions. Except for closed set domain adaptation, we also extend DADA for more challenging problem settings of partial and open set domain adaptation. Experiments on benchmark datasets testify the efficacy of our proposed methods for all the three settings.