Transfer Learning Library
Deep networks have been successfully applied to learn transferable features for adapting models from a source domain to a different target domain. In this paper, we present joint adaptation networks (JAN), which learn a transfer network by aligning the joint distributions of multiple domain-specific layers across domains based on a joint maximum mean discrepancy (JMMD) criterion. Adversarial training strategy is adopted to maximize JMMD such that the distributions of the source and target domains are made more distinguishable. Learning can be performed by stochastic gradient descent with the gradients computed by back-propagation in linear-time. Experiments testify that our model yields state of the art results on standard datasets.READ FULL TEXT VIEW PDF
Transfer Learning Library
ICML 2017 accepted papers on arXiv.org
Resources and codes about transfer learning and domain adaptation--迁移学习
Deep networks have significantly improved the state of the arts for diverse machine learning problems and applications. Unfortunately, the impressive performance gains come only when massive amounts of labeled data are available for supervised learning. Since manual labeling of sufficient training data for diverse application domains on-the-fly is often prohibitive, for a target task short of labeled data, there is strong motivation to build effective learners that can leverage rich labeled data from a different source domain. However, this learning paradigm suffers from the shift in data distributions across different domains, which poses a major obstacle in adapting predictive models for the target task(Quionero-Candela et al., 2009; Pan & Yang, 2010).
Learning a discriminative model in the presence of the shift between training and test distributions is known as transfer learning or domain adaptation (Pan & Yang, 2010)
. Previous shallow transfer learning methods bridge the source and target domains by learning invariant feature representations or estimating instance importance without using target labels(Huang et al., 2006; Pan et al., 2011; Gong et al., 2013). Recent deep transfer learning methods leverage deep networks to learn more transferable representations by embedding domain adaptation in the pipeline of deep learning, which can simultaneously disentangle the explanatory factors of variations behind data and match the marginal distributions across domains (Tzeng et al., 2014, 2015; Long et al., 2015, 2016; Ganin & Lempitsky, 2015; Bousmalis et al., 2016).
Transfer learning becomes more challenging when domains may change by the joint distributions of input features and output labels, which is a common scenario in practical applications. First, deep networks generally learn the complex function from input features to output labels via multilayer feature transformation and abstraction. Second, deep features in standard CNNs eventually transition from general to specific along the network, and the transferability of features and classifiers decreases when the cross-domain discrepancy increases(Yosinski et al., 2014). Consequently, after feed-forwarding the source and target domain data through deep networks for multilayer feature abstraction, the shifts in the joint distributions of input features and output labels still linger in the network activations of multiple domain-specific higher layers. Thus we can use the joint distributions of the activations in these domain-specific layers to approximately reason about the original joint distributions, which should be matched across domains to enable domain adaptation. To date, this problem has not been addressed in deep networks.
In this paper, we present Joint Adaptation Networks (JAN) to align the joint distributions of multiple domain-specific layers across domains for unsupervised domain adaptation. JAN largely extends the ability of deep adaptation networks (Long et al., 2015)
to reason about the joint distributions as mentioned above, while keeping the training procedure even simpler. Specifically, JAN admits a simple transfer pipeline, which processes the source and target domain data by convolutional neural networks (CNN) and then aligns the joint distributions of activations in multiple task-specific layers. To learn parameters and enable alignment, we derive joint maximum mean discrepancy (JMMD), which measures the Hilbert-Schmidt norm between kernel mean embedding of empirical joint distributions of source and target data. Thanks to a linear-time unbiased estimate of JMMD, we can easily draw a mini-batch of samples to estimate the JMMD criterion, and implement it efficiently via back-propagation. We further maximize JMMD using adversarial training strategy such that the distributions of source and target domains are made more distinguishable. Empirical study shows that our models yield state of the art results on standard datasets.
Transfer learning (Pan & Yang, 2010)
aims to build learning machines that generalize across different domains following different probability distributions(Sugiyama et al., 2008; Pan et al., 2011; Duan et al., 2012; Gong et al., 2013; Zhang et al., 2013)
. Transfer learning finds wide applications in computer vision(Saenko et al., 2010; Gopalan et al., 2011; Gong et al., 2012; Hoffman et al., 2014)2011; Glorot et al., 2011).
The main technical problem of transfer learning is how to reduce the shifts in data distributions across domains. Most existing methods learn a shallow representation model by which domain discrepancy is minimized, which cannot suppress domain-specific exploratory factors of variations. Deep networks learn abstract representations that disentangle the explanatory factors of variations behind data (Bengio et al., 2013) and extract transferable factors underlying different populations (Glorot et al., 2011; Oquab et al., 2013), which can only reduce, but not remove, the cross-domain discrepancy (Yosinski et al., 2014). Recent work on deep domain adaptation embeds domain-adaptation modules into deep networks to boost transfer performance (Tzeng et al., 2014, 2015, 2017; Ganin & Lempitsky, 2015; Long et al., 2015, 2016). These methods mainly correct the shifts in marginal distributions, assuming conditional distributions remain unchanged after the marginal distribution adaptation.
Transfer learning will become more challenging as domains may change by the joint distributions of input features and output labels . The distribution shifts may stem from the marginal distributions (a.k.a. covariate shift (Huang et al., 2006; Sugiyama et al., 2008)), the conditional distributions (a.k.a. conditional shift (Zhang et al., 2013)), or both (a.k.a. dataset shift (Quionero-Candela et al., 2009)). Another line of work (Zhang et al., 2013; Wang & Schneider, 2014) correct both target and conditional shifts based on the theory of kernel embedding of conditional distributions (Song et al., 2009, 2010; Sriperumbudur et al., 2010). Since the target labels are unavailable, adaptation is performed by minimizing the discrepancy between marginal distributions instead of conditional distributions. In general, the presence of conditional shift leads to an ill-posed problem, and an additional assumption that the conditional distribution may only change under location-scale transformations on is commonly imposed to make the problem tractable (Zhang et al., 2013). As it is not easy to justify which components of the joint distribution are changing in practice, our work is transparent to diverse scenarios by directly manipulating the joint distribution without assumptions on the marginal and conditional distributions. Furthermore, it remains unclear how to account for the shift in joint distributions within the regime of deep architectures.
We begin by providing an overview of Hilbert space embeddings of distributions, where each distribution is represented by an element in a reproducing kernel Hilbert space (RKHS). Denote by
a random variable with domainand distribution , and by the instantiations of . A reproducing kernel Hilbert space (RKHS) on endowed by a kernel is a Hilbert space of functions with inner product . Its element satisfies the reproducing property: . Alternatively, can be viewed as an (infinite-dimensional) implicit feature map where
. Kernel functions can be defined on vector space, graphs, time series and structured objects to handle diverse applications. The kernel embedding represents a probability distributionby an element in RKHS endowed by a kernel (Smola et al., 2007; Sriperumbudur et al., 2010; Gretton et al., 2012)
where the distribution is mapped to the expected feature map, i.e. to a point in the RKHS, given that . The mean embedding has the property that the expectation of any RKHS function can be evaluated as an inner product in , . This kind of kernel mean embedding provides us a nonparametric perspective on manipulating distributions by drawing samples from them. We will require a characteristic kernel such that the kernel embedding is injective, and that the embedding of distributions into infinite-dimensional feature spaces can preserve all of the statistical features of arbitrary distributions, which removes the necessity of density estimation of
. This technique has been widely applied in many tasks, including feature extraction, density estimation and two-sample test(Smola et al., 2007; Gretton et al., 2012).
While the true distribution is rarely accessible, we can estimate its embedding using a finite sample (Gretton et al., 2012). Given a sample of size drawn i.i.d. from , the empirical kernel embedding is
This empirical estimate converges to its population counterpart in RKHS norm with a rate of .
Kernel embeddings can be readily generalized to joint
distributions of two or more variables using tensor product feature spaces(Song et al., 2009, 2010; Song & Dai, 2013). A joint distribution of variables can be embedded into an -th order tensor product feature space by
where denotes the set of variables on domain , is the feature map endowed with kernel in RKHS for variable , is the feature map in the tensor product Hilbert space, where the inner product satisfies . The joint embeddings can be viewed as an uncentered cross-covariance operator by the standard equivalence between tensor and linear map (Song et al., 2010). That is, given a set of functions , their covariance can be computed by .
When the true distribution is unknown, we can estimate its embedding using a finite sample (Song et al., 2013). Given a sample of size drawn i.i.d. from , the empirical joint embedding (the cross-covariance operator) is estimated as
This empirical estimate converges to its population counterpart with a similar convergence rate as marginal embedding.
Let and be the sets of samples from distributions and , respectively. Maximum Mean Discrepancy (MMD) (Gretton et al., 2012)
is a kernel two-sample test which rejects or accepts the null hypothesisbased on the observed samples. The basic idea behind MMD is that if the generating distributions are identical, all the statistics are the same. Formally, MMD defines the following difference measure:
where is a class of functions. It is shown that the class of functions in an universal RKHS is rich enough to distinguish any two distributions and MMD is expressed as the distance between their mean embeddings: . The main theoretical result is that if and only if (Gretton et al., 2012).
In practice, an estimate of the MMD compares the square distance between the empirical kernel mean embeddings as
where is an unbiased estimator of .
In unsupervised domain adaptation, we are given a source domain of labeled examples and a target domain of unlabeled examples. The source domain and target domain are sampled from joint distributions and respectively, . The goal of this paper is to design a deep neural network which formally reduces the shifts in the joint distributions across domains and enables learning both transferable features and classifiers, such that the target risk can be minimized by jointly minimizing the source risk and domain discrepancy.
Recent studies reveal that deep networks (Bengio et al., 2013) can learn more transferable representations than traditional hand-crafted features (Oquab et al., 2013; Yosinski et al., 2014). The favorable transferability of deep features leads to several state of the art deep transfer learning methods (Ganin & Lempitsky, 2015; Tzeng et al., 2015; Long et al., 2015, 2016). This paper also tackles unsupervised domain adaptation by learning transferable features using deep neural networks. We extend deep convolutional neural networks (CNNs), including AlexNet (Krizhevsky et al., 2012) and ResNet (He et al., 2016), to novel joint adaptation networks (JANs) as shown in Figure 1. The empirical error of CNN classifier on source domain labeled data is
is the cross-entropy loss function. Based on the quantification study of feature transferability in deep convolutional networks(Yosinski et al., 2014), convolutional layers can learn generic features that are transferable across domains (Yosinski et al., 2014). Thus we opt to fine-tune the features of convolutional layers when transferring pre-trained deep models from source domain to target domain.
However, the literature findings also reveal that the deep features can reduce, but not remove, the cross-domain distribution discrepancy (Yosinski et al., 2014; Long et al., 2015, 2016). The deep features in standard CNNs must eventually transition from general to specific along the network, and the transferability of features and classifiers decreases when the cross-domain discrepancy increases (Yosinski et al., 2014). In other words, even feed-forwarding the source and target domain data through the deep network for multilayer feature abstraction, the shifts in the joint distributions and still linger in the activations of the higher network layers . Taking AlexNet (Krizhevsky et al., 2012) as an example, the activations in the higher fully-connected layers are not safely transferable for domain adaptation (Yosinski et al., 2014). Note that the shift in the feature distributions and mainly lingers in the feature layers while the shift in the label distributions and mainly lingers in the classifier layer . Thus we can use the joint distributions of the activations in layers , i.e. and as good surrogates of the original joint distributions and , respectively. To enable unsupervised domain adaptation, we should find a way to match and .
Many existing methods address transfer learning by bounding the target error with the source error plus a discrepancy between the marginal distributions and of the source and target domains (Ben-David et al., 2010). The Maximum Mean Discrepancy (MMD) (Gretton et al., 2012)
, as a kernel two-sample test statistic, has been widely applied to measure the discrepancy in marginal distributionsand (Tzeng et al., 2014; Long et al., 2015, 2016). To date MMD has not been used to measure the discrepancy in joint distributions and , possibly because MMD has not been directly defined for joint distributions by (Gretton et al., 2012) while in conventional shallow domain adaptation methods the joint distributions are not easy to manipulate and match.
Following the virtue of MMD (5), we use the Hilbert space embeddings of joint distributions (3) to measure the discrepancy of two joint distributions and . The resulting measure is called Joint Maximum Mean Discrepancy (JMMD), which is defined as
Based on the virtue of the kernel two-sample test theory (Gretton et al., 2012), we will have if and only if . Given source domain of labeled points and target domain of unlabeled points drawn i.i.d. from and respectively, the deep networks will generate activations in layers as and . The empirical estimate of is computed as the squared distance between the empirical kernel mean embeddings as
Remark: Taking a close look on the objectives of MMD (6) and JMMD (9), we can find some interesting connections. The difference is that, for the activations in each layer , instead of putting uniform weights on the kernel function as in MMD, JMMD applies non-uniform weights, reflecting the influence of other variables in other layers . This captures the full interactions between different variables in the joint distributions and , which is crucial for domain adaptation. All previous deep transfer learning methods (Tzeng et al., 2014; Long et al., 2015; Ganin & Lempitsky, 2015; Tzeng et al., 2015; Long et al., 2016) have not addressed this issue.
Denote by the domain-specific layers where the activations are not safely transferable. We will formally reduce the discrepancy in the joint distributions of the activations in layers , i.e. and . Note that the features in the lower layers of the network are transferable and hence will not require a further distribution matching. By integrating the JMMD (9) over the domain-specific layers into the CNN error (7), the joint distributions are matched end-to-end with network training,
where is a tradeoff parameter of the JMMD penalty. As shown in Figure 1(a), we set for the JAN model based on AlexNet (last three layers) while we set for the JAN model based on ResNet (last two layers), as these layers are tailored to task-specific structures, which are not safely transferable and should be jointly adapted by minimizing CNN error and JMMD (9).
A limitation of JMMD (9) is its quadratic complexity, which is inefficient for scalable deep transfer learning. Motivated by the unbiased estimate of MMD (Gretton et al., 2012), we derive a similar linear-time estimate of JMMD as follows,
where . This linear-time estimate well fits the mini-batch stochastic gradient descent (SGD) algorithm. In each mini-batch, we sample the same number of source points and target points to eliminate the bias caused by domain size. This enables our models to scale linearly to large samples.
The MMD defined using the RKHS (6) has the advantage of not requiring a separate network to approximately maximize the original definition of MMD (5). But the original MMD (5) reveals that, in order to maximize the test power such that any two distributions can be distinguishable, we require the class of functions to be rich enough. Although (Gretton et al., 2012) shows that an universal RKHS is rich enough, such kernel-based MMD may suffer from vanishing gradients for low-bandwidth kernels. Moreover, it may be possible that some widely-used kernels are unable to capture very complex distances in high dimensional spaces such as natural images (Reddi et al., 2015; Arjovsky et al., 2017).
To circumvent the issues of vanishing gradients and non-rich function class of kernel-based MMD (6), we are enlightened by the original MMD (5) which fits the adversarial training in GANs (Goodfellow et al., 2014). We add multiple fully-connected layers parametrized by to the proposed JMMD (9) to make the function class of JMMD richer using neural network as shown in Figure 1(b). We maximize JMMD with respect to these new parameters to approach the virtue of the original MMD (5), that is, maximizing the test power of JMMD such that distributions of source and target domains are made more distinguishable (Sriperumbudur et al., 2009). This leads to a new adversarial joint adaptation network as
Learning deep features by minimizing this more powerful JMMD, intuitively any shift in the joint distributions will be more easily identified by JMMD and then adapted by CNN.
uses logistic regression. As pointed out in a very recent study(Arjovsky et al., 2017), our JMMD-adversarial network can be trained more easily.
We evaluate the joint adaptation networks with state of the art transfer learning and deep learning methods. Codes and datasets are available at http://github.com/thuml.
Office-31 (Saenko et al., 2010) is a standard benchmark for domain adaptation in computer vision, comprising 4,652 images and 31 categories collected from three distinct domains: Amazon (A), which contains images downloaded from amazon.com, Webcam (W) and DSLR (D), which contain images respectively taken by web camera and digital SLR camera under different settings. We evaluate all methods across three transfer tasks A W, D W and W D, which are widely adopted by previous deep transfer learning methods (Tzeng et al., 2014; Ganin & Lempitsky, 2015), and another three transfer tasks A D, D A and W A as in (Long et al., 2015, 2016; Tzeng et al., 2015).
ImageCLEF-DA111http://imageclef.org/2014/adaptation is a benchmark dataset for ImageCLEF 2014 domain adaptation challenge, which is organized by selecting the 12 common categories shared by the following three public datasets, each is considered as a domain: Caltech-256 (C), ImageNet ILSVRC 2012 (I), and Pascal VOC 2012 (P). There are 50 images in each category and 600 images in each domain. We use all domain combinations and build 6 transfer tasks: I P, P I, I C, C I, C P, and P C. Different from Office-31 where different domains are of different sizes, the three domains in ImageCLEF-DA are of equal size, which makes it a good complement to Office-31 for more controlled experiments.
We compare with conventional and state of the art transfer learning and deep learning methods: Transfer Component Analysis (TCA) (Pan et al., 2011), Geodesic Flow Kernel (GFK) (Gong et al., 2012), Convolutional Neural Networks AlexNet (Krizhevsky et al., 2012) and ResNet (He et al., 2016), Deep Domain Confusion (DDC) (Tzeng et al., 2014), Deep Adaptation Network (DAN) (Long et al., 2015), Reverse Gradient (RevGrad) (Ganin & Lempitsky, 2015), and Residual Transfer Network (RTN) (Long et al., 2016)
. TCA is a transfer learning method based on MMD-regularized Kernel PCA. GFK is a manifold learning method that interpolates across an infinite number of intermediate subspaces to bridge domains. DDC is the first method that maximizes domain invariance by regularizing the adaptation layer of AlexNet using linear-kernel MMD(Gretton et al., 2012). DAN learns transferable features by embedding deep features of multiple task-specific layers to reproducing kernel Hilbert spaces (RKHSs) and matching different distributions optimally using multi-kernel MMD. RevGrad improves domain adaptation by making the source and target domains indistinguishable for a domain discriminator by adversarial training. RTN jointly learns transferable features and adaptive classifiers by deep residual learning (He et al., 2016).
We examine the influence of deep representations for domain adaptation by employing the breakthrough AlexNet (Krizhevsky et al., 2012) and the state of the art ResNet (He et al., 2016) for learning transferable deep representations. For AlexNet, we follow DeCAF (Donahue et al., 2014) and use the activations of layer as image representation. For ResNet (50 layers), we use the activations of the last feature layer as image representation. We follow standard evaluation protocols for unsupervised domain adaptation (Long et al., 2015; Ganin & Lempitsky, 2015). For both Office-31 and ImageCLEF-DA
datasets, we use all labeled source examples and all unlabeled target examples. We compare the average classification accuracy of each method on three random experiments, and report the standard error of the classification accuracies by different experiments of the same transfer task. We perform model selection by tuning hyper-parameters using transfer cross-validation(Zhong et al., 2010). For MMD-based methods and JAN, we adopt Gaussian kernel with bandwidth set to median pairwise squared distances on the training data (Gretton et al., 2012).
We implement all deep methods based on the Caffe
framework, and fine-tune from Caffe-provided models of AlexNet(Krizhevsky et al., 2012) and ResNet (He et al., 2016), both are pre-trained on the ImageNet 2012 dataset. We fine-tune all convolutional and pooling layers and train the classifier layer via back propagation. Since the classifier is trained from scratch, we set its learning rate to be 10 times that of the other layers. We use mini-batch stochastic gradient descent (SGD) with momentum of 0.9 and the learning rate annealing strategy in RevGrad (Ganin & Lempitsky, 2015): the learning rate is not selected by a grid search due to high computational cost—it is adjusted during SGD using the following formula: , where is the training progress linearly changing from to , and , which is optimized to promote convergence and low error on the source domain. To suppress noisy activations at the early stages of training, instead of fixing the adaptation factor , we gradually change it from to by a progressive schedule: , and is fixed throughout experiments (Ganin & Lempitsky, 2015). This progressive strategy significantly stabilizes parameter sensitivity and eases model selection for JAN and JAN-A.
|Method||A W||D W||W D||A D||D A||W A||Avg|
|AlexNet (Krizhevsky et al., 2012)||61.60.5||95.40.3||99.00.2||63.80.5||51.10.6||49.80.4||70.1|
|TCA (Pan et al., 2011)||61.00.0||93.20.0||95.20.0||60.80.0||51.60.0||50.90.0||68.8|
|GFK (Gong et al., 2012)||60.40.0||95.60.0||95.00.0||60.60.0||52.40.0||48.10.0||68.7|
|DDC (Tzeng et al., 2014)||61.80.4||95.00.5||98.50.4||64.40.3||52.10.6||52.20.4||70.6|
|DAN (Long et al., 2015)||68.50.5||96.00.3||99.00.3||67.00.4||54.00.5||53.10.5||72.9|
|RTN (Long et al., 2016)||73.30.3||96.80.2||99.60.1||71.00.2||50.50.3||51.00.1||73.7|
|RevGrad (Ganin & Lempitsky, 2015)||73.00.5||96.40.3||99.20.3||72.30.3||53.40.4||51.20.5||74.3|
|ResNet (He et al., 2016)||68.40.2||96.70.1||99.30.1||68.90.2||62.50.3||60.70.3||76.1|
|TCA (Pan et al., 2011)||72.70.0||96.70.0||99.60.0||74.10.0||61.70.0||60.90.0||77.6|
|GFK (Gong et al., 2012)||72.80.0||95.00.0||98.20.0||74.50.0||63.40.0||61.00.0||77.5|
|DDC (Tzeng et al., 2014)||75.60.2||96.00.2||98.20.1||76.50.3||62.20.4||61.50.5||78.3|
|DAN (Long et al., 2015)||80.50.4||97.10.2||99.60.1||78.60.2||63.60.3||62.80.2||80.4|
|RTN (Long et al., 2016)||84.50.2||96.80.1||99.40.1||77.50.3||66.20.2||64.80.3||81.6|
|RevGrad (Ganin & Lempitsky, 2015)||82.00.4||96.90.2||99.10.1||79.70.4||68.20.4||67.40.5||82.2|
|Method||I P||P I||I C||C I||C P||P C||Avg|
|AlexNet (Krizhevsky et al., 2012)||66.20.2||70.00.2||84.30.2||71.30.4||59.30.5||84.50.3||73.9|
|DAN (Long et al., 2015)||67.30.2||80.50.3||87.70.3||76.00.3||61.60.3||88.40.2||76.9|
|RTN (Long et al., 2016)||67.40.3||81.30.3||89.50.4||78.00.2||62.00.2||89.10.1||77.9|
|ResNet (He et al., 2016)||74.80.3||83.90.1||91.50.3||78.00.2||65.50.3||91.20.3||80.7|
|DAN (Long et al., 2015)||74.50.4||82.20.2||92.80.2||86.30.4||69.20.4||89.80.4||82.5|
|RTN (Long et al., 2016)||74.60.3||85.80.1||94.30.1||85.90.3||71.70.3||91.20.4||83.9|
The classification accuracy results on the Office-31 dataset for unsupervised domain adaptation based on AlexNet and ResNet are shown in Table 1. As fair comparison with identical evaluation setting, the results of DAN (Long et al., 2015), RevGrad (Ganin & Lempitsky, 2015), and RTN (Long et al., 2016) are directly reported from their published papers. The proposed JAN models outperform all comparison methods on most transfer tasks. It is noteworthy that JANs promote the classification accuracies substantially on hard transfer tasks, e.g. D A and W A, where the source and target domains are substantially different and the source domain is smaller than the target domain, and produce comparable classification accuracies on easy transfer tasks, D W and W D, where the source and target domains are similar (Saenko et al., 2010). The encouraging results highlight the key importance of joint distribution adaptation in deep neural networks, and suggest that JANs are able to learn more transferable representations for effective domain adaptation.
The results reveal several interesting observations. (1) Standard deep learning methods either outperform (AlexNet) or underperform (ResNet) traditional shallow transfer learning methods (TCA and GFK) using deep features (AlexNet-fc7 and ResNet-pool5) as input. And traditional shallow transfer learning methods perform better with more transferable deep features extracted by ResNet. This confirms the current practice that deep networks learn abstract feature representations, which can only reduce, but not remove, the domain discrepancy (Yosinski et al., 2014). (2) Deep transfer learning methods substantially outperform both standard deep learning methods and traditional shallow transfer learning methods. This validates that reducing the domain discrepancy by embedding domain-adaptation modules into deep networks (DDC, DAN, RevGrad, and RTN) can learn more transferable features. (3) The JAN models outperform previous methods by large margins and set new state of the art record. Different from all previous deep transfer learning methods that only adapt the marginal distributions based on independent feature layers (one layer for RevGrad and multilayer for DAN and RTN), JAN adapts the joint distributions of network activations in all domain-specific layers to fully correct the shifts in joint distributions across domains. Although both JAN and DAN (Long et al., 2015) adapt multiple domain-specific layers, the improvement from DAN to JAN is crucial for the domain adaptation performance: JAN uses a JMMD penalty to reduce the shift in the joint distributions of multiple task-specific layers, which reflects the shift in the joint distributions of input features and output labels; DAN needs multiple MMD penalties, each independently reducing the shift in the marginal distribution of each layer, assuming feature layers and classifier layer are independent.
By going from AlexNet to extremely deep ResNet, we can attain a more in-depth understanding of feature transferability. (1) ResNet-based methods outperform AlexNet-based methods by large margins. This validates that very deep convolutional networks, e.g. VGGnet (Simonyan & Zisserman, 2015), GoogLeNet (Szegedy et al., 2015), and ResNet, not only learn better representations for general vision tasks but also learn more transferable representations for domain adaptation. (2) The JAN models significantly outperform ResNet-based methods, revealing that even very deep networks can only reduce, but not remove, the domain discrepancy. (3) The boost of JAN over ResNet is more significant than the improvement of JAN over AlexNet. This implies that JAN can benefit from more transferable representations.
The great aspect of JAN is that via the kernel trick there is no need to train a separate network to maximize the MMD criterion (5) for the ball of a RKHS. However, this has the disadvantage that some kernels used in practice are unsuitable for capturing very complex distances in high dimensional spaces such as natural images (Arjovsky et al., 2017). The JAN-A model significantly outperforms the previous domain adversarial deep network (Ganin & Lempitsky, 2015). The improvement from JAN to JAN-A also demonstrates the benefit of adversarial training for optimizing the JMMD in a richer function class. By maximizing the JMMD criterion with respect to a separate network, JAN-A can maximize the distinguishability of source and target distributions. Adapting domains against deep features where their distributions maximally differ, we can enhance the feature transferability.
The three domains in ImageCLEF-DA are more balanced than those of Office-31. With these more balanced transfer tasks, we are expecting to testify whether transfer learning improves when domain sizes do not change. The classification accuracy results based on both AlexNet and ResNet are shown in Table 2. The JAN models outperform comparison methods on most transfer tasks, but by less improvements. This means the difference in domain sizes may cause shift.
Feature Visualization: We visualize in Figures 2(a)–2(d) the network activations of task A W learned by DAN and JAN respectively using t-SNE embeddings (Donahue et al., 2014). Compared with the activations given by DAN in Figure 2(a)–2(b), the activations given by JAN in Figures 2(c)–2(d) show that the target categories are discriminated much more clearly by the JAN source classifier. This suggests that the adaptation of joint distributions of multilayer activations is a powerful approach to unsupervised domain adaptation.
Distribution Discrepancy: The theory of domain adaptation (Ben-David et al., 2010; Mansour et al., 2009) suggests -distance as a measure of distribution discrepancy, which, together with the source risk, will bound the target risk. The proxy -distance is defined as , where is the generalization error of a classifier (e.g. kernel SVM) trained on the binary problem of discriminating the source and target. Figure 3(a) shows on tasks A W, W D with features of CNN, DAN, and JAN. We observe that using JAN features is much smaller than using CNN and DAN features, which suggests that JAN features can close the cross-domain gap more effectively. As domains W and D are very similar, of task W D is much smaller than that of A W, which explains better accuracy of W D.
A limitation of the -distance is that it cannot measure the cross-domain discrepancy of joint distributions, which is addressed by the proposed JMMD (9). We compute JMMD (9) across domains using CNN, DAN and JAN activations respectively, based on the features in and ground-truth labels in (the target labels are not used for model training). Figure 3(b) shows that JMMD using JAN activations is much smaller than JMMD using CNN and DAN activations, which validates that JANs successfully reduce the shifts in joint distributions to learn more transferable representations.
Parameter Sensitivity: We check the sensitivity of JMMD parameter , i.e. the maximum value of the relative weight for JMMD. Figure 3(c) demonstrates the transfer accuracy of JAN based on AlexNet and ResNet respectively, by varying on task A W. The accuracy of JAN first increases and then decreases as varies and shows a bell-shaped curve. This confirms the motivation of deep learning and joint distribution adaptation, as a proper trade-off between them enhance transferability.
Convergence Performance: As JAN and JAN-A involve adversarial training procedures, we testify their convergence performance. Figure 3(d) demonstrates the test errors of different methods on task A W, which suggests that JAN converges fastest due to nonparametric JMMD while JAN-A has similar convergence speed as RevGrad with significantly improved accuracy in the whole procedure of convergence.
This paper presented a novel approach to deep transfer learning, which enables end-to-end learning of transferable representations. Unlike previous methods that match the marginal distributions of features across domains, the proposed approach reduces the shift in joint distributions of the network activations of multiple task-specific layers, which approximates the shift in the joint distributions of input features and output labels. The discrepancy between joint distributions can be computed by embedding the joint distributions in a tensor-product Hilbert space, which can be scaled linearly to large samples and be implemented in most deep networks. Experiments testified the efficacy of the proposed approach.
We thank Zhangjie Cao for conducting part of experiments. This work was supported by NSFC (61502265, 61325008), National Key R&D Program of China (2016YFB1000701, 2015BAF32B01), and Tsinghua TNList Lab Key Projects.
Unsupervised domain adaptation by backpropagation.In International Conference on Machine Learning (ICML), 2015.
IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2012.
Conference on Computational Learning Theory (COLT), 2009.
Hilbert space embeddings of hidden markov models.In International Conference on Machine Learning (ICML), 2010.