# Rethink Maximum Mean Discrepancy for Domain Adaptation

Existing domain adaptation methods aim to reduce the distributional difference between the source and target domains and respect their specific discriminative information, by establishing the Maximum Mean Discrepancy (MMD) and the discriminative distances. However, they usually accumulate to consider those statistics and deal with their relationships by estimating parameters blindly. This paper theoretically proves two essential facts: 1) minimizing the MMD equals to maximize the source and target intra-class distances respectively but jointly minimize their variance with some implicit weights, so that the feature discriminability degrades; 2) the relationship between the intra-class and inter-class distances is as one falls, another rises. Based on this, we propose a novel discriminative MMD. On one hand, we consider the intra-class and inter-class distances alone to remove a redundant parameter, and the revealed weights provide their approximate optimal ranges. On the other hand, we design two different strategies to boost the feature discriminability: 1) we directly impose a trade-off parameter on the implicit intra-class distance in MMD to regulate its change; 2) we impose the similar weights revealed in MMD on inter-class distance and maximize it, then a balanced factor could be introduced to quantitatively leverage the relative importance between the feature transferability and its discriminability. The experiments on several benchmark datasets not only prove the validity of theoretical results but also demonstrate that our approach could perform better than the comparative state-of-art methods substantially.

## Authors

• 339 publications
• 18 publications
• 23 publications
• 21 publications

Adversarial training is a useful approach to promote the learning of tra...
05/28/2019 ∙ by Zeya Wang, et al. ∙ 1

• ### Joint Domain Alignment and Discriminative Feature Learning for Unsupervised Deep Domain Adaptation

Recently, considerable effort has been devoted to deep domain adaptation...
08/28/2018 ∙ by Chao Chen, et al. ∙ 0

Unsupervised Domain Adaptation (UDA) makes predictions for the target do...
01/04/2019 ∙ by Guoliang Kang, et al. ∙ 0

• ### A Unified Joint Maximum Mean Discrepancy for Domain Adaptation

Domain adaptation has received a lot of attention in recent years, and m...
01/25/2021 ∙ by Wei Wang, et al. ∙ 0

• ### Domain Alignment with Triplets

Deep domain adaptation methods can reduce the distribution discrepancy b...
12/03/2018 ∙ by Weijian Deng, et al. ∙ 0

• ### Probabilistic Filtered Soft Labels for Domain Adaptation

Many domain adaptation (DA) methods aim to project the source and target...
12/24/2019 ∙ by Wei Wang, et al. ∙ 16

• ### Single Image Human Proxemics Estimation for Visual Social Distancing

In this work, we address the problem of estimating the so-called "Social...
11/03/2020 ∙ by Maya Aghaei, et al. ∙ 2

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## I Introduction

Due to the available substantial amount of labeled data, traditional machine learning algorithms have achieved remarkable performances on the object recognition task when the training and test data follow the same or similar distributions. In most realistic scenarios, though, only a fully-labeled source domain is available to us, from which we do wish to learn a transferable classifier from the source domain, to correctly predict the data labels for a new target domain with different distribution

[ACM1, ACM2, ACM3]. Fortunately, Domain Adaptation (DA) as a novel emerging technique has prepared us for this pressing challenge, or rather, it has been committed to narrowing the distributional differences between the source and target domains so that extensive knowledge in the source domain could be desirably transferred to the target, thus the relabeling consumption is mitigated largely [ACM4, ACM5, ACM6].

An essential issue in the DA is to formulate an appropriate metric of the distributional distance to be used for measuring the proximity of two different distributions. Over the years, numerous distance-metric methods were proposed. For example, the Quadratic [BD], Kullback-Leibler [KL], Mahalanobis [RTML]

distances that are derived from the Bregman Divergence but generated by different convex functions were introduced to explicitly match the two different distributions. However, it is inflexible to extend them into different DA models due to their inconvenient manipulation. Additionally, on account of theoretical deficiencies, they are unable to describe more complicated distributions such as conditional and joint distributions. The Wasserstein distance from optimal transport problem exploited a transportation plan also aligning the two different distributions

[WD], but it is still very tedious to be applied to subspace-learning DA methods because it will come down to a complex bi-level optimization problem that is nontrivial to optimize.

Noticeably, the Maximum Mean Discrepancy (MMD) [MMD]

, a metric based on the embedding of distribution measures in a reproducing kernel Hilbert space, has been applied successfully in a wide range of problems thanks to its simplicity and solid theoretical foundation, such as transfer learning

[TCA]

, kernel Bayesian inference

[KBP], approximate Bayesian computation [ABC], two-sample [MMD], goodness-of-fit testing [GFT], MMD GANs [GMMN], and auto-encoders [IFVAE], etc. For the DA setting, MMD aimed to minimize the deviation of means that are respectively computed by the source and target domains. Together with label constraint, the class-wise MMD [JDA] further diminished the mean deviations of each two coupled classes with the same labels but respectively from the two different domains. Moreover, MMD and class-wise MMD are usually adopted to respectively measure the marginal and conditional distribution differences between the two different domains [JDA]. Notably, this paper only concentrates on rethinking the class-wise MMD since MMD is a special case of the class-wise MMD when we regard a domain as one category, and the DA performances are mainly determined by the class-wise MMD.

The early DA methods usually directly integrated the MMD with some predefined models [Dann1, DDC, TCA, SPDA, TSC], while some recent approaches were proposed to further study the MMD in-depth and elaborately improved the MMD using some prior data information [BDA, MEDA, WMMD, DAN, JAN, HoMM]. However, the adverse impacts of MMD on some domain-specific data properties that are implicit in the original feature space are ignored carelessly, such as the feature discriminability and the local manifold structure of data, etc. Differently, some remarkable algorithms were raised to accumulate to devise various regularization losses independently of the MMD to offset the negative influences that arise from the MMD [VDA, DICD, TIT, GEF, LPJT, TRSC, ARTL, SCA, JGSA]. Especially, some discriminative DA methods established the discriminative distances (i.e., intra-class and inter-class distances) like Local Discriminant Analysis (LDA) [HMLDA] to further respect the discriminative information of each specific domain. However, it is hard to study the relationships between those statistics qualitatively and quantitatively due to deficiencies in the theory, so that more parameters have to be estimated blindly and the learned DA models are often unstable. Strikingly, this paper mainly aims to answer the following two essential questions: 1) how exactly does the MMD minimize the mean deviations between the two different domains? 2) why does the MMD usually produce an unexpected deterioration of the feature discriminability?

As we all known, the DA technique, as a branch of transfer learning, also aimed to simulate the transferable intelligence of human beings, so that the feature representations of those images with the same semantic (i.e., category) are as similar as possible. As shown in Fig. 1, we expect to leverage the common features shared between the source and target domains by minimizing their mean deviations of each pair of categories, even though they follow very different distributions, but how exactly does it work? Strikingly, this paper presents a novel insight into the MMD and theoretically reveals that its working principle could reach a high consensus with the transferable behavior of human beings. As shown in Fig. 1, given a pair of classes with the label Desktop_computer respectively from the source and target domains, 1) the two relatively smaller red circles (i.e., the hollow and meshed ones) are transformed into the larger red ones which are magnified greatly (i.e., maximizing their specific intra-class distances); 2) the two tiny red circles are gradually drawn closer to each other along with their specific arrows (i.e., minimizing their joint variance). It is generally known that human beings attempt to abstract the common feature of a provided semantic, so that it could embrace all its possible appearances, i.e., 1), but the detailed information is decayed heavily, i.e., 2). Therefore, the proposed novel insight is highly consistent with the transferability of human beings, and the detailed theoretical proof will be elaborated in the Section II-C. Remarkably, this paper theoretically proves that the discriminative distances involved in the MMD are distinctly different from the ones in the LDA [HMLDA] since there exist different weights imposed on various classes. As shown in Fig. 1, those relatively smaller circles are enlarged and drawn closer with varying degrees.

Given the facts illustrated above, the reasons for degradation of the feature discriminability in the MMD could be therefore revealed. As can be seen from Fig. 1, the common features of Desktop_computer and Trash_can (resp. Laptop_computer and Monitor) are quite similar, and the feature discriminability performs worse than before since the circles of different categories will chaotically overlap to each other. This observation provides us qualitative and quantitative guidance in studying the relationship between the MMD and the discriminative distances (i.e., transferability vs discriminability), and devising more robust and effective DA models. Qualitatively, this paper proposes a discriminative MMD with two different strategies to prompt the leveraged features more discriminative: 1) we directly impose a trade-off parameter on the implicit intra-class distance of the MMD to regulate its change; 2) we impose the similar weights revealed in the MMD on the inter-class distance and maximize it. Although two parameters are still involved, we have no longer need to estimate it blindly in the unknown regions and it is easy to know how the feature properties will change with varying parameter values since we experimentally observe that the implicit weights imposed on the discriminative distances revealed here are very close to the optimal ones empirically set in existing discriminative DA models (Section IV-C), which theoretically gives the approximate optimal parameter ranges, thus different feature properties could be regulated more exactly. Specifically, the trade-off parameter in the first strategy could be set between and , where the intra-class distance is regulated corresponding with different physical meanings (i.e., suppressing/removing its expansion, enhancing its compactness instead). Moreover, the balanced factor in the second manner could be set between and , to quantitatively leverage the relative importance between the feature transferability and its discriminability. Finally, we consider the intra-class and inter-class distances alone in the proposed two strategies, since this paper proves that their relationship is as one falls, another rises, thus the redundant parameter could be omitted. By and large, the main contributions of our work are three-folds:

• This paper theoretically proves that the working principle of the MMD, and illustrate the reasons for degradation of feature discriminability, which provides qualitative and quantitative guidance in studying their relationship and devising more robust and effective DA models.

• This paper proposes a discriminative MMD with two different strategies, which provides the approximate optimal parameter ranges and the corresponding physical meanings with different parameter values, thus the different feature properties could be regulated more exactly.

• This paper considers the intra-class and inter-class distances alone in the proposed two strategies since we prove that their relationship is as one falls, another rises, thus the redundant parameter could be further omitted.

## Ii Rethink MMD

### Ii-a Preliminary

In this paper, a matrix is denoted as the bold-italic uppercase letter (e.g., X

) but a column vector is represented as the bold-italic lowercase letter (e.g.,

x), and is the -th column of X. In addition, is the value from the -th row and the -th column of X, and is the -th value of . is the Frobenius norm of X, and is the -norm of . The superscript and are the transpose and trace operators. The indexes of source and target domains are denoted using the subscripts and . The index of the -th category is defined by the superscript .

In DA scenario, there have a labled source domain (i.e., data matrix , label vector ) but an unlabeled target domain (i.e., ), where is the feature dimension and is the number of source/target data instances, and the whole data matrix is (). Notably, if not stated otherwise, represents the data matrix of any given domain, and its label vector is . Our goal is to jointly project the source and target domains data into a common feature subspace so that the distributional differences between their new feature representations (i.e., ) are minimized substantially.

### Ii-B Revisit MMD

To be specific, the marginal distribution difference between the two domains could be measured using the Maximum Mean Discrepancy (MMD), which computes the deviation of their specific means, and could be formulated as follows

 ||1ns∑{x}i∈{X}s{A}⊤{x}i−1nt∑{x}j∈{X}t{A}⊤{x}j||22=tr({A}⊤{X% }st{M}0{X}⊤st{A}), (1)

where is computed as follows

 ({M}0)ij=⎧⎪ ⎪ ⎪⎨⎪ ⎪ ⎪⎩\par1nsns,({x}i,{x}j∈{X}s)\par1ntnt,({x}i,{x}j∈{X}t)\par−1nsnt,(otherwise).\par (2)

Together with label constraint, the class-wise MMD is modeled to approximately measure the conditional distribution difference across the two domains, which further computes the mean deviations of each two coupled classes with the same labels but from different domains, and it could be defined as follows

 ∑Cc=1||1ncs∑{x}i∈{X}cs{A}⊤{x}i−1nct∑{x}j∈{X}ct{A}⊤{x}j||22=∑Cc=1tr({A}⊤{X}st{M}c% {X}⊤st{A}), (3)

where (resp. ) is the data samples pertaining to the -th category of source domain (resp. target domain), and its number is (resp. ). Likewise, the is computed as follows

 ({M}c)ij=⎧⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎩\par1ncsncs,({x}i,{x}j∈{X}cs)\par1nctnct,({x}i,{x}j∈%Xct)\par−1ncsnct,{{x}i∈{X}cs,{x}j∈{X}ct{x}j∈{X}cs,{x}i∈{X}ct\par0,(otherwise).\par (4)

Notably, the MMD is a special case of class-wise MMD where the whole source/target domain data is regarded as one category. Once those two metrics of distributional distance are established, we can jointly reduce the marginal and conditional distribution differences between the source and target domains by minimizing the MMD and class-wise MMD losses in a given feature learning framework (e.g., the Principal Component Analysis, PCA), and it could be formulated as follows

 min{A}∑Cc=0tr({A}⊤{X}st{M}c{X}⊤st{A})+α||{A}||2Fs.t.{A}⊤{X}st{H}st{% X}⊤st{A}={I}k×k, (5)

where the constraint means that the whole data variance is tied to a fixed value, so that the data information on the subspace could be statistically preserved to some extent. controls the scale of projection A, and is the trade-off parameter. Notably,

denotes an identity matrix with the size of

, is a matrix whose elements are all with the size of , and is a centering matrix.

### Ii-C Rethink MMD

Although the MMD has been widely utilized in the cross-domain problem, its detailed working principle is still under insufficient exploration so far. Notably, this paper only focuses on the class-wise MMD because it plays a decisive role in the DA performances, and the MMD is a special case of class-wise MMD.

This paper mainly answers the following two essential questions: 1) how exactly does the MMD minimize the mean deviations between the two different domains? 2) why does the MMD usually produce an unexpected deterioration of the feature discriminability? To this end, a novel insight is firstly provided theoretically, and we now present Lemma 1 Lemma 3 as follows

Lemma 1. We have the following identity about the inter-class distance according to [HMLDA]

 tr({A}⊤{S}b{A})=1nC−1∑i=1C∑j=i+1ninjtr({A}⊤{D}ij{A}), (6)

where , and is the inter-class scatter matrix. Notably, / denotes the mean of data instances from the /-th category, the number of data instances is , and m is the mean of the whole data samples.
Lemma 2. The inter-class distance equals to the data variance minus the intra-class distance

 tr({A}⊤{S}b{A})=tr({A}⊤{S}v{A})−tr({A}⊤{S}w{A% }), (7)

where is the variance matrix, and is the intra-class scatter matrix.

Proof. .
because and . Then , and . This completes the proof.
Lemma 3. We have the following identity about the MMD

 ∑Cc=1tr({A}⊤{X}{M}% c{X}⊤{A})=∑Cc=1ncs+nctncsncttr({A}⊤({S}st)cb{% A})=∑Cc=1ncs+nctncsncttr({A}⊤({S}st)cv{A})−∑Cc=1ncs+nctncsncttr({A}⊤({S}st)cw{A}), (8)

where , , and . Notably, is the number of data instances of the -th category from the -th domain, and . Besides, is the data mean of the -th category from the -th domain, and is the data mean of the -th category from both the source and target domains.
Proof. Given the data instances of -th categories respectively from the source and target domains, because , and Lemma 1, Lemma 2, we have

 tr({A}⊤{X}{M}c{% X}⊤{A})=ncs+nctncsncttr({A}⊤({S}st)cb{A})=ncs+nctncsncttr({A}⊤(% {S}st)cv{A})−ncs+nctncsncttr({A}⊤({S}st)cw{A}). (9)

Notably, the Eq. 8 is the sum of Eq. 9. This completes the proof.

From Eq. 9, it could be concluded that the MMD aims to respectively maximize the source and target intra-class distances but jointly minimize their variance with different weights, which are separately established by each pair of classes with the same labels but from the source and target domains. This conclusion illustrates the detailed working principle of the MMD that how it precisely minimizes the mean deviations. Moreover, since the intra-class distance is enlarged greatly and the whole data variance is tied to a fixed value (i.e., Eq. 5), the inter-class distance will be drawn closer (i.e., Lemma 2). Thus, different classes will chaotically overlap to each other with various degrees, and the feature discriminability is degraded largely, which provides us qualitative and quantitative guidance in studying the relationship between the MMD and the discriminative distances, and devising more robust and effective DA models. Based on this, in the next subsection, we will propose a discriminative MMD with two different strategies to prompt the extracted features more discriminative.

## Iii The Proposed Approach

According to Lemma 3, we could rewrite Eq. 5 using the equivalent formulation of the original MMD as follows

 min{A}tr({A}⊤{X}% st{M}0{X}⊤st{A})+∑Cc=1wcsttr({A}⊤{X}st(({L}st)cv−({L}st)cw){X}⊤st{A})+α||{A}||2Fs.t.{A}⊤{X}st{H}st{X}⊤st{A}={I}k×k, (10)

where , and and are the Laplacian matrix of and , respectively. We let , and define as follows

 ({V}c∗st)ij=⎧⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪⎩1ncsncs,({x}i,{x}j∈{X}cs)1nctnct,({x}i,{x}j∈{X}ct)0,(otherwise).\par (11)

Moreover, we define and , thus . For the convenience of matrix operation in Eq. 10, we utilize and to define and as follows

 ⎧⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎩(({L}st)cv)({y}s=c,{y}s=c)=({L}st)c∗v(1:ncs,1:ncs),(({L}st)cv)({y}t=c,{y}t=c)=({L}st)c∗v(ncs+1:ncs+nct,ncs+1:ncs+nct),(({L}st)cv)({y}s=c,{y}t=c)=({L}st)c∗v(1:ncs,ncs+1:ncs+nct),(({L}st)cv)({y}t=c,{y}s=c)=({L}st)c∗v(ncs+1:ncs+nct,1:ncs),0,(otherwise).\par (12)
 ⎧⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎩(({L}st)cw)({y}s=c,{y}s=c)=({L}st)c∗w(1:ncs,1:ncs),(({L}st)cw)({y}t=c,{y}t=c)=({L}st)c∗w(ncs+1:ncs+nct,ncs+1:ncs+nct),(({L}st)cw)({y}s=c,{y}t=c)=({L}st)c∗w(1:ncs,ncs+1:ncs+nct),(({L}st)cw)({y}t=c,{y}s=c)=({L}st)c∗w(ncs+1:ncs+nct,1:ncs),0,(otherwise).\par (13)

Now, we devise a discriminative MMD with two different strategies, and they could be formulated as Eq. 14 and Eq. 15.

### Iii-a The First Strategy

 min{A}∑Cc=1{w}csttr({A}⊤{X}st(({L}st)cv+β({L}st)cw){X}⊤st{A})+tr({A}⊤{X}st{M}0{X}⊤st{A})+α||{A}||2Fs.t.{A}⊤{X}st% {H}st{X}⊤st{A}={I}k×k. (14)

Here, a trade-off parameter between and is directly imposed on the implicit intra-class distance of MMD. Notably, the revealed weights could provide us the theoretical guidance for setting parameter imposed on the intra-class distance, and intensifying the feature discriminability more correctly, since the optimal parameter regions are revealed by the implicit weights, and we exactly knew how it will change the leveraged feature properties with varying .

Specifically, there exist three cases respecting Eq. 14: 1) the expansion of intra-class distance is gradually mitigated when ; 2) the adverse influences on the intra-class distance is offset exactly when ; 3) the intra-class compactness is positively stimulated instead of weakening it when .

Similar to previous work [JDA, BDA, VDA], Eq. 14 is equivalent to a generalized eigen-decomposition problem as follows

 (∑Cc=1{X}st({w}cst({L}st)cv−{w}cstβ({L}st)cw+{M}0){X}⊤st+α{I}m×m){A}={X}st{H}st{X}⊤st{A}Θ, (15)

where is a diagonal matrix with Lagrange Multipliers. The Eq. 15

can be effectively and efficiently solved by calculating the eigenvectors corresponding to the

-smallest eigenvalues.

### Iii-B The Second Strategy

 min{A}λ∑Cc=1{w}csttr({A}⊤{X}st(({L}st)cv−({L}st)cw){X}⊤st{A})−(1−λ)∑i=1∑j=i+1tr({A}⊤{X}st[({L}s)ijb,{0};{0},({L}t)ijb]{X}⊤st{A})+tr({A}⊤{X}st{M}0{X}⊤st{A})+α||{A}||2Fs.t.{A}⊤{X}st% {H}st{X}⊤st{A}={I}k×k, (16)

where , are the Laplacian matrix, , , and . Similarly, , and , where , , and could be computed as follows

 ({V}ij∗s/t)lh=⎧⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎩1nis/tnis/t,({x}l,{x}h∈{X}is/t)1njs/tnjs/t,({x}l,{x}h∈% {X}js/t)0,(otherwise).\par (17)

Similar to and , and could be constructed accordingly. Different from the first strategy, we aim to further reformulate the inter-class distances of the source and target domains using the similar weights revealed in the MMD so that the optimal parameter regions imposed on the inter-class distances are also known beforehand. Therefore, a balanced factor of could be employed to adaptively leverage the importance of feature transferability and its discriminability. Likewise, Eq. 15 could be solved in the same manner as Eq. 14.

Moreover, from Lemma 3, we consider those two discriminative distances alone in the proposed two strategies since their relationship is as one falls, another rises when the whole data variance is fixed, thus the redundant parameter could be further omitted.

### Iii-C Classification Scheme

We utilize the whole common features to construct a neighborhood similarity graph with the -neareast neighbors similar to [CPCAN, GAKT]. Specifically, the weight mesures the similarity degree between and , and the closer, the bigger. We now employ a Graph-based Label Propogation method [GAKT] (GLP) to propagate the source labels to the target domain data as follows

 min{F}t∑nsti=1∑nstj=1({W})ij||{f}i−{f}j||22=min{F}ttr({F}t{L}tt{F}% ⊤t)+2tr({F}t{L}ts{F}⊤s), (18)

where , are the one-hot labels, and , if . Besides, we define the graph Laplacian matrix , where B denotes a diagonal matrix with the diagonal entries as the column sums of W, and .

We first obtain the partial derivative of Eq. 17 w.r.t., , and set it to 0. Then the solution can be derived as follows

 {F}t={F}s({L}ts)⊤({L}tt)−1, (19)

Once the one-hot label matrix is obtained, the target label of any given data instance is computed as .

Since the statistics about the target domain are computed by their pseudo labels during the current iteration, we have to optimize A and iteratively. Remarkably, our approach could achieve desirable performances within only a few iterations (i.e., ).