Maximum Mean Discrepancy (MMD) is a non-parametric statistical test and distance metric that measures the difference between two probability distributions by comparing their mean embeddings in a reproducing kernel Hilbert space $(\mathrm{RKHS}). In$ domain adaptation, MMD serves as a differentiable loss function that quantifies how different the source and target feature distributions are, enabling direct minimization of domain discrepancy without adversarial training.
Why MMD Matters in AI/ML:
MMD provides a statistically principled, non-adversarial measure of distribution distance that is differentiable, easy to compute, has well-understood theoretical properties, and directly plugs into neural network training as a regularization loss—making it the most mathematically grounded approach to domain alignment.
• RKHS embedding — Each distribution $P$ is represented by its mean embedding $\mu_P = E_{x\sim P}[\phi (x)] \in a \mathrm{RKHS}$ defined by kernel $k; \mathrm{MMD}^2(P,Q) = \lVert{\mu_P - \mu _Q}\rVert^2_H = E[k(x,x')] - 2E[k(x,y)] + E[k(y,y')]$, where $x,x' \sim P$ and $y,y' \sim Q$
• Kernel choice — The Gaussian RBF kernel $k(x,y) = \exp(-\lVert{x-y}\rVert^{2/2}\sigma ^2)$ is most common; $\text{multi-kernel} \mathrm{MMD}$ uses a mixture of Gaussians with different bandwidths for robustness; the kernel must be characteristic (Gaussian, Laplacian) to guarantee that $\mathrm{MMD}=0$ iff $P=Q$
• Unbiased estimator — Given source samples {x_i}ᵢ₌₁ᴺ and target samples {y_j}ⱼ₌₁ᴹ, the unbiased empirical $\mathrm{MMD}^2 = 1/(N(N-1))\Sigma_i\ne ⱼk(x_{i,x}ⱼ) - 2/(\mathrm{NM})\Sigma_i\Sigma ⱼk(x_{i,y}ⱼ) + 1/(M(M-1))\Sigma_i\ne ⱼk(y_{i,y}ⱼ)$ is computed from mini-batches during training
• Multi-layer MMD (DAN) — Deep Adaptation Network $(\mathrm{DAN})$ minimizes MMD across multiple hidden layers simultaneously: $L = L_{\text{task}} + \lambda \Sigma_l \mathrm{MMD}^2(S_l, T_l)$, aligning representations at multiple abstraction levels for more robust adaptation
• Conditional MMD — $\text{Class-conditional} \mathrm{MMD}$ aligns source and target distributions per class: $\Sigma_k \mathrm{MMD}^2(P_S(f|y=k), P_T(f|y=k))$, preventing class confusion that can occur with marginal MMD alignment alone
| Variant | Kernel | Alignment Level | Complexity | Key Property |
|---|---|---|---|---|
| $\text{Single-kernel} \mathrm{MMD}$ | Gaussian RBF | Single layer | $O(N^2)$ | Simple, well-understood |
| $\text{Multi-kernel} \mathrm{MMD} (\text{MK-MMD})$ | Mixture of RBFs | Single layer | $O(N^2)$ | Bandwidth-robust |
| $\mathrm{DAN} (\text{multi-layer})$ | Multi-kernel | Multiple layers | $O(L\cdot N^2)$ | Deep alignment |
| JAN (joint) | Multi-kernel | Joint distributions | $O(N^2)$ | Class-aware |
| Linear MMD | Linear kernel | Single layer | $O(N\cdot d)$ | Fast, less expressive |
| Conditional MMD | Any | Per-class | $O(K\cdot N^2)$ | Prevents class confusion |
Maximum Mean Discrepancy is the mathematically rigorous foundation for non-adversarial domain adaptation, providing a differentiable distribution distance in kernel space that enables direct minimization of domain discrepancy, with well-understood statistical properties, unbiased estimation from finite samples, and seamless integration as a regularization loss in deep neural network training.