{'fraction_non_alphanumeric': 0.04066367985420305, 'fraction_numerical': 0.012149745614701193, 'mean_word_length': 4.524119127516778, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Co-Teaching for Unsupervised Domain Adaptation and Expansion

Unsupervised Domain Adaptation (UDA) is known to trade a model's performance on a source domain for improving its performance on a target domain. To resolve the issue, Unsupervised Domain Expansion (UDE) has been proposed recently to adapt the model for the target domain as UDA does, and in the meantime maintain its performance on the source domain. For both UDA and UDE, a model tailored to a given domain, let it be the source or the target domain, is assumed to well handle samples from the given domain. We question the assumption by reporting the existence of cross-domain visual ambiguity: Due to the lack of a crystally clear boundary between the two domains, samples from one domain can be visually close to the other domain. We exploit this finding and accordingly propose in this paper Co-Teaching (CT) that consists of knowledge distillation based CT (kdCT) and mixup based CT (miCT). Specifically, kdCT transfers knowledge from a leader-teacher network and an assistant-teacher network to a student network, so the cross-domain visual ambiguity will be better handled by the student. Meanwhile, miCT further enhances the generalization ability of the student. Comprehensive experiments on two image-classification benchmarks and two driving-scene-segmentation benchmarks justify the viability of the proposed method.


I. INTRODUCTION
U Nsupervised Domain Adaptation (UDA), aiming to adapt a model trained on a labeled source domain for an unlabeled target domain without the need of re-labeling any data, is a crucial technique for real-world AI [1]- [3]. Applications of this technique includes cross-view person re-ID [4], [5], cross-device medical image analysis [6], [7], and crosscondition autopilot scene segmentation [8], [9], to name just a few. Thanks to the advent of novel methods for UDA [10], [11], we witness an ever-growing performance on the target domain, as demonstrated by public benchmark evaluations such as Office-Home [12] and DomainNet [13] for multiclass image classification and ACDC [14] for driving scene segmentation. However, it has been documented recently in the context of image classification that UDA in fact trades the model's performance on the source domain for improving its performance on the target domain [15], [16]. Such a finding is disturbing, as it suggests that one may have to deploy simultaneously two models to support both domains. Even putting the doubled deployment cost aside, how to swiftly switch between the models is nontrivial as from which domain a test sample comes is unknown. The degeneration of the source-domain performance puts the real-world applicability of UDA into question.
To remedy the issue, GSFDA [16] resorts to continual learning to preserve a model's ability on the source domain while being adapted to the target domain. Since the method assumes zero availability of the original samples from the source domain, it has little chance to recover once degeneration occurs. Indeed, our evaluation indicates that GSFDA remains suffering performance loss on the source domain.
To explicitly quantify the issue, a variant of UDA termed Unsupervised Domain Expansion (UDE) is introduced by Wang et al. [15]. UDE has the same starting point as UDA, i.e. a set of labeled training samples from the source domain and a set of unlabeled training samples from the target domain.
The key difference is that UDE explicitly reports the sourcedomain performance and consequently the performance on an expanded domain covering both the source and target domains. Besides, the KDDE method by [15] assumes that a model tailored to a given domain, let it be the source or the target domain, can well handle samples from the given domain. Accordingly, KDDE runs in two steps, where two domain-specific models are first trained for the source and target domains, respectively. It then performs knowledge distillation, where the dark knowledge of the source-specific (target-specific) teacher is transferred to a student model via source-domain (target-domain) samples exclusively.
We question the assumption of [15] by reporting the existence of cross-domain visual ambiguity. We consider a test image in a specific domain A being cross-domain ambiguous if the test image is wrongly predicted by a model well-trained on domain A but can be correctly classified by a model welltrained on a different domain B. Tab. I shows the percentage of such ambiguous images on Office-Home and DomainNet, respectively. While the number ranges from 1.9% to 7.5%, the result consistently shows the universal existence of interdomain ambiguity across different datasets.
The cross-domain ambiguity is also exemplified in Fig. 1. While the source and target domains are known to be distinct, there lacks a crystally boundary between the two. Hence, samples from one domain can be visually close to the other domain. As such sorts of samples are in minority in their which exploits the domain-specific models in a more effective and easy-to-implement manner. Our major contributions are as follows: • We propose CT as a generic method for unsupervised domain adaptation and expansion. CT consists of knowledge distillation based CT (kdCT) and mixup based CT (miCT). Specifically, kdCT transfers knowledge from a leader-teacher network and an assistant-teacher network to a student network, to let the student better resolve cross-domain ambiguity, while miCT further enhances the generalization ability of the student. • Comprehensive experiments on two image-classification benchmarks, i.e. Office-Home [12] and DomainNet [13], and two driving-scene-segmentation benchmarks, i.e. Cityscapes [17] and ACDC [14], justify the viability of the proposed method and its superior performance against competitive baselines. CT is open-source at GitHub 1 .  [21] or by adversarial training [22]- [26]. In Deep Domain Confusion (DDC) [18], the domain discrepancy between features from the source / target domains is defined as the maximum mean discrepancy (MMD) on the last layers of a deep image classification network. Contrastive Adaptation Network (CAN) [21] takes class information into account, measuring both intra-class and inter-class domain discrepancy. Domain Adversarial Neural Network (DANN) [22] is among the first to introduce adversarial training into the context of UDA. CDAN [23] extends DANN by taking the multiplicative interaction of feature representations and class predictions as the input of its discriminator. SRDC [10] enhances its discriminator by clustering features from intermediate layers of the network. All the above is conducted for image classification. The problem of source-domain performance degeneration is largely overlooked, and persists even in the recent Transformer based method [27], as our experiments will show.

Source-domain samples
We note an increasing interest in extending image-level UDA to the pixel level for cross-domain semantic image segmentation. AdaSegNet [28] and Advent [29] use adversarial training at the output space, while pixel-level adaptation is performed in DCAN [30] and Cycada [31]. More recently, FDA [11] uses self-predicted labels for self-supervised training.
Our proposed CT method conceptually differs from the existing works as it essentially performs meta learning on top of a specific UDA method. Moreover, in contrast to the prior art which cares only the target-domain performance, CT aims for a broader scope that covers the source and target domains both. By contrast, GSFDA [16] tries to prevent performance deterioration on the source domain by continual learning, while PDA [32] attempts to balance the source supervised loss and the cross-domain alignment loss by pareto optimal solution. Our experiment indicates that the deterioration remains. CT works better for both image classification and semantic segmentation.
Progress on UDE. CT is inline with KDDE [15], as both aim for training a model that suits the expanded domain by knowledge distillation (KD). However, KDDE uses its teacher networks in a relatively limited manner, where the knowledge of the teacher network trained for the source (target) domain is transferred to the student network via the source (target) samples exclusively. Consequently, KDDE lacks the ability to fully exploit the potential of the teacher network derived from one domain in handling the cross-domain ambiguity for the other domain.
Multi-Teacher Knowledge Distillation (MTKD). MTKD has been used in the context of multi-source UDA, where multiple domain-adapted teacher models are trained by pairing the target domain with each of the multiple source domains [33], [34]. Such a tactic is inapplicable to single-source UDA as this paper works on. In the context of standard supervised learning, MultiT [35] transfers the dark knowledge of multiple pre-trained teacher networks to a student network by mini-  mizing the KL divergence between the averaged prediction of the teachers and the prediction of the student. Treating the teachers equally, MultiT is suboptimal for UDA/UDE. Different from MultiT whose teacher networks are all fully supervised, the teachers in CT are trained by supervised and semi-supervised learning, respectively. Moreover, to deal with the labeled and unlabeled training samples in an unbiased manner, CT exclusively uses the label-free KL divergence loss.
Co-Teaching. It is worth pointing out that the term coteaching has been used in other contexts which conceptually and technically differ from ours. For supervised learning, Decoupling [36] and Co-Teach [37] aim for label denoising within a single domain. Decoupling simultaneously trains two models h 1 and h 2 , updating them with samples having h 1 (x) = h 2 (x) in a given mini-batch. Co-Teach alternately uses samples correctly classified by one model to train the other model. Since both methods are fully supervised, they are inapplicable for UDA/UDE where the target domain is unlabeled. For multi-target domain adaptation, CGCT [38] proposes a co-teaching strategy that uses a dual classifier head to provide pseudo labels for unlabeled target-domain samples. As our CT is model-agnostic, any UDA method including CGCT can in principle be used to instantiate the UDA module of our method.

A. Problem Formalization
We use x to indicate a specific sample. For a manually labeled sample, we use y to indicate its manual annotation, which can be a one-hot vector for multi-class image classification or a multi-dimensional binary mask for semantic image segmentation. Let N be a deep neural network, which is supposed to output N (x) that well matches the (unknown) label of a novel sample. Following [15], we formalize the UDE task as follows. Given a set of n s labeled samples {(x s , y s )} randomly sampled from a source domain D s and a set of n t unlabeled samples {x t } sampled randomly from a target domain D t , the goal of UDE is to train N that works for an expanded domain covering both D s and D t . Accordingly, we use D s+t to indicate the expanded domain.
The previous approach to UDE, as aforementioned, is Knowledge Distillation Domain Expansion (KDDE) [15]. At a high level, KDDE works in two stages. In the first stage, two domain-specific teacher networks N s and N t are trained, where N s for D s is learned from the labeled set {(x s , y s )} by standard supervised learning, while N t for D t is trained on {(x s , y s )} and {x t } by an off-the-shelf UDA method. In the second stage, knowledge distillation (KD) is performed to inject the dark knowledge of the teacher networks into a student network N u , which will be eventually used for inference. Depending on the domain identity of a training sample, KDDE selectively uses the two teachers, i.e. N s to deal with samples from D s and N t for samples from D t , see Eq. Eq. (1).
The two-stage property of KDDE ensures flexibility in choosing UDA methods for implementing N t . We thecrefore opt to inherit this property, but introduce a novel Co-Teaching (CT) method into the second stage.

B. Framework
As illustrated in Fig. Fig. 2, CT consists of knowledge distillation based CT (kdCT) and mixup based CT (miCT). Both kdCT and miCT are introduced to exploit the domainspecific advantages of the two teacher networks. In particular, kdCT allows the student network to simultaneously learn the two teacher networks' dark knowledge about every training sample. Meanwhile, miCT improves the generalization ability of the student network by using the mixup technique in a cross-domain manner. As the two implementations of CT are orthogonal to each other, they can be used either alone or jointly.
1) Knowledge Distillation based Co-Teaching: We depart from a standard KD process with one student network (N u ) and one teacher network, either N s or N t . Let us consider N s for instance. Given a set of samples {x}, KD from N s to N u is achieved by minimizing the Kullback-Leibler (KL) divergence between N s ({x}) and N u ({x}), defined as KL(N s ({x}), N u ({x})). In a similar manner, we define the loss of KD from N t to N u KL(N t ({x}), N u ({x})).
To perform multi-teacher KD, a straightforward solution is to average the two losses. In the context of UDA / UDE, however, the two teacher networks are supposed to specialize in handling samples from their targeted domains. Thecrefore, we shall not treat them equally. To be more precise, for training samples from D s , we expect that N s leads the teaching process, while the N t acts as an assistant. The opposite is true when exploiting training examples from D t . To that end, we introduce a parameter γ to weigh the importance of two teachers in the kdCT process as: Given Eq. (2), KDDE can now be viewed as a special case of kdCT with γ = 1. Such a mechanism provides the possibility of making correct decision for the samples, which subjectively divided into the host domain but have more opposite domain styles. By contrast, KDDE, exclusively using one teacher network for one domain, lacks such a compensation mechanism by definition.
Concerning the choice of γ, in principle we shall a value larger than 0.5 to emphasize the leading-teacher network, which is N s for samples from D s and N t for samples from D t . It has been recognized that introducing certain randomness into the process of deep network training can make the network more resistant to noise and thus improve its robustness [39]- [42]. Thecrefore, we let γ follow a probability distribution, instead of using a fixed value. Since the beta distribution can produce diversified probability distributions with ease by adjusting two positive shape parameters denoted by α an β, we choose to use γ ∼ Beta(α, β). Our randomness is introduced at a mini-batch level, by sampling randomly a specific γ from the beta distribution per batch.
Given the two domain-specific losses L kdct ({x s }) and L kdct ({x t }) comuted by Eq. (2), we define the overall loss L kdct as their sum.
2) Mixup based Co-Teaching: The Mixup technique [42], which synthesizes a new training sample by a convex combination of two real samples, is shown to be effective for improving image classification networks. We thus re-purpose this technique to generate new domain-expanded samples denoted by {x m }. In particular, x m is obtained by blending x s randomly chosen from D s with x t randomly chosen from D t .
Our mixup based Co-Teaching (miCT) is implemented by transferring the two-teacher knowledge via the mixed samples to the student network. The teachers' joint knowledge w.r.t. x m is naturally creflected by their combined prediction denoted aŝ y m . Accordingly, the loss of miCT L mict is computed as with λ ∼ Beta(1, 1).
Both L kdct and L mict are KL-divergence based losses for knowledge distillation. So they can be directly added and minimized together for the joint use of kdCT and miCT.

C. Applications
As Fig. 2 shows, CT is a generic method for UDA and UDE. Depending on the choice of the network and the loss function, the method can be used with ease for multi-class image classification and semantic image segmentation. For the former task, a classification network, e.g. ResNet [43], shall be used with the KD losses computed at the image level. For the latter, a segmentation network, e.g. DeepLabv2 [44], shall be adopted with the KD losses computed at the pixel level.

IV. EXPERIMENTS
We evaluate the viability of the proposed CT method in the context of two tasks, i.e. multi-class image classification and driving scene segmentation. It is worth pointing out that UDE as an emerging topic is less studied. We shall naturally include methods directly targeted at UDE, namely KDDE [15]. Meanwhile, as our method is built based on two teacher networks (N s and N t ), methods used for obtaining these networks, e.g. SRDC for image classification [10] and FDA [11] for semantic segmentation, shall be treated as baselines.
In addition, methods developed for other purposes yet technically applicable for UDE, e.g. MultiT [35] which performs knowledge distillation given multiple teachers is also included. So for a fair and comprehensive evaluation, we organize the competitor methods into the following three groups: methods targeted at UDE, methods targeted at UDA, and methods technically related. All experiments are run within the PyTorch framework with two NVIDIA Tesla P40 cards.
A. Task 1. Multi-Class Image Classification 1) Experimental Setup: We adopt two public collections, Office-Home [12] and DomainNet [13]. Office-Home contains 15,588 images of 65 object classes common in office and home scenes, e.g. chair, table and TV. There are four different domains, i.e. artistic images (A), clip art (C), product images (P), and real-world images (R). DomainNet, previously used in the Visual Domain Adaptation Challenge at ICCV 2019 2 , has 362,470 images of 345 object classes from four domains, i.e. clipart, painting, real, and sketch. In order to evaluate a model's performance on both source and target domains, we adopt the data split provided by [15], where images per domain have been divided at random into two disjoint subsets, one for training and the other for test 3 . A specific UDE task is defined with one domain as D s and another domain as D t . Per collection, by pairing its individual domains, we define 12 tasks in total.
Competitor methods. We include as a baseline ResNet-50 trained by standard supervised learning on D s . As mentioned above, we compare with existing methods from the following three groups:  [38].
As each method is provided with the same training data and eventually yields a specific ResNet-50 network for inference, such an experimental setup enables a head-to-head comparison between the different methods.
In order to study whether CT also works with the latest Transformer-based method, we try to improve CDTrans [27] with CT. Different from the previous baselines, CDTrans uses DeiT-Base [45] as its backbone. We simply use the same training protocol (optimizer, initial learning rate, learning rate adjustment strategy etc. ) as used for CNN.
Details of implementation. Following [15], we train networks by SGD with a momentum of 0.9, an initial learning rateof 0.005, and a weight decay of 0.0005. The learning rate is decayed by 0.1 every 30 epochs on Office-Home and every 10 epochs on DomainNet. A fixed number of training epochs is used, which is 100 for Office-Home (with batch size 32) and 30 on DomainNet (with batch size 96) as the latter is much larger. Models obtained at the last epoch are used for evaluation. Each method is run independently three times with averaged performance reported.
Note that not all methods are compared on DomainNet due to their high demand on GPU computational resources that are beyond our capacity. Also notice that the performance of the baselines appear lower than that reported in their original papers. Our data split follows [15], "for each domain, we randomly divide its images into two disjoint subsets, one for training and the other for test, at a ratio of 1:1", while other works typically use much more training data, e.g. [10] uses "all labeled source samples and all unlabeled target samples as the training data". Such difference results in the performance gap.
Performance metric. We report accuracy (%), i.e. the percentage of test images correctly classified.   proposed CT performs the best. Given DDC as N t , CT even outperforms N s on D s . When evaluated in the UDA setting to which only the performance on D t matters, CT again compares favorably against the best UDA method, i.e. GSFDA. CT is also better than KDDE and MultiT. As for the UDE setting, the lower performance of MultiT than KDDE and CT confirms our hypothesis that the two teacher networks shall not be treated equally in the knowledge distillation process. Given DDC / SRDC as N t , CT outperforms KDDE by 0.52% (72.47 → 72.99 / 74.37 → 74.89). When using CDAN as N t , a larger gain of 1.36% (72.00 → 73.36) is obtained on Office-Home. As Tab. IV shows, the proposed CT steadily surpasses KDDE for all the 12 tasks on the expanded domain.
CT for Transformer-based UDA. As Tab. III shows, CT exceeds CDTrans on the target domain, and obtains better performance on the expanded domain (82.07→83.62). Also note that the issue of source-performance degeneration is alleviated (85.37→88.06). The above result allows us to conclude that CT can also work with the transformer-based UDA.
On addressing the cross-domain ambiguity. While the above experiments have shown that the student network derived by kdCT is better than its KDDE / MultiT counterparts, it remains not entirely conclusive that kdCT can better handle the cross-domain ambiguity. In that regard, we group all test samples w.r.t. to the prediction (in)consistency between the two teacher networks. In particular, depending on whether the predictions of N s and N t are consistent (=) or inconsistent ( =), samples are exclusively grouped. The inconsistent group covers the visually ambiguous samples. The fine-grained result is shown in Tab. V. We can mostly attribute the success of kdCT to its superior performance on the inconsistent group, which confirms the effectiveness of compensation mechanism from CT. As Fig. 3 shows, the activated regions w.r.t. kdCT is more precise than the others. Both quantitative and qualitative results justify the efficacy of CT.  able to train the following UDA methods, i.e. CDAN, DANN and DDC. As Tab. II shows, using either DDC or CDAN as N t , our CT method again achieves the best performance on D s , D t and D s+t . In particular, CT exceeded KDDE on 11/12 tasks, see Tab. VI. 4) Ablation Study: We choose Office-Home for ablation study, simply because the set is more computationally friendly than DomainNet.
The influence of kdCT and miCT. As shown in Tab. VII, kdCT is better than miCT when they are used alone. Their joint use is recommended for the image classification task. The lower performance of miCT is because we train on mixup samples exclusively, without using original samples. Similar to a standard mixup, mixup samples shall not be used alone.
The influence of γ. Tab. VIII reports the performance of kdCT given γ specified in varied manners. The stochastic strategy with γ ∼ Beta(10, 1) leads to the best performance on the expanded domain. In particular, we also tried fixing γ to 0.909, which is the expectation value of Beta(10, 1), see   B. Task 2. Driving Scene Segmentation 1) Experimental Setup: We follow the setup of [14], using Cityscapes [17] as D s and ACDC [14] as D t . Both datasets have pixel-level ground truth w.r.t. 19 traffic-related labels such as bicycle, road and sidewalk. Different from Cityscapes Baselines. We again compare with KDDE [15]. Our choice of N s is DeepLabv2 [44] with ResNet-101 as its backbone, as has been used in the previous work [14]. As for N t , we adopt the classic AdaSegNet [28] and the more recent FDA [11], which is found to be the most effective on ACDC [14].
Details of Implementation. Following [44], we adopt SGD with an initial learning rate of 0.001, a momentum of 0.9, and a weight decay of 0.0005. We train 75000 iterations with batch size 1. Previous work on semantic image segmentation [47] reports the Mixup technique has an adverse effect on the performance, which is also observed in our preliminary experiment on driving scene segmentation, we therefore uses  CT without miCT for this task. Performance metric. We report IoU per class, and mean IoU (mIoU) for measuring the overall performance.
2) Results: On the source domain, we observe that the performance of the AdaSegNet and FDA decreases in X, which confirms the necessity of the UDE for semantic segmentation. Two-stage methods can alleviate the decline, and CT outperforms KDDE. Under the UDA setting, CT boosts both UDA methods and achieves the best performance on the target domain. As Fig. 5 shows, for the adverse conditions, CT produces more accurate segmentation, e.g. reducing misclassification of the sky into buildings. On the expanded domain, CT achieves the best performance on the most categories in X and CT(FDA) achieves the best average performance for UDE. This demonstrates our method's applicability to crosscondition driving scene segmentation.
In addition, we provide pixel-level classification accuracy in Tab. IX. The superior performance of CT on the pixels with inconsistent N s and N t predictions shows the effectiveness of CT for tackling the cross-domain ambiguity in the context of driving scene segmentation.

V. SUMMARY AND CONCLUSIONS
We have presented Co-Teaching (CT) as new method for both UDA and UDE. Our multi-class image classification experiments on two public benchmarks, i.e. Office-Home and DomainNet, and semantic image segmentation experiments on another two public sets, i.e. Cityscapes and ACDC, support our conclusions as follows. Due to the existence of crossdomain ambiguity, a domain-specific model is not universally applicable to handle samples from its targeted domain. With its ability to resolve such ambiguity, CT beats strong baselines on UDA, i.e. GSFDA for image classification and FDA for driving scene segmentation. CT is also better than the prior art on UDE, i.e. KDDE, for both tasks.