LLGA · Course notes

Machine learning with Optimal Transport and Algorithmic Fairness

APM_52188_EP · Year 1 · Period 2

Contents

Introduction and overview

Module Machine learning with Optimal Transport and Algorithmic Fairness
Code APM_52188_EP
Team and workload Heads (“Responsables” on the 2026–2027 sheet): Rémi Flamary (École Polytechnique, CMAP; co-creator of the POT library) and Solenne Gaucher (École Polytechnique), Solenne Gaucher being the head of the 2026–2027 occurrence · instructional engineering team: Charlotte Laclau · 36 h in person (“36 heures en présentiel”); the same sheet’s breakdown line reads “(CTD) Module Cours-TD: 40.3”, which contradicts the 36 h — we keep the 36 h headline figure, also shown in the volume column of the track page · 4.5 ECTS · limited enrollment (maximum 24 on the course unit, 30 on the occurrence) · from Monge and Kantorovich to Sinkhorn, with the ML applications: Wasserstein losses, domain adaptation, graphs (Gromov-Wasserstein, FGW, COOT) and fairness. Extends the “signal for ML” chapter of the Signal Processing module (M1P1, same instructor).
Period Year 1, semester 2 (listed in LLGA 1 – S2) · period 2 (X-3A-P2, from 04/01/2027 to 19/03/2027) · X3A session “Machine learning with Optimal Transport and Algorithmic Fairness”; languages: French and English
Assessment Group project: reading, understanding and numerical implementation of scientific papers, followed by an oral presentation of the results (100% of the grade); official modalities: “oral presentation by the group of the final project” (displayed for the engineering degree, the exchange programmes and the AI & Advanced Visual Computing MScT; the LLGA section of the sheet is empty); numerical grade out of 20; resit allowed (maximum of the two grades); the course unit is earned if the final grade ≥ 10
Status in the program P2 option — Choose 1Not preselected by a route one of the Period 2 “Choose 1” electives of the official LLGA 1 – S2 2026–2027 list; no route of the home page preselects it

Audience: an engineer who has already compared two histograms (KL, MMD) and seen domain adaptation “work on a toy, die in prod”.

Empirical first: EMD too slow on 5k points; Sinkhorn diverging when \varepsilon is too small; FID dropping while the eye sees no gain — then we name Monge, Wasserstein, duality.

Theory (Monge, Kantorovich, duality) + practice (Sinkhorn / POT), then losses, domain adaptation, Gromov-Wasserstein and fairness. Flamary & Gaucher (CMAP); Flamary co-created POT.

What you will be able to do

Official objectives and syllabus (2026-2027 catalog)

The official course description (X3A session “Machine learning with Optimal Transport and Algorithmic Fairness”) sets a clear objective: “to discover some of the major current issues of machine learning”, around two stated themes — optimal transport for statistical learning and algorithmic fairness in statistical learning.

The teaching is organized into “fundamental lectures providing the necessary foundations to discover the various topics”, complemented by a group project of reading, understanding and numerical implementation of scientific papers, followed by an oral presentation of the results — which carries 100% of the grade.

Official volume: “36 heures en présentiel” (36 h in person), while the breakdown line of the same sheet gives “(CTD) Module Cours-TD: 40.3” — an internal inconsistency of the sheet that we report without resolving it; these notes are calibrated on the 36 h headline figure.

Languages: French and English; limited enrollment (maximum 24 on the course unit, 30 on the 2026–2027 occurrence). Detailed week-by-week syllabus: not displayed on the sheet. Official prerequisites: the sheet states, for students of the engineering degree only, that it is “strongly recommended to have taken the MAP553 course”; it displays no prerequisite for the LLGA track.

Official topic of the description Course section
Fundamental lectures: foundations of optimal transport (Monge, Kantorovich, duality, computation) Chapters 1 (the transport problem), 2 (duality and Wasserstein) and 3 (entropic regularization, Sinkhorn)
Optimal transport for statistical learning Chapter 4 (OT and machine learning: Wasserstein losses, domain adaptation, barycenters) and chapter 5 (Gromov-Wasserstein for relational data)
Algorithmic fairness in statistical learning Chapter 6 (fairness through transport: correcting distributional disparities between groups)
Project of reading and implementation of scientific papers (100% of the grade) To be worked on throughout chapters 4 to 7, with the POT paper and the references as entry points

Both official themes are fully covered, the description not publishing any more detailed syllabus. Our extensions, beyond the official description: the refresher chapter 0 (convexity and LP duality), chapter 5 (Gromov-Wasserstein and its FGW/COOT variants) and chapter 7 (the research work of the team, foremost among which those of Rémi Flamary around POT).

Where this course fits in the program

Module of period 2 of M1 (36 h, 4.5 ECTS): one of the six electives of the Period 2 “Choose 1” group of the LLGA 1 – S2 list, and no route of the home page preselects it. Official prerequisites: none displayed for the LLGA track; for engineering-degree students the sheet strongly recommends having taken MAP553. It is the course that gives the master’s program its common language for talking about distances between distributions.

Course outline

Session plan

36 h in class = 12 sessions of 3 h. The volume is the headline figure of the SynapseS 2026–2027 sheet (“36 heures en présentiel”); the same sheet’s breakdown line gives 40.3 h of lecture-exercise module, an inconsistency we report but do not follow, because the LLGA curriculum page of the programme wiki (msct.dix.polytechnique.fr/llga, last modified on 9 September 2026 by the programme director) states that “all subsequent M1 courses are 36h and will credit 4.5 ECTS”.

The sheet publishes no session-by-session programme, so the split below is our proposal for covering these notes in that time. Level 1 = foundations (reviews, definitions, first worked examples), 2 = core theory and algorithms, 3 = advanced extensions and recent research; the level never goes down from one session to the next.

Session Hours Level Content Practice
1 3 h 1 ch. 0 Review: LP duality, pushforward measures, strict convexity, KL divergence lab: first steps with POT (ot.emd on two small clouds)
2 3 h 1 ch. 1 Monge’s problem, Kantorovich’s relaxation, existence and extreme plans Ex. 8
3 3 h 2 ch. 2 Kantorovich duality, c-transforms, Brenier’s theorem (2.1–2.3) Ex. 1
4 3 h 2 ch. 2 Wasserstein distances, 1D quantiles, Gaussians and the Bures metric, barycenters (2.4–2.8) Ex. 3, 4
5 3 h 2 ch. 3 Entropic OT, the Sinkhorn algorithm, convergence, gradients (3.1–3.4) Ex. 2
6 3 h 2 ch. 3 Sinkhorn divergences, ε-scaling, sliced transport (3.5) lab: log-domain Sinkhorn in NumPy checked against POT; exact OT vs Sinkhorn vs sliced (code of ch. 3)
7 3 h 2 ch. 4 Domain adaptation (OTDA), Kantorovich-Rubinstein duality and WGAN (4.1–4.2) Ex. 7
8 3 h 2 ch. 4 Barycenters, Word Mover’s Distance, Gaussian losses, statistical estimation (4.3–4.5) Ex. 5
9 3 h 3 ch. 5 Gromov-Wasserstein: definition, isometric invariance, algorithms (5.1–5.2) Ex. 6
10 3 h 3 ch. 5 Fused GW, COOT, graph alignment (5.3–5.5) Ex. 10, 12
11 3 h 3 ch. 6 Fairness criteria, repair by Wasserstein barycenter (6.1–6.2) Ex. 9, guided lab of ch. 6
12 3 h 3 ch. 6 Bicausal OT, counterfactuals, equalized-odds post-processing, limits (6.3) Ex. 11

Self-study, outside the 36 h (about 3 h in total): ch. 7 Research at CMAP — POT, OT for domain adaptation, FGW, COOT, sliced theory, biosignals (≈ 3 h; it also gives entry points for the group project).

How to study this module

independent note Cross-cutting language: FID (Multimodal GenAI), graph alignment (Gromov-Wasserstein → M2), fairness. A differentiator in data science / research — if you know when Sinkhorn is enough and when exact EMD is a trap.

0. Review: convexity and LP duality

Every transport problem of this course is a convex optimization problem, and most of its proofs are duality arguments. This review states the four tools used throughout: linear-programming duality, the pushforward of a measure, uniqueness under strict convexity, and the positivity of the Kullback-Leibler divergence.

L3 background used

  • Convex sets and functions: for convex f, any stationary point is a global minimum; for strictly convex f, the minimizer (if it exists) is unique — entropic OT in ch. 3 takes advantage of this;
  • Linear programming: minimize c^\top x subject to Ax = b, x \geq 0;
  • Measure theory: probability, expectation \mathbb{E}_\mu[f] = \int f\,d\mu, pushforward measure;
  • Entropy: Kullback-Leibler divergence, Jensen’s inequality — the engine of entropic regularization.

Theorem 0.1 — LP duality: weak (proved), strong, complementarity (proved) Primal (left) and dual (right): \min\{c^\top x \ : \ Ax = b,\ x \geq 0\}, \qquad \max\{b^\top y \ : \ A^\top y \leq c\}.

  • Weak duality: for any pair of feasible points, c^\top x \geq b^\top y.
  • Strong duality: if the primal is feasible and bounded, the dual attains its optimum and the values coincide.
  • Complementarity: at the optima x^\star, y^\star: x^\star_j > 0 \Rightarrow (A^\top y^\star)_j = c_j.

Proof. Weak duality. Summing the dual constraints weighted by x_j \geq 0, c^\top x \geq (A^\top y)^\top x = y^\top (Ax) = y^\top b .

Strong duality. Admitted (polyhedron separation).

Complementarity. At the optimum, 0 = c^\top x^\star - b^\top y^\star = (c - A^\top y^\star)^\top x^\star = \sum_j \underbrace{(c - A^\top y^\star)_j}_{\geq 0}\, \underbrace{x^\star_j}_{\geq 0} . Every term is zero, hence the implication.∎

Proposition 0.2 — Pushforward measure and transfer lemma (proved) For measurable T : \mathbb{R}^d \to \mathbb{R}^d, the pushforward measure gives to each set A “the mass of what is sent into A”: T_\#\mu(A) = \mu\big(T^{-1}(A)\big). Transfer lemma: for every positive or bounded measurable f, \int f\,d(T_\#\mu) = \int f \circ T\,d\mu.

Proof. For f = \mathbf{1}_A this is the definition. Both sides are linear in f: the equality passes to positive simple functions, then to all positive functions by monotone convergence, then to bounded ones by taking differences. This “moving the change of variables into the measure” is used on every page of this course.∎

Proposition 0.3 — Strict convexity: uniqueness (proved) If a strictly convex F attains its minimum at x^\star, then x^\star is the unique minimizer.

Proof. If x \neq x^\star were also a minimizer, the midpoint m = \tfrac12(x + x^\star) would give F(m) < \tfrac12F(x) + \tfrac12F(x^\star) = \min F — a contradiction.∎

Proposition 0.4 — KL ≥ 0 (proved by Gibbs/Jensen), with equality case For discrete distributions p, q (or densities): \mathrm{KL}(p \| q) = \sum_i p_i \log\frac{p_i}{q_i} \ \geq\ 0, \qquad \text{equality} \iff p = q.

Proof. By definition, \mathrm{KL}(p\|q) = -\sum_i p_i \log\frac{q_i}{p_i} . The \log function is concave: by Jensen weighted by p (Gibbs’ inequality), \sum_i p_i \log\frac{q_i}{p_i} \leq \log\sum_i p_i\frac{q_i}{p_i} = \log\sum_i q_i = 0 . Equality in Jensen (strict concavity of \log) requires q_i/p_i constant on \{p_i > 0\}, and the constant equals 1 because both are probabilities.∎

1. The transport problem

Concrete scene: two 1D histograms of 20 bins each, a source and a target. A greedy coupling that sends each bin to the nearest bin with remaining capacity costs 12.4; the linear-programming solver of POT finds 7.1.

And when one source bin must feed two target bins, no deterministic map can do the job, whereas a transport plan that splits the mass exists. This chapter states the two formulations of the problem, Monge’s and Kantorovich’s, before any algorithm.

What breaks Demanding a Monge map when mass must split; dropping marginal constraints (it is no longer transport); over-regularizing (plan too blurry, metric useless). All three sabotage domain adaptation as much as a 3-point toy.

Definition 1.1 — Monge’s problem (1781) Given two probability measures \mu, \nu on \mathbb{R}^d and a cost c(x, y) (typically \|x - y\|^2), find a transport map T : \mathbb{R}^d \to \mathbb{R}^d that moves the first measure onto the second while minimizing the total cost.

In other words, T_\#\mu = \nu and T solves \min_T \ \int c\big(x, T(x)\big)\, d\mu(x).

Historical note: cut and fill (Monge, 1781); the problem is non-convex in T, and a solution may not exist.

Example 1.2 — Non-existence of a Monge map: 1 to 2 (detailed) Take \mu = \delta_0 (unit mass at the origin) and \nu = \tfrac12\delta_{-1} + \tfrac12\delta_{+1} (two half-masses).

A map T sends 0 to a single point T(0), so the pushforward measure is atomic at a single point: T_\#\delta_0 = \delta_{T(0)} . It is impossible to obtain \nu, which has two.

The mass must be “split”: the random pair (X, Y) with X = 0 and Y = \pm1 by a coin flip realizes the transport, but a map does not. This is exactly what Kantorovich formalizes: allowing splitting.

Kantorovich’s formulation (1942) — the pivot of the course Relax “each source goes to a single destination” into a transport plan \gamma — the law of a pair (X, Y) with marginals \mu, \nu:

Key result — Kantorovich’s problem W_c(\mu, \nu) \;=\; \min_{\gamma \in \Pi(\mu, \nu)} \ \int c(x, y)\, d\gamma(x, y), \Pi(\mu,\nu) = \big\{\gamma \geq 0 \ :\ \gamma(\cdot \times \mathbb{R}^d) = \mu,\ \gamma(\mathbb{R}^d \times \cdot) = \nu\big\}.

Discrete case (\mu = \sum_i a_i \delta_{x_i}, \nu = \sum_j b_j \delta_{y_j}, \mathbf{1}^\top a = \mathbf{1}^\top b = 1): a linear program on the transport matrix \Gamma, \min_{\Gamma \in \mathbb{R}_+^{n \times m}} \ \langle C, \Gamma\rangle \quad \text{s.t.} \quad \Gamma \mathbf{1} = a,\ \Gamma^\top \mathbf{1} = b, where C_{ij} = c(x_i, y_j).

Theorem 1.3 — Existence (by compactness) and structure of solutions

  • \Pi(\mu,\nu) is a non-empty convex compact (discrete: a bounded polytope defined by closed constraints; general: compactness in the sense of narrow convergence, by tightness). The cost being continuous, the minimum is attained (Weierstrass).

  • Extreme solutions: there exists an optimal solution that is a vertex of the polytope, and such a vertex has at most n + m - 1 non-zero coefficients.

    Proof (sketch): the n + m equality constraints are dependent (the sum of the row constraints equals that of the columns: rank \leq n + m - 1). A vertex of a polyhedron in dimension nm is defined by nm independent active constraints, of which at least nm - (n+m-1) are bounds \Gamma_{ij} = 0.

Why the relaxation is “lossless” Example 1.2 shows it is sometimes necessary (mass splitting). It is also sufficient in the sense that, as soon as \mu has a density with respect to Lebesgue (the case of all data clouds), the optimal Kantorovich plan is induced by a map T: \gamma^\star = (\mathrm{Id}, T)_\#\mu — this is Brenier’s theorem, proved in ch. 2.

In the discrete case, on the other hand (n sources, m targets), the vertices with \leq n+m-1 non-zeros are “almost” deterministic — how much splitting remains is the subject of exercise 8. Logistic interpretation: mines and coke ovens (Hitchcock, Kantorovich) — nowadays, comparing two data distributions.

2. Duality and the Wasserstein distance

Computing a transport plan is a minimization; its dual, a maximization over pairs of potentials, gives certificates of optimality, the structure of optimal plans (Brenier’s theorem) and closed formulas in dimension 1 and for Gaussians. This chapter derives the duality, then defines the Wasserstein distances and proves that they are distances.

Theorem 2.1 — Kantorovich duality (complete proof in the discrete case)

Key result — Kantorovich duality W_c(\mu, \nu) \;=\; \max_{(f, g) \in \Phi_c} \ \int f\, d\mu + \int g\, d\nu, \qquad \Phi_c = \big\{(f, g) \ :\ f(x) + g(y) \leq c(x, y)\ \forall (x,y)\big\}.

In the discrete case: \max_{f,g} \langle a, f\rangle + \langle b, g\rangle \quad \text{s.t.} \quad f_i + g_j \leq C_{ij}.

Proof. Step 1 (the discrete problem is an LP). The constraints \Gamma \geq 0, \Gamma\mathbf{1} = a, \Gamma^\top\mathbf{1} = b are affine; the primal is feasible (e.g. \Gamma = ab^\top) and bounded (\langle C,\Gamma\rangle \geq 0).

Step 2 (the dual). Write the dual of th. 0.1 by associating a multiplier f_i with the row constraint \sum_j \Gamma_{ij} = a_i and g_j with the column constraint \sum_i \Gamma_{ij} = b_j. The dual of \min_{\Gamma \geq 0}\{\langle C, \Gamma\rangle\} under these equalities is \max_{f,g}\{\langle a, f\rangle + \langle b, g\rangle\ :\ f_i + g_j \leq C_{ij}\ \forall i,j\} . Each variable \Gamma_{ij} \geq 0 yields one dual inequality constraint.

Step 3 (strong duality). The primal is feasible and bounded ⇒ strong duality (th. 0.1): the optima exist and coincide.

Step 4 (reading the complementarity). At the optimal triple (\Gamma^\star, f^\star, g^\star): \Gamma^\star_{ij} > 0 \ \Longrightarrow\ f^\star_i + g^\star_j = C_{ij}, i.e. mass travels only on saturated routes — it is this condition that ties the plan to the potentials (corollary 2.3).∎

Definition 2.2 — c-transform and Kantorovich potentials For a potential f, the c-transform is f^c(y) = \inf_x\, \big[c(x,y) - f(x)\big] . A potential f is c-concave if f = (f^c)^{\bar c} (bitransform).

At the optima of theorem 2.1, one may always assume g^\star = (f^\star)^c and f^\star = (g^\star)^{\bar c}: replacing g by f^c \geq g can only increase the dual objective while remaining admissible. The optimal pair then reduces to one c-concave potential f^\star (and its dual).

Corollary 2.3 — Brenier’s theorem (precise statement) and the quadratic case If \mu \ll \mathrm{Leb} and c(x,y) = \tfrac12\|x-y\|^2:

  • the optimal plan is unique and induced by a map: \gamma^\star = (\mathrm{Id}, T)_\#\mu;
  • T = \nabla\varphi, the gradient of a convex function \varphi; conversely, every admissible map of this form is optimal (cyclical monotonicity);
  • link with the dual: \varphi(x) = \tfrac12\|x\|^2 - f^\star(x), i.e. \ T(x) = x - \nabla f^\star(x) on the transported support.

Reading: optimal transport is a gradient — it deforms space continuously, without tearing; in 1D, T = F_\nu^{-1} \circ F_\mu (monotone rearrangement, prop. 2.6). For two Gaussians, T is affine (th. 2.7).

In ML: T = the “mapping” we learn to adapt a domain (ch. 4) — cf. the Deep Learning module for the networks that approximate it.

Definition 2.4 — Wasserstein distance of order p With c = d^p on a metric space (E, d): W_p(\mu, \nu) = \Big( \min_{\gamma \in \Pi(\mu,\nu)} \int d(x,y)^p\, d\gamma \Big)^{1/p} on the set of probabilities with finite moment of order p.

Theorem 2.5 — W_p is a distance (proved: separation and triangle inequality by gluing)

Proof. Symmetry: if \gamma is admissible for (\mu,\nu), its transpose is admissible for (\nu,\mu), at the same cost.

Separation: W_p(\mu,\nu) = 0 ⇒ there exists an optimal \gamma^\star with zero cost, supported on \{x = y\} (since d^p > 0 off the diagonal); its marginals are then equal: \mu = \nu.

Triangle inequality (discrete): let \gamma^{12} be optimal between \mu^1, \mu^2 and \gamma^{23} optimal between \mu^2, \mu^3.

Gluing. Set \pi_{i\ell} \;=\; \sum_j\ \frac{\gamma^{12}_{ij}\,\gamma^{23}_{j\ell}}{\mu^2_j}, the law of the pair (X, Z) where we first draw Y \sim \mu^2, then X \sim \gamma^{12}(\cdot\mid Y) and Z \sim \gamma^{23}(Y, \cdot).

Marginals: \sum_\ell \pi_{i\ell} = \sum_j \gamma^{12}_{ij}\frac{\sum_\ell\gamma^{23}_{j\ell}}{\mu^2_j} = \sum_j \gamma^{12}_{ij} = \mu^1_i , and likewise \sum_i \pi_{i\ell} = \mu^3_\ell. So \pi is admissible for (\mu^1, \mu^3).

We conclude by conditional Minkowski: the inequality \big(\mathbb{E}[d(X,Z)^p]\big)^{1/p} \leq \big(\mathbb{E}[d(X,Y)^p]\big)^{1/p} + \big(\mathbb{E}[d(Y,Z)^p]\big)^{1/p} is proved by applying Minkowski conditionally on Y, then integrating. Hence W_p(\mu^1,\mu^3) \leq \Big(\sum_{i\ell} \pi_{i\ell}\, d(x_i, z_\ell)^p\Big)^{1/p} \leq W_p(\mu^1,\mu^2) + W_p(\mu^2,\mu^3). ∎

Narrow topology: what W_p “sees” On probabilities with finite moment of order p, W_p(\mu_k, \mu) \to 0 ⇔ narrow convergence (against every bounded continuous test function) + convergence of the moments of order p.

Comparison with the usual divergences: \mathrm{KL}(\mu\|\nu) = \infty as soon as the supports move apart, whereas W_p stays finite and continuous — two clouds shifted by \varepsilon are at distance \varepsilon (not “infinity”).

It is this “flat” geometry (no support jump) that makes W usable in ML: informative gradients, and an interpolation in the physical sense of displacement, \mu_t = ((1-t)\,\mathrm{Id} + tT)_\#\mu .

Proposition 2.6 — W_p in dimension 1: coupling of quantiles (proved in the discrete case) W_p(\mu, \nu) = \Big(\int_0^1 \big|F_\mu^{-1}(u) - F_\nu^{-1}(u)\big|^p\, du\Big)^{1/p}, where F^{-1}(u) = \inf\{x \ : \ F(x) \geq u\} is the quantile. The optimal plan matches the u-quantile of \mu with the u-quantile of \nu; computable by sorting in \mathcal{O}(n\log n).

Proof. Discrete case, n equal masses.

Step 1 (uncrossing). Consider a plan putting mass on (x_1, y_2) and (x_2, y_1) with x_1 \leq x_2 and y_1 \leq y_2 (“crossed routes”); move this mass to (x_1, y_1) and (x_2, y_2). The marginals are preserved and the cost does not increase, since |x_1 - y_2|^p + |x_2 - y_1|^p \ \geq\ |x_1 - y_1|^p + |x_2 - y_2|^p. Indeed, set a = x_1 - y_1, \qquad b = x_2 - y_2, \qquad d = y_2 - y_1 \geq 0 . The right-hand side is \varphi(a) + \varphi(b) and the left one \varphi(a - d) + \varphi(b + d), with \varphi(t) = |t|^p convex for p \geq 1.

The two numbers a - d and b + d have the same sum as a and b, and they enclose them.

Indeed, a - d \leq a \leq b + d because x_1 \leq x_2, and a - d \leq b because b - (a - d) = x_2 - x_1 \geq 0.

Hence a = \lambda (a - d) + (1-\lambda)(b + d) for some \lambda \in [0, 1], and then b = (1-\lambda)(a - d) + \lambda (b + d). By convexity we get a convex rearrangement inequality: \varphi(a) + \varphi(b) \leq \varphi(a - d) + \varphi(b + d) .

Step 2. By iterating the uncrossing, an optimal plan exists that crosses no pair: it is the monotone coupling x_i \leftrightarrow y_{\sigma(i)} with increasing \sigma — the quantile matching.

Step 3 (general case, statement). For arbitrary laws, the plan (F_\mu^{-1}(U), F_\nu^{-1}(U)) with U \sim \mathcal{U}[0,1] has the right marginals and is monotone, hence optimal (1D Brenier).∎

Theorem 2.7 — W_2 between Gaussians: the Bures metric (proved) W_2^2\big(\mathcal{N}(m_1,\Sigma_1), \mathcal{N}(m_2,\Sigma_2)\big) = \|m_1 - m_2\|^2 + \mathrm{tr}\Big(\Sigma_1 + \Sigma_2 - 2\big(\Sigma_1^{1/2}\,\Sigma_2\,\Sigma_1^{1/2}\big)^{1/2}\Big).

Proof. Step 1 (centering). For every coupling (X, Y), \mathbb{E}\|X - Y\|^2 = \|m_1 - m_2\|^2 + \mathbb{E}\|\tilde X - \tilde Y\|^2 with \tilde X, \tilde Y centered (expand the square, the cross terms cancel). Means and covariances transport separately, and the plan (m_1 + \tilde X,\ m_2 + \tilde Y) attains the bound. Assume m_1 = m_2 = 0.

Step 2 (an affine candidate). Set M = \Sigma_1^{1/2}\Sigma_2\Sigma_1^{1/2} and A \;=\; \Sigma_1^{-1/2}\, M^{1/2}\, \Sigma_1^{-1/2}. A is symmetric positive definite (a symmetric conjugate of M^{1/2}). The coupling (X, Y = AX) with X \sim \mathcal{N}(0,\Sigma_1) is admissible: Y is a centered Gaussian with covariance A\Sigma_1A^\top = \Sigma_1^{-1/2}M\Sigma_1^{-1/2} = \Sigma_2 .

Step 3 (cost of the candidate). We have \mathbb{E}\|X - AX\|^2 = \mathrm{tr}\big((I - A)\Sigma_1(I - A)^\top\big) = \mathrm{tr}(\Sigma_1) - 2\,\mathrm{tr}(A\Sigma_1) + \mathrm{tr}(\Sigma_2) . Now, by cyclicity, \mathrm{tr}(A\Sigma_1) = \mathrm{tr}\big(\Sigma_1^{-1/2}M^{1/2}\Sigma_1^{1/2}\big) = \mathrm{tr}\big(M^{1/2}\big), so the cost is \mathrm{tr}(\Sigma_1 + \Sigma_2) - 2\,\mathrm{tr}(M^{1/2}), the announced formula.

Step 4 (optimality via Brenier). T(x) = Ax = \nabla\big(\tfrac12 x^\top A x\big) is the gradient of a convex function (A symmetric ≥ 0) that sends \mu onto \nu; by the converse of corollary 2.3 (sufficiency of cyclical monotonicity), this coupling is optimal. In 1D, A = \sigma_2/\sigma_1: cost (\sigma_1 - \sigma_2)^2, consistent with prop. 2.6.∎

Corollary 2.8 — Wasserstein barycenter of 1D Gaussians (proved) The barycenter of the laws \mu_k = \mathcal{N}(m_k, \sigma_k^2) with weights \sum w_k = 1, \arg\min_\nu \sum_k w_k\, W_2^2(\nu, \mu_k), is the Gaussian \mathcal{N}\Big(\sum_k w_k m_k,\ \ \big(\sum_k w_k \sigma_k\big)^{2}\Big).

Proof. By prop. 2.6, minimizing over \nu amounts to minimizing \sum_k w_k \int_0^1 |F_\nu^{-1}(u) - F_k^{-1}(u)|^2du in the quantile function F_\nu^{-1}.

Pointwise in u, the optimization is a simple regression: the optimum (zero derivative — strictly convex function) is F_\nu^{-1}(u) = \sum_k w_k F_k^{-1}(u) . Now F_k^{-1}(u) = m_k + \sigma_k\,\Phi^{-1}(u), so F_\nu^{-1}(u) = \underbrace{\sum_k w_k m_k}_{m} + \underbrace{\sum_k w_k\sigma_k}_{\sigma}\,\Phi^{-1}(u), which is exactly the quantile of \mathcal{N}(m, \sigma^2).

Note that the “barycenter variance” \sigma^2 = (\sum w_k\sigma_k)^2 is the square of the mean of the standard deviations — not the mean of the variances.∎

Bridge with the Signal Processing module The Bures formula of theorem 2.7 is exactly the Fréchet distance (FID) used to evaluate image generators and audio models: cf. the Signal Processing module M1P1, chapter 8, which prepares this reading — and whose “spectral loss” is a Gaussian W_2 loss on spectrograms. The same mathematical object runs through both modules.

3. Entropic regularization: Sinkhorn

Exact transport is a linear program whose cost grows like n^3 \log n and whose solution is not differentiable in the data. Adding a small entropy term makes the problem strictly convex, solvable by a few matrix-vector products (the Sinkhorn algorithm) and smooth — the version of OT that machine learning actually uses.

Definition 3.1 — Entropic OT (Cuturi, 2013) W_\varepsilon(a, b) \;=\; \min_{\Gamma \in U(a, b)}\ \langle C, \Gamma\rangle + \varepsilon\, \mathrm{KL}\big(\Gamma\,\big\|\, a b^\top\big), where U(a,b) is the polytope of marginals. The problem is strictly convex (the entropy is, prop. 0.3) ⇒ unique solution, which converges to a solution of the LP as \varepsilon \to 0.

Theorem 3.2 — Form of the minimizer and the Sinkhorn algorithm (proved) The unique solution reads \Gamma^\varepsilon = \mathrm{diag}(u)\, K\, \mathrm{diag}(v), \qquad K = e^{-C/\varepsilon}, and the scaling vectors are obtained by the alternating iterations

Key result — Sinkhorn iterations u \leftarrow a\,/\,(K v), \qquad v \leftarrow b\,/\,(K^\top u).

Proof. Form (optimality conditions). Lagrangian with multipliers \lambda_i (rows) and \mu_j (columns): \mathcal{L} = \langle C,\Gamma\rangle + \varepsilon\sum_{ij}\Gamma_{ij} \log\frac{\Gamma_{ij}}{a_ib_j} - \lambda^\top(\Gamma\mathbf{1} - a) - \mu^\top(\Gamma^\top\mathbf{1} - b) . At \Gamma^\star, for each (i,j): C_{ij} + \varepsilon\Big(\log\frac{\Gamma_{ij}}{a_ib_j} + 1\Big) - \lambda_i - \mu_j - \varepsilon = 0 \ \Rightarrow\ \Gamma^\star_{ij} = a_i b_j\, e^{(\lambda_i + \mu_j - C_{ij})/\varepsilon} = u_i K_{ij} v_j, with u_i = a_i\, e^{\lambda_i/\varepsilon} and v_j = b_j\, e^{\mu_j/\varepsilon} (the weights a_i, b_j are absorbed into the scaling vectors).

Iterations (Bregman projections). The constraints \Gamma\mathbf{1} = a and \Gamma^\top\mathbf{1} = b are not separated: we alternately project K onto each constraint in the sense of the Bregman divergence \mathrm{KL}(\cdot\|\cdot).

Consider the projection of \tilde\Gamma = \mathrm{diag}(u)K\, \mathrm{diag}(v) onto \{\Gamma\mathbf{1} = a\}, i.e. the minimization of \mathrm{KL}(\Gamma\|\tilde\Gamma) under the row constraint. Setting to zero the derivative \partial/\partial\Gamma_{ij}\big[\sum\Gamma_{ij}\log(\Gamma_{ij}/\tilde\Gamma_{ij}) - \rho_i(\sum_j\Gamma_{ij} - a_i)\big] = \log(\Gamma_{ij}/\tilde\Gamma_{ij}) + 1 - \rho_i gives \Gamma_{ij} = e^{\rho_i - 1}\tilde\Gamma_{ij}: a rescaling of the rows, exactly u \leftarrow a/(Kv); likewise for the columns.

Each iteration divides the violation of the other constraint; the sequence converges to the point with the prescribed marginals — the unique point of the polytope of the form \mathrm{diag}(u)K\,\mathrm{diag}(v).∎

Theorem 3.3 — Geometric convergence (Franklin & Lorenz, 1989) For K > 0 (finite costs, \varepsilon > 0), Sinkhorn converges at a geometric rate. The scaling vectors converge in Hilbert’s projective metric, which each half-iteration contracts by the factor \tanh(\Delta/4), where \Delta = \max_{i,j,k,l} \log\frac{K_{ik}K_{jl}}{K_{jk}K_{il}} measures the spread of the coefficients of K.

Since \Delta \leq 2\max_{ij} C_{ij}/\varepsilon, convergence is all the faster as \varepsilon is large. In practice: 20 to 200 iterations for 3-digit accuracy (at moderate \varepsilon).

Theorem 3.4 — Gradient of the regularized loss (sketch: envelope/implicit differentiation) \nabla_a\, W_\varepsilon(a, b) = \lambda^\star - \varepsilon\mathbf{1} \quad (\lambda^\star:\ \text{optimal dual potential}).

Proof. The Lagrangian of the problem (that of th. 3.2) has a saddle point at (\Gamma^\star, \lambda^\star, \mu^\star), at which W_\varepsilon(a,b) = \mathcal{L}(\Gamma^\star,\lambda^\star,\mu^\star).

Differentiate with respect to a. Since the Lagrangian is stationary in \Gamma and in the multipliers at the saddle point, their variations contribute nothing, and only the explicit dependence on a remains — the term \lambda^\top a, and the term -\varepsilon\sum_{ij}\Gamma_{ij}\log a_i of the entropy, whose derivative is -\varepsilon\sum_j \Gamma^\star_{ij}/a_i = -\varepsilon . Hence \partial W_\varepsilon/\partial a_i = \lambda^\star_i - \varepsilon . The gradient is the optimal dual potential, up to an additive constant that is irrelevant on the simplex (\sum_i a_i = 1). This is the envelope theorem — only the multiplier matters, the plan itself contributes nothing.

Practical consequence: a loss a = a_\theta (a batch of features, parameters \theta) can be differentiated without re-differentiating the Sinkhorn iterations: we backpropagate the potential, not the plan.∎

“Debiased” Sinkhorn divergences and epsilon-scaling

  • Entropic bias: W_\varepsilon(a,a) > 0 (the regularized plan “blurs” even between identical distributions) and the plan is concentrated near ab^\top as \varepsilon \to \infty. Correction (Feydy et al., AISTATS 2019): S_\varepsilon(a,b) = W_\varepsilon(a,b) - \tfrac12 W_\varepsilon(a,a) - \tfrac12 W_\varepsilon(b,b) \ \geq\ 0, \qquad S_\varepsilon(a,a) = 0, which interpolates between W (ε→0) and a kernel distance (MMD, ε→∞) — the loss of choice for comparing clouds in deep learning.
  • ε-scaling: at small \varepsilon, K = e^{-C/\varepsilon} is numerically degenerate (its smallest entries underflow): start at large \varepsilon (fast convergence), then divide it by ~2 down to the target, reusing (u, v) warm; stabilized variants in log space (ot.bregman.sinkhorn_log, sketched after the code below).
  • GPU and complexity: one iteration = two matrix-vector products (\mathcal{O}(n^2)), fully parallelizable and “batchable” (thousands of problems at once on GPU); the exact LP (\mathcal{O}(n^3 \log n)) lacks this memory regularity — hence Sinkhorn’s supremacy in high dimension.

Definition 3.5 — Sliced transport (1D projections) \mathrm{SW}_p^p(\mu,\nu) = \int_{\mathbb{S}^{d-1}} W_p^p\big(\theta_\#\mu,\ \theta_\#\nu\big)\,d\theta, the average of the 1D W_p of the projections onto all directions \theta. It is computable by sorting (prop. 2.6) and estimated by Monte-Carlo over L directions: \mathcal{O}(L\,n\log n), with no n \times n cost matrix.

Statistical benefits: no curse of dimensionality (estimating \mathrm{SW} converges at n^{-1/2}, versus n^{-1/d} for W_p) — see Tanguy, Flamary & Delon (2024) for the fine analysis of empirical projections. It is also the natural language for the spectrograms of the Signal Processing module (ch. 9): projecting = marginalizing.

import numpy as np
import ot                              # POT: Python Optimal Transport

n = 200
xs, xt = np.random.RandomState(0).normal(0, 1, (n, 2)), np.random.RandomState(1).normal([2, 0], [0.5, 2], (n, 2))
a, b = np.ones(n) / n, np.ones(n) / n
C = ot.dist(xs, xt)                    # squared costs ||x-y||^2

G = ot.emd(a, b, C)                    # exact OT (LP, transport simplex)
G0 = ot.emd2(a, b, C)                  # value only (exact W2^2)
Gs = ot.sinkhorn(a, b, C / C.max(), reg=0.05)
print("exact  :", (G * C).sum())
print("sinkhorn:", (Gs * C).sum())     # slight entropy overhead
print("sliced  :", ot.sliced_wasserstein_distance(xs, xt, n_projections=500))

# 1D: quantiles (prop. 2.6) -- exact W2 computed by sorting
print("W2 1d :", ot.wasserstein_1d(xs[:,0], xt[:,0], p=2)**0.5)

Sinkhorn in the log domain, from scratch. The iterations of theorem 3.2 can run on the potentials f = \varepsilon\log u and g = \varepsilon\log v instead of the scalings. Since u_i = e^{f_i/\varepsilon}, the update u \leftarrow a/(Kv) becomes a log-sum-exp: f_i \leftarrow \varepsilon\log a_i - \varepsilon\log\sum_j e^{(g_j - C_{ij})/\varepsilon}, \qquad g_j \leftarrow \varepsilon\log b_j - \varepsilon\log\sum_i e^{(f_i - C_{ij})/\varepsilon}.

The kernel K = e^{-C/\varepsilon} is never formed, so nothing underflows at small \varepsilon: this is what ot.sinkhorn(..., method="sinkhorn_log") runs (ot.bregman.sinkhorn_log). The lines below reuse the clouds of the previous block and check the plan against POT.

from scipy.special import logsumexp

def sinkhorn_log(a, b, C, eps, n_iter=1000):
    """Log-domain Sinkhorn (th. 3.2) on the potentials f = eps*log(u), g = eps*log(v)."""
    f, g = np.zeros(len(a)), np.zeros(len(b))
    for _ in range(n_iter):
        f = eps * np.log(a) - eps * logsumexp((g[None, :] - C) / eps, axis=1)  # u <- a / (K v)
        g = eps * np.log(b) - eps * logsumexp((f[:, None] - C) / eps, axis=0)  # v <- b / (K^T u)
    return np.exp((f[:, None] + g[None, :] - C) / eps), f, g

Cn = C / C.max()                                        # same clouds and costs as above
P, f, g = sinkhorn_log(a, b, Cn, eps=0.01)
P_pot = ot.sinkhorn(a, b, Cn, reg=0.01, method="sinkhorn_log")
print("max |P - P_pot|:", np.abs(P - P_pot).max())     # about 1e-11
print("marginal error :", np.abs(P.sum(1) - a).max(), np.abs(P.sum(0) - b).max())
print("<C,P> vs exact :", (P * Cn).sum(), ot.emd2(a, b, Cn))  # entropic plan costs more

The two plans agree to about 10^{-11} and the marginals hold to machine precision. The transport cost of the entropic plan stays above the exact optimum, because that plan is admissible but blurred: the entropic bias of the note above.

These f and g are log-scalings, not the multipliers of the proof of th. 3.2. From u_i = a_i e^{\lambda_i/\varepsilon}, \lambda = f - \varepsilon\log a , and the potential of th. 3.4 is \lambda^\star, because def. 3.1 measures the entropy against ab^\top. So f gives the gradient in a, up to a constant, only when a is uniform; a finite-difference check with random weights shows the difference.

4. OT and machine learning

With the tools of ch. 1–3 in hand, this chapter uses transport to solve learning problems: adapting a classifier to a shifted domain, training generative models with a Wasserstein loss, averaging distributions, comparing documents — and asks how many samples are needed to estimate a Wasserstein distance.

Definition 4.1 — Domain adaptation, covariate shift A domain adaptation problem provides a labeled source (x_i, y_i)_{i \leq n} \sim \mu_S on \mathcal{X} \times \mathcal{Y} and an unlabeled target (z_j)_{j \leq m} \sim \mu_T on \mathcal{X}.

Working assumption (covariate shift): the labeling rule P(Y \mid X) is the same in both domains, but the marginals \mu_S \neq \mu_T (sensors, populations, image styles…).

A classifier trained on the source suffers from the distribution shift; the OT idea: transport the source onto the target before learning — exactly Monge’s problem of ch. 1, applied to clouds of features.

OTDA algorithm — transport, propagate the labels, predict (Courty, Flamary et al., IEEE TPAMI 2016)

  1. Costs: C_{ij} = \|x_i - z_j\|^2 (centered-scaled features, possibly kernel or deep features, cf. the Deep Learning module M1P1, chapter 7 “transfer learning”).

  2. Class regularization: the x_i carry labels, so we penalize plans in which one target point receives mass from several classes. With I_c the set of source rows of class c, the group-lasso penalty of Courty et al. is \Omega_c(\Gamma) = \sum_j \sum_c \big\|\Gamma_{I_c,\, j}\big\|_2 . For each target column j, the mass coming from each class forms one group, so each target point is fed by few classes, ideally one. Final cost: \langle C, \Gamma\rangle + entropy + \eta\,\Omega_c(\Gamma), solved by generalized conditional gradient, each step being a Sinkhorn problem (ch. 3). POT implements it as ot.da.SinkhornL1l2Transport; ot.da.SinkhornLpl1Transport uses the non-convex \ell_p–\ell_1 variant (p = 1/2), solved by majorization-minimization.

  3. Barycentric transport: each source point is sent to the plan-weighted average of its images, \hat T(x_i) \;=\; \frac{1}{a_i}\sum_j\ \Gamma_{ij}\, z_j, and its label y_i follows. The plan is a soft coupling, not a map, and \hat T is its barycentric projection.

    For discrete measures it is in general not an optimal Monge map, and it does not push a exactly onto b: corollary 2.3 needs \mu \ll \mathrm{Leb}. The exception is exact OT between two uniform clouds of the same size, whose optimal plan can be chosen to be a permutation (exercise 8). When the samples come from a measure with a density, the barycentric projection approximates the Brenier map as the sample size grows, provided \varepsilon is zero or shrinks with it.

    Label propagation is the dual view: the label predicted for z_j is the plan-weighted majority of the classes arriving at z_j.

  4. Learning: train the classifier on the transported pairs (\hat T(x_i),\, y_i) — which live in the target space — then predict on the target.

  5. Out-of-sample: a new point z is predicted directly (it is already in the target space); to transport a new source point without recomputing the plan, interpolate the plan row of the k nearest neighbors of x in the source, or learn a map T_\theta \approx \hat T (a network, Deep Learning module).

Positioning: the module’s instructor is a co-author of the paper — detailed in ch. 7.

The JDOT extension (Courty, Flamary et al., NeurIPS 2017) transports the joint law (X, Y) with a cost that includes the label loss, c\big((x,y),(z,y')\big) = \alpha\|x - z\|^2 + \ell(y', y), where \ell is the label loss and y' = h(z) is the label that the classifier h, learned alternately with the plan, predicts on the target point. This gives unsupervised and semi-supervised adaptation in the same framework.

Proposition 4.2 — Kantorovich-Rubinstein duality, or why GANs are called “Wasserstein” (proved sketch) For c = d (a distance), W_1(\mu, \nu) \;=\; \sup_{\|f\|_{\mathrm{Lip}} \leq 1}\ \int f\, d\mu - \int f\, d\nu, the sup being taken over the 1-Lipschitz functions.

Proof. Start from the duality of th. 2.1 with c = d and replace g by the c-transform g = f^c (def. 2.2: this does not decrease the objective). For a distance cost, f^c(y) = \inf_x\,[\,d(x,y) - f(x)\,] .

If f is 1-Lipschitz, taking x = y gives f^c(y) = -f(y), because the infimum is attained at x = y: indeed f(x) \leq f(y) + d(x,y), i.e. d(x,y) - f(x) \geq -f(y) . The dual then equals \int f\,d\mu - \int f\, d\nu.

Conversely, the constraint f(x) + f^c(y) \leq d(x,y) with y \to x forces |f(x) - f(x')| \leq d(x, x'): every admissible dual pair can be written (up to normalization) with a 1-Lipschitz f — hence the formula (complete proof: Villani 2009, th. 5.10).∎

The WGAN (Arjovsky, Chintala & Bottou, ICML 2017) minimizes precisely this quantity between the law of the data and that of a generator G_\theta: \min_\theta\ \max_{D_\phi\ \mathrm{1\!-\!Lip}}\ \mathbb{E}_{x \sim \mathrm{data}}[D_\phi(x)] \ -\ \mathbb{E}_{z \sim p(z)}[D_\phi(G_\theta(z))], the “critic” D_\phi playing the role of a parametrized Kantorovich potential (the dual of th. 2.1 makes the loss differentiable in \theta).

The 1-Lipschitz constraint in practice: weight clipping, gradient penalty (Gulrajani et al., 2017), spectral normalization (Miyato et al., 2018) — cf. the Deep Learning module M1P1, chapter 9 (generative models). A modern computable alternative: the debiased Sinkhorn loss of ch. 3 (th. 3.4: we backpropagate the potential), available with PyTorch/JAX backends in POT.

Definition 4.3 — Wasserstein barycenter (Agueh & Carlier, 2011) For measures \mu_1, \dots, \mu_K and weights w \in \Delta_K (the simplex): \mathrm{Bar}(\mu_1, \dots, \mu_K; w) \;=\; \arg\min_{\nu}\ \sum_{k=1}^{K} w_k\, W_2^2(\nu, \mu_k). The 1D Gaussian case is solved explicitly by corollary 2.8 (barycentric quantiles). General cases:

  • Fixed support (a grid of p points): the problem is convex in the barycenter weights — quadratic programming (Agueh-Carlier) or iterative Sinkhorn;
  • Iterated Bregman projections (IBP): the entropic version (Benamou et al., 2015): initialize \Gamma_k independently for each k, then repeat for each k a Sinkhorn scaling step (th. 3.2) toward the common barycenter mass, then a rescaling toward the marginal \mu_k — a “squared” Sinkhorn iteration, parallelizable;
  • Free support (Cuturi & Doucet, 2014): optimize positions and weights of the barycenter points by alternating: (i) plans \Gamma_k toward each measure (OT), (ii) moving the barycenter points toward the barycenter of their images — the multi-measure extension of the barycentric transport formula of the OTDA algorithm.

Applications: interpolation of shapes and distributions, color transfer (histograms), atlases and averages in medical imaging, signal normalization (ch. 7: Convolutional Monge Mapping), barycenters of graphs (ch. 5, FGW). POT: ot.bregman.barycenter, ot.lp.free_support_barycenter.

Example 4.4 — Word Mover’s Distance: the distance between documents as OT (Kusner et al., ICML 2015) A document is a distribution over the embeddings of its words: a_i \propto frequency (or frequency × idf) of word i, point x_i \in \mathbb{R}^d its embedding (word2vec/GloVe — cf. the Text Mining and NLP module M1P2, chapter 4).

The WMD between two documents is simply W_1 between these two discrete distributions, with the Euclidean cost between embeddings: the transport plan “explains” the semantic proximity: “Obama” speaks to “president”, “France” to “Germany”.

For large-scale nearest-neighbor search, lower bounds (relaxed distances between centroids) are precomputed so that exact OT is solved only on the candidates.

import numpy as np, ot
# two partially shared "documents", fictitious embeddings
X = np.array([[0., 0.], [1., 0.], [10., 0.]])     # king, queen, cat (source)
Y = np.array([[0.1, 0.], [1.2, 0.], [10.4, 0.]])  # queen, king, dog  (target)
a = np.array([.5, .3, .2]); b = np.array([.4, .4, .2])
C = ot.dist(X, Y, metric="euclidean")              # Euclidean costs (WMD is a W_1)
print("WMD :", ot.emd2(a, b, C))                   # exact plan: ot.emd(a, b, C)

Spectral loss: Gaussian W_2 as a closed-form, differentiable loss Compare two batches of generative data (images, audio) by fitting a Gaussian to their features and evaluating W_2^2 with the closed formula of theorem 2.7 (Bures metric): this is the FID of image generators and the “Fréchet audio distance” of audio generators — a loss without a solver, differentiable, usable as a training loss (spectral loss).

This is exactly the announced bridge with the Signal Processing module M1P1: chapter 8 (FID and Bures are presented there) and chapter 9 (bridge lab). In 1D (spectra, signals), return to quantiles (prop. 2.6); ot.gaussian.empirical_bures_wasserstein_distance provides the Gaussian empirical estimate.

Theorem 4.5 — Statistical estimation of W: the curse of dimensionality, and the Sinkhorn exception (statement) Let \mu_n be the empirical measure of n i.i.d. points \sim \mu on \mathbb{R}^d. Then:

  • Exact OT: \mathbb{E}\,W_p(\mu_n, \mu) \asymp n^{-1/d} for d > 2p (Dudley; sharp bounds by Fournier & Guillin, 2015). In high dimension, the empirical W_p distance between two samples of the same law remains of constant order — the “noise” does not decrease: using exact W_p as a loss in high dimension is statistically fragile;
  • Debiased Sinkhorn: the divergence S_\varepsilon of ch. 3 (debiased) is estimated at the parametric rate n^{-1/2} under regularity assumptions (Genevay, Chizat, Bach, Peyré & Rigollet, AISTATS 2019); the same holds for the sliced distance (def. 3.5, 1D projections).
Comparator Empirical rate Cost for n points Differentiable?
exact W_p n^{-1/d} \mathcal{O}(n^3 \log n) subgradients only
Sinkhorn W_\varepsilon, S_\varepsilon n^{-1/2} (debiased) \mathcal{O}(n^2) / iteration yes (potential, th. 3.4)
sliced \mathrm{SW}_p n^{-1/2} \mathcal{O}(L\, n\log n) yes (sorting)
Gaussian W_2 (Bures) parametric (if Gaussian) \mathcal{O}(d^3) yes (closed form)

Reading: in small dimension or in 1D, exact OT (quantiles); in high dimension, regularize (entropy, projections, Gaussian). This is the rule applied in all the labs of this module.

5. Gromov-Wasserstein and beyond

Sometimes the two distributions live in different spaces — two graphs with unrelated node sets, two word-embedding spaces of different languages — so that no cost c(x, y) between their points exists. Gromov-Wasserstein compares instead the internal distances of each space; this chapter defines it, proves its invariance, and gives its algorithms and its variants for attributed graphs and data matrices.

Definition 5.1 — Gromov-Wasserstein transport (Mémoli, 2011) The two clouds live in incomparable spaces: we have no cross cost c(x, y), only internal structures — distance matrices D \in \mathbb{R}^{n \times n} (source) and D' \in \mathbb{R}^{m \times m} (target). Notation: on the graph pages D is the degree matrix; in this chapter, as in the GW literature, D and D' are distance matrices (for a graph, shortest-path distances). The quadratic problem: \mathrm{GW}_2^2(D, D'; a, b) \;=\; \min_{\Gamma \in U(a,b)}\ \sum_{i,k,j,l} \big(D_{ik} - D'_{jl}\big)^2\ \Gamma_{ij}\,\Gamma_{kl}, that is, \min_\gamma \mathbb{E}\big[\,\big(\mathcal{D}(X, X') - \mathcal{D}'(Y, Y')\big)^2\,\big] where (X, Y) and (X', Y') are i.i.d. with law \gamma: we look for the coupling that makes the pairs of internal distances as equal as possible.

Interpretation: preserve the neighborhoods, the triangles, the “shape” — not the positions. The problem is non-convex in \Gamma (quadratic): local minima, important initialization — a complete contrast with ch. 1.

Theorem 5.2 — Isometric invariance of GW (proved as a sketch) Let \varphi be an isometry between the structured spaces, with \varphi_\#\mu = \nu: \mathcal{D}'(\varphi(x), \varphi(x')) = \mathcal{D}(x, x') \quad \text{for all } x, x'. Then \mathrm{GW}_2(\mu, \nu) = 0 . Conversely (Mémoli): \mathrm{GW}_2(\mu, \nu) = 0 if and only if such a measure-preserving isometry exists.

Proof. The diagonal plan \gamma^\star = (\mathrm{Id}, \varphi)_\#\mu is admissible (marginals \mu and \varphi_\#\mu = \nu). For two copies (X, \varphi(X)) and (X', \varphi(X')) i.i.d. from \gamma^\star, each term of the quadratic sum vanishes pointwise, by the definition of an isometry: \big(\mathcal{D}(X, X') - \mathcal{D}'(\varphi(X), \varphi(X'))\big)^2 = 0 . The cost is 0, and 0 is the lower bound (a sum of squares).

The converse: a zero cost forces \mathcal{D}(X, X') = \mathcal{D}'(Y, Y') \gamma-almost surely; the support of \gamma^\star (compact, closed) then defines the sought isometry between the supports (a closure argument, admitted).∎

Practical consequence: GW is invariant under rotations, translations, reflections, changes of frame — where W_2 “sees” the absolute offset of the clouds (and equals \|\text{translation}\| even for two isometric copies). It is the right distance for aligning objects defined up to an isometry: graphs, proteins, surfaces, heterogeneous embedding spaces.

GW algorithms: projected (PGW), entropic, sliced (SGW)

  • Projected GW — PGW (Peyré, Cuturi & Solomon, ICML 2016): linearize the quadratic problem around the current plan \Gamma^{(t)}. The gradient of the objective in \Gamma is 2c^{(t)}, with c^{(t)}_{ij} \;=\; \sum_{k,l}\ \big(D_{ik} - D'_{jl}\big)^2\ \Gamma^{(t)}_{kl} \;=\; \big[(D \odot D)\,a\big]_i + \big[(D' \odot D')\,b\big]_j - 2\,\big[D\,\Gamma^{(t)}\,D'^\top\big]_{ij}, using \Gamma^{(t)}\mathbf{1} = a and \Gamma^{(t)\top}\mathbf{1} = b, where \odot is the entrywise product (in matrix form: two matrix-matrix products, \mathcal{O}(n^2 m)).

    We then iterate: solve the linear OT with cost c^{(t)} (exact LP or Sinkhorn) → new plan \Gamma^{(t+1)}. This is a conditional-gradient (Frank-Wolfe) scheme: with a line search between \Gamma^{(t)} and the new plan, the GW value decreases at each iteration and the iterates reach a stationary point — in practice a local minimum, hence the importance of the initialization.

  • Entropic GW (Solomon, Peyré, Kim & Sra, SIGGRAPH 2016): regularize each linearized subproblem by \varepsilon\,\mathrm{KL} and solve it by Sinkhorn (ch. 3): dense and smooth plans, GPU, but entropic blur — ε-scaling is used. In POT this is ot.gromov.entropic_gromov_wasserstein (parameter epsilon); ot.gromov.gromov_wasserstein is the unregularized conditional-gradient solver.

  • SGW (Vayer et al., NeurIPS 2019): project the structures onto 1D lines and average — the sliced analogue of ch. 3, speeds of \mathcal{O}(L n\log n) and no statistical curse.

Definition 5.3 — Fused Gromov-Wasserstein: features and structure (Vayer, Chapel, Flamary, Tavenard & Courty, ICML 2019) When the objects also carry comparable attributes (features F \in \mathbb{R}^{n \times d}, F' \in \mathbb{R}^{m \times d'} with a cross cost C_F(x_i, y_j), typically \|F_i - F'_j\|^2 after aligning the dimensions): \mathrm{FGW}_{\alpha} \;=\; \min_{\Gamma \in U(a,b)}\ (1-\alpha)\sum_{i,j} C_F(x_i, y_j)\,\Gamma_{ij} \;+\; \alpha\sum_{i,k,j,l} \big(D_{ik} - D'_{jl}\big)^2 \Gamma_{ij}\Gamma_{kl}.

The parameter \alpha \in [0, 1] arbitrates between fidelity to the attributes (\alpha = 0: pure Wasserstein on the features) and fidelity to the structure (\alpha = 1: pure GW). This is the convention of Vayer et al. (2019) and of the alpha argument of ot.gromov.fused_gromov_wasserstein, so the \alpha sweeps of the labs read the same way. The paper shows a form of continuity of the distance in \alpha and bounds between FGW and its two extremes. The algorithm: PGW applied to the combined cost (the same linearization iteration).

This is the distance for attributed graphs: molecules (atoms: features; bonds: structure), social networks, brains — cf. the Graph ML module M1P2, chapter 5 (GNNs: message passing combines exactly attributes and structure) and chapter 9 (graph generation/evaluation). The FGW barycenter of several graphs defines a graph “average” (Vayer et al.).

Definition 5.4 — COOT: co-optimal transport over rows and columns (Redko, Vayer, Flamary & Courty, NeurIPS 2020) Two data matrices X \in \mathbb{R}^{n \times d} (objects as rows, variables as columns) and Y \in \mathbb{R}^{m \times p} — object and variable dimensions possibly different. COOT looks for two couplings, \pi \in U(a, c) between the rows and \sigma \in U(b, d) between the columns: \min_{\pi, \sigma}\ \sum_{i,j,k,l}\ \big(X_{ik} - Y_{jl}\big)^2\ \pi_{ij}\, \sigma_{kl}, solved by alternation: with \sigma fixed, the problem in \pi is a linear OT with cost \sum_{kl}(X_{ik} - Y_{jl})^2\sigma_{kl} (and symmetrically).

COOT unifies and generalizes: classical OT (a single cross-cost matrix), GW (when X and Y are themselves internal distance matrices D, D'), co-clustering and heterogeneous domain adaptation (aligning simultaneously samples and sensors/features — for example two EEG datasets with different electrodes). Here again: non-convex alternation, local minimum, initialization by OT or k-means.

Example 5.5 — Alignment of graphs and knowledge graphs (an LLGA application), in POT Align two graphs (nodes with no given correspondence): GW on the adjacency/distance matrices; if the nodes carry attributes, FGW. Typical use cases in the master’s program:

  • alignment of knowledge graphs (entities/relations of two bases, cf. the Graph ML module, chapter 10 on GraphRAG: disambiguating the common entities);
  • alignment of two word embedding spaces without a dictionary — Gromov-Wasserstein alignment of word embedding spaces (Alvarez-Melis & Jaakkola, EMNLP 2018): GW between the internal similarity matrices of two languages aligns the spaces in an unsupervised way (the plan connects words with the same neighborhoods) — a direct link with the Text Mining and NLP module, chapter 4.
import numpy as np, ot                          # POT: ot.gromov
from scipy.sparse.csgraph import shortest_path

# two non-isomorphic 4-node graphs: a star K_{1,3} and a path P_4
A1 = np.array([[0., 1., 1., 1.], [1., 0., 0., 0.], [1., 0., 0., 0.], [1., 0., 0., 0.]])
A2 = np.array([[0., 1., 0., 0.], [1., 0., 1., 0.], [0., 1., 0., 1.], [0., 0., 1., 0.]])
D1 = shortest_path(A1, unweighted=True)         # distance matrices: zero diagonal
D2 = shortest_path(A2, unweighted=True)
a = np.ones(4) / 4 ; b = np.ones(4) / 4

# exact GW (conditional gradient, no regularization): node alignment plan
G = ot.gromov.gromov_wasserstein(D1, D2, a, b, loss_fun='square_loss')
print("GW2^2 :", ot.gromov.gromov_wasserstein2(D1, D2, a, b))     # 0.375 > 0

# FGW: add node attributes (same dimension here) and sweep alpha (def. 5.3)
F1 = np.array([[0., 0.], [1., 0.], [1., 0.], [0., 1.]])
F2 = np.array([[1., 0.], [0., 0.], [0., 1.], [1., 0.]])
Cf = ot.dist(F1, F2)
for alpha in (0.0, 0.5, 1.0):                   # 0: features only, 1: structure only
    Gf, log = ot.gromov.fused_gromov_wasserstein(Cf, D1, D2, a, b,
                                                 loss_fun='square_loss', alpha=alpha,
                                                 log=True)
    print(f"FGW(alpha={alpha}) :", log['fgw_dist'])

The star and the path have different distance profiles, so GW is positive; 0.375 is also the best value over the 24 node matchings. FGW is 0 at \alpha = 0 (the attributes match exactly) and rises to the GW value at \alpha = 1.

Lab remark: test several initializations (GW is non-convex), plot the distance as a function of \alpha (FGW continuity), compare with the known exact alignment (synthetic sets of isomorphic graphs: GW = 0, th. 5.2).

The CMAP/POT GW bestiary The ecosystem developed around the instructor: semi-relaxed GW (only one side preserved — ICLR 2022), unbalanced fused GW for brain alignment (fugw, NeurIPS 2022), sliced GW, graph barycenters for prediction (NeurIPS 2022), and the complete integration into POT (ot.gromov: gromov_wasserstein, fused_gromov_wasserstein…, and ot.coot.co_optimal_transport). Positioning with respect to the course: ch. 5 lays the definitions; these variants each fix a practical limitation (unequal masses, size, attributes) — details in ch. 7.

6. Fairness through transport

A model trained on historical data reproduces the disparities between groups that these data contain. Fairness criteria compare the distributions of decisions across groups, so transport — which moves one distribution onto another at minimal cost — gives a natural way to repair the data or the decisions while changing them as little as possible.

Definition 6.1 — The framework: sensitive attribute, demographic parity, equalized odds Data (X, S, Y): features, sensitive attribute S (gender, origin…), label Y; predictor \hat Y = h(X) (possibly randomized). Two emblematic criteria:

  • Demographic parity (DP): \hat Y independent of S — the same positive decision rates per group;
  • Equalized odds (EO, Hardt, Price & Srebro, 2016): \hat Y independent of S given Y — the same true positive and false positive rates per group.

OT enters both scenarios: (i) pre-processing — repair the feature distribution with a Wasserstein barycenter; (ii) post-processing — couple the per-group score distributions. In both cases, the central object is a coupling, i.e. a transport plan as in ch. 1.

Theorem 6.2 — Repair by Wasserstein barycenter (Gordaliza, Del Barrio, Gamboa & Loubes, ICML 2019) Algorithm (full repair, scalar case then multivariate).

  1. Estimate the conditional laws \mu_s = \mathcal{L}(X \mid S = s) by the empirical quantiles Q_s = \hat F_s^{-1} (sorting, prop. 2.6).
  2. Form the barycenter of the \mu_s weighted by the proportions p_s = \mathbb{P}(S = s); in 1D, corollary 2.8 gives its quantile function pointwise: Q^\star(u) \;=\; \sum_s\ p_s\, Q_s(u).
  3. Repair: replace each observation by its counterpart at the same quantile level in the barycenter: \tilde X_i = Q^\star\big(\hat F_s(X_i)\big) for S_i = s. In the multivariate case, replace the 1D transport by a Sinkhorn plan between each cloud and a common entropic barycenter (def. 4.3), then use the barycentric projection of the OTDA algorithm (ch. 4).
  4. Retrain the model on the (\tilde X_i, Y_i) without the sensitive attribute.

Proof. Full repair guarantees demographic parity. Let U_s = \hat F_s(X) for X \sim \mu_s: U_s is (asymptotically) uniform on [0,1], and \tilde X = Q^\star(U_s). Hence the conditional law \mathcal{L}(\tilde X \mid S = s) = \mathcal{L}\big(Q^\star(U)\big) is the same law for every s — the barycenter.

Identical conditionals give independence: \mathbb{P}(\tilde X \in A, S = s) = \mathbb{P}(\tilde X \in A \mid S = s)\, \mathbb{P}(S = s) = \mathbb{P}(\tilde X \in A)\,\mathbb{P}(S = s). Any predictor h(\tilde X) then inherits independence from S: DP, regardless of the downstream classifier.∎

Partial repair: interpolate the quantiles, \tilde X^{(\lambda)} = (1-\lambda)\, Q_s(U_s) + \lambda\, Q^\star(U_s), with \lambda \in [0, 1] — \lambda = 0: untouched data; \lambda = 1: full repair.

Utility/fairness trade-off: as \lambda is swept, the demographic parity gap decreases (the conditionals get closer in Wasserstein distance, linearly in \lambda for the interpolated transport), while accuracy decreases all the faster as X carries signal correlated with S.

The curve (DP gap on the x-axis, accuracy on the y-axis) is typically decreasing with a “knee” — one chooses \lambda at the elbow, where a lot of equity has been bought for little utility. This is the curve plotted in the lab below.

Proposition 6.3 — Bicausal OT, counterfactuals and optimal EO post-processing by coupling (simple case proved) Bicausal OT. To compare two “twin” individuals differing only in the sensitive attribute, we couple the joint laws \mathcal{L}(S, X) with a plan \pi respecting the causal structure S \to X. This is a bicausal coupling: the copy of X depends on the copy of S only through the coupling of the conditionals \mathcal{L}(X \mid S = s) (de Lara, González-Sanz, Asher, Risser & Loubes, JMLR 2024).

The counterfactual X^\star(s') — “the value X would have taken had S been s'” — is the coupled point: constructed by OT between \mathcal{L}(X \mid S = s) and \mathcal{L}(X \mid S = s').

Applications: measuring discrimination \mathbb{E}\big[c(X, X^\star)\big], predicting on the counterfactual (“counterfactual” fairness).

Proof. EO post-processing: the optimal coupling is the increasing coupling. Simple setting: Y \in \{0,1\}, real score R_s = f(X) per group, and a randomized post-processing \hat Y_s = g_s(R_s, U), U \sim \mathcal{U}[0,1] common.

  1. Such a post-processing is exactly a coupling between the law of R_s \mid Y = y and a target Bernoulli law — the noise U realizes the plan.
  2. EO requires that the law of \hat Y_s \mid Y = y be the same for both groups: we therefore couple simultaneously the two conditional score laws to a common target.
  3. Among these couplings, the one maximizing utility (accuracy, increasing in the score within each class) is the increasing coupling — quantile matching. The uncrossing argument of the proof of prop. 2.6 applies word for word: uncrossing two pairs (making the coupling more comonotone) cannot decrease a utility that is increasing in both scores.

Concretely: bring each score to its rank U_s = \hat F_s(R_s) (quantile within its group), then apply the same decision rule to the U_s — the equalization of the conditional laws happens on the quantiles. Choosing the common operating point (TPR, FPR) maximizes the linear utility \mathbb{P}(Y{=}1)\,\mathrm{TPR} + \mathbb{P}(Y{=}0)\,(1 - \mathrm{FPR}) over the feasible set (the intersection of the two regions convexified by randomization — the “mixture of predictors” procedure of Hardt et al., reread as an OT coupling).∎

Limits and debate: incompatible metrics, utility, causal assumptions

  • Theoretical incompatibilities: when the base rates \mathbb{P}(Y = 1 \mid S = s) differ across groups, calibration and equalized odds are mutually exclusive (Kleinberg, Mullainathan & Raghavan, 2017; Chouldechova, 2017): no method — OT included — can satisfy all the criteria; choosing the metric is choosing the trade-off.
  • Utility cost: DP repair can destroy a legitimate signal (if S genuinely predicts Y, independence forces a loss); “blind” repair is not always fair in the individual sense.
  • Causal assumptions: counterfactuals by bicausal OT assume a structure S \to X and the absence of unmeasured confounding; two different optimal bicausal couplings (non-uniqueness, cf. example 1.2) can yield different counterfactuals — OT provides a family of models, to be audited (the JMLR 2024 paper proposes statistical tests).
  • Position of the course: OT is not an answer to the question of justice, but a geometric language for quantifying trade-offs: distances between groups, barycenters, optimal couplings — the same objects as in ch. 1-5.

Guided lab — repair and trade-off curves on Adult (UCI)

import numpy as np, ot
from sklearn.linear_model import LogisticRegression
# Adult: X = numerical variables, S = gender, Y = income > 50k
# (load with pandas.read_csv("adult.data"), encode the categoricals)

def repair_1d(x, s, lam):
    """Partial quantile repair of one feature (th. 6.2): x -> (1-lam) x + lam Q*(F_s(x))."""
    xR, groups = x.astype(float).copy(), np.unique(s)
    p = {g: np.mean(s == g) for g in groups}                       # group weights p_s
    u = np.linspace(0, 1, 101)                                     # quantile levels
    bary = sum(p[g] * np.quantile(x[s == g], u) for g in groups)   # Q*(u) = sum_s p_s Q_s(u)
    for g in groups:
        xg = x[s == g]
        ug = (np.argsort(np.argsort(xg)) + 0.5) / len(xg)          # within-group ranks F_s(x)
        xR[s == g] = (1 - lam) * xg + lam * np.interp(ug, u, bary)
    return xR

def repair(X, s, lam):                                             # feature by feature
    return np.column_stack([repair_1d(X[:, j], s, lam) for j in range(X.shape[1])])

assert np.allclose(repair(X_num, S, 0.0), X_num)                   # lambda = 0 changes nothing
for lam in np.linspace(0, 1, 11):                  # lambda -> trade-off curve
    Xr = repair(X_num, S, lam)
    clf = LogisticRegression().fit(Xr, Y)
    acc = clf.score(Xr, Y)
    dp = abs(clf.predict_proba(Xr[S==0])[:,1].mean()
           - clf.predict_proba(Xr[S==1])[:,1].mean())
    print(f"lambda={lam:.1f}  accuracy={acc:.3f}  dp_gap={dp:.3f}")
# Plot accuracy vs dp_gap: knee of the curve, discussion in the lab

Lab questions:

  1. where is the knee, and what does it say?
  2. compare marginal 1D repair and multivariate repair by Sinkhorn;
  3. also measure the EO gap before/after;
  4. does repair preserve calibration? (connect to the debate above).

7. Research at CMAP (Flamary, Gaucher)

Who teaches this module, and why these chapters Rémi Flamary (CNRS, CMAP, École Polytechnique) is co-director of the LLGA master’s program and co-creator of the POT library. The methods presented in this module — OT domain adaptation (ch. 4), Gromov-Wasserstein and FGW (ch. 5) — partly come from his own papers: this chapter presents them as published, with their links. All the references below are real and verifiable.

POT — Python Optimal Transport (Flamary et al., JMLR 2021): the library of the course POT: Python Optimal Transport, Journal of Machine Learning Research 22(78), 2021 — pythonot.github.io. Principle: a unified library of OT solvers, with an API with three inputs (measures, costs, solver):

  • Exact solvers: ot.emd, ot.emd2 (network simplex, ch. 1); 1D by quantiles (ot.wasserstein_1d);
  • Regularized: ot.sinkhorn, ot.bregman.sinkhorn_log (ch. 3), debiased divergences ot.bregman.empirical_sinkhorn_divergence; exact and entropic barycenters (ch. 4);
  • Structured: ot.gromov — GW, FGW — and ot.coot — COOT (ch. 5); Gaussian (ot.gaussian.bures_wasserstein_distance, th. 2.7); sliced;
  • Application: ot.da — the transporter of the OTDA algorithm of ch. 4, packaged with label propagation and out-of-sample.

Result: some sixty solvers drawn from the literature, NumPy/PyTorch/JAX backends (differentiation of the potential, th. 3.4), an example gallery — the reference tool for numerical OT, used from medical applications to generative AI. Positioning: all the labs of this module use it; the architecture of ch. 3 (solvers, regularization, GPU) is exactly its architecture.

Optimal Transport for Domain Adaptation (Courty, Flamary, Tuia & Rakotomamonjy, IEEE TPAMI 2016) Optimal Transport for Domain Adaptation, IEEE Transactions on Pattern Analysis and Machine Intelligence 39(9), 2017 (online 2016).

Principle: that of the OTDA algorithm of ch. 4 — regularized coupling (entropy + class regularization by group-lasso) between the source/target clouds, barycentric transport of the labeled points, learning in the target space.

Result: theory (error bounds linking the source-target Wasserstein distance and the target risk) and experimental gains on images and texts; the extension JDOT (Courty, Flamary, Habrard & Rakotomamonjy, NeurIPS 2017) transports the joint law (X, Y) by including the label loss in the cost — the direct ancestor of OT training losses.

Positioning: this is ch. 4 of the course; the modern benchmark SKADA-Bench (TMLR 2025) measures its successors.

Fused Gromov-Wasserstein (Vayer, Chapel, Flamary, Tavenard & Courty, ICML 2019) Optimal Transport for structured data with application on graphs, ICML 2019 (PMLR 97).

Principle: the FGW distance of ch. 5 — combining the feature cost and the structure cost under a parameter \alpha, with continuity and bounds with respect to the two extremes; a linearization-type algorithm (PGW).

Result: classification and barycenters of attributed graphs (the “average” of several graphs exists: it is used in classification by nearest barycenter); applications to molecules/time series.

Positioning: def. 5.3 of the course; the “graphs” side extends into M1P2 (Graph ML module, ch. 5 and 9) and up to FGW-template GNNs (NeurIPS 2022).

CO-Optimal Transport (Redko, Vayer, Flamary & Courty, NeurIPS 2020) CO-Optimal Transport, NeurIPS 2020 — code github.com/PythonOT/COOT.

Principle: def. 5.4 — transporting simultaneously the samples (rows) and the variables (columns) of two data matrices via two alternating couplings.

Result: a unifying framework subsuming OT, GW and co-clustering; marked gains in heterogeneous domain adaptation (datasets with different features: texts in different languages, distinct sensors).

Positioning: the “double alternation” of ch. 5; available in POT (ot.coot.co_optimal_transport).

Two recent tracks: sliced under the magnifier, OT for biosignals

Exercises

  1. ★ Duality in dimension 2 (solution). Source and target in \mathbb{R}, cost \|x - y\|: a = (1/2, 1/2) \text{ at } x_1 = 0,\ x_2 = 1, \qquad b = (1/2, 1/2) \text{ at } y_1 = 0,\ y_2 = 2. Write the primal, guess the optimal plan, deduce the dual potentials from the complementarity of th. 2.1 and check the equality of the values.

    Solution (sketch). The cost matrix is C = \begin{pmatrix}0 & 2\\ 1 & 1\end{pmatrix}, and the extreme admissible plans are \Gamma_1 = \big(\begin{smallmatrix}1/2 & 0\\ 0 & 1/2\end{smallmatrix}\big) \ (\text{cost } 1/2), \qquad \Gamma_2 = \big(\begin{smallmatrix}0 & 1/2\\ 1/2 & 0\end{smallmatrix}\big) \ (\text{cost } 3/2). Optimum: \Gamma_1, with W_1 = 1/2.

    Complementarity: the support of \Gamma^\star is \{(1,1), (2,2)\}, which gives the equalities f_1 + g_1 = C_{11} = 0 and f_2 + g_2 = C_{22} = 1, together with the inequalities f_1 + g_2 \leq 2 and f_2 + g_1 \leq 1.

    Take f = (0, 1), g = (0, 0): the value \langle a, f\rangle + \langle b, g\rangle = 1/2 equals the primal value — strong duality verified by hand.

  2. ★ Sinkhorn 2×2 by hand (solution). With a = b = (1/2, 1/2), C = \begin{pmatrix}0 & 1\\ 1 & 0\end{pmatrix} and \varepsilon = 1, compute K and initialize v = \mathbf{1}. Then perform two complete iterations of u \leftarrow a/(Kv), \qquad v \leftarrow b/(K^\top u), and check that the row marginals converge to a.

    Solution (values). The kernel is K = \big(\begin{smallmatrix}1 & e^{-1}\\ e^{-1} & 1\end{smallmatrix}\big). Iteration 1: Kv = (1 + e^{-1}, 1 + e^{-1})^\top, so u = \frac{1}{2(1+e^{-1})}(1,1)^\top; then K^\top u = \frac12(1,1)^\top, so v = (1,1)^\top again. The second iteration reproduces the same u and v: the fixed point is reached after a single complete iteration (symmetric case).

    The plan \Gamma = \mathrm{diag}(u)\,K = \frac{1}{2(1+e^{-1})}\big(\begin{smallmatrix}1 & e^{-1}\\ e^{-1} & 1\end{smallmatrix}\big) \approx \big(\begin{smallmatrix}0.366 & 0.134\\ 0.134 & 0.366\end{smallmatrix}\big) indeed has rows and columns summing to 1/2; the entropic plan “blurs” the diagonal toward the anti-diagonal (entropic bias, ch. 3).

  3. ★ Bures in simulation (lab). Draw n = 5000 points from two anisotropic 2D Gaussians (\Sigma_1 = \mathrm{diag}(4, 1) rotated, \Sigma_2 = \mathrm{diag}(1, 4)), compare the empirical W_2^2 (Sinkhorn on the samples) with the closed formula of th. 2.7 and with ot.gaussian.empirical_bures_wasserstein_distance (it returns the distance, not its square). Observe the effect of \varepsilon.

    Hint. The gap comes from the entropic bias (use ot.bregman.empirical_sinkhorn_divergence) and from the sampling noise (n^{-1/d}, th. 4.5: severe in dimension 2 if n is small).

  4. ★ Weighted Gaussian barycenter (hint). Rederive corollary 2.8 with arbitrary weights, then in the case of two laws \mathcal{N}(0, 1) and \mathcal{N}(0, 9): show that the standard deviation of the equal-weight barycenter equals 2 (and not \sqrt{5}), and comment (“the mean of the variances” is not the barycenter).

    Hint. Minimize pointwise in u the quantile function (zero derivative), then identify the resulting Gaussian quantile: \sigma = \sum_k w_k \sigma_k.

  5. ★ WMD on two sentences (solution). With real word2vec embeddings (Text Mining and NLP module, ch. 4), compute the WMD between “the president addresses the congress” and “Obama speaks to the parliament”, then between two unrelated sentences; display the plan (ot.emd) and comment on the word matchings.

    Solution (key). Documents = uniform distributions over the words (minus the stopwords); cost = Euclidean distance between embeddings (not its square: WMD uses W_1); the plan connects “president”↔︎“Obama”, “congress”↔︎“parliament” (neighbors in the space): the distance stays small where the centroid distance would be misled by function words.

  6. ★ GW invariant, W not (solution). Let \mu be uniform on three non-collinear points of the plane and \nu = \tau_\#\mu its translate by a vector of norm r, with the internal Euclidean distances. Show \mathrm{GW}_2(\mu, \nu) = 0 and W_2(\mu, \nu) = r. What happens under a rotation?

    Solution. The translation \tau preserves all the internal distances (an isometry in the sense of th. 5.2): diagonal plan at zero cost. For W_2, the plan (\mathrm{Id}, \tau)_\#\mu costs \big(\int \|x - (x + \tau)\|^2 d\mu\big)^{1/2} = r, and no coupling can do better, since by Jensen \mathbb{E}\|X - Y\|^2 \geq \|\mathbb{E}X - \mathbb{E}Y\|^2 = r^2 for every coupling (X, Y) (the means differ by the translation).

    Rotation: still GW = 0 (isometry); W_2 > 0 as soon as the points actually move — this is the motivation of ch. 5 (objects defined up to an isometry).

  7. ★★ Kantorovich-Rubinstein (solution). In the framework of prop. 4.2, show that if f is 1-Lipschitz then f^c = -f for the cost c(x, y) = |x - y| (in dimension 1), and conclude that W_1(\mu, \nu) = \sup_{\mathrm{Lip}(f) \leq 1} \int f\,d(\mu - \nu).

    Solution (key). By definition, f^c(y) = \inf_x [|x - y| - f(x)]. The choice x = y gives f^c(y) \leq -f(y). For every x, f(x) \leq f(y) + |x - y| (1-Lipschitz), hence |x - y| - f(x) \geq -f(y) . The infimum is therefore attained at x = y, and f^c = -f. The dual of th. 2.1 becomes \int f\,d\mu + \int (-f)\,d\nu over the admissible pairs (f, -f), which are exactly (up to an additive constant) the 1-Lipschitz functions — hence the formula.

  8. ★★ Vertices of the transport polytope (solution) — promised in ch. 1. Show that an optimal plan can be chosen with at most n + m - 1 non-zero coefficients (th. 1.3), build an example where the optimal plan is not deterministic, and connect it to example 1.2.

    Solution (sketch). Vertex: nm variables, constraints of rank \leq n + m - 1 (sum of the rows = sum of the columns); a vertex requires nm independent active constraints, of which at least nm - (n+m-1) are \Gamma_{ij} = 0.

    Non-deterministic example: a = (1) at x_1, b = (1/2, 1/2) — every plan has the form (1/2, 1/2), one row toward two columns: no vertex is a partial permutation. Link: this is example 1.2 (one mass, two half-masses).

    In general, a vertex has at most n + m - 1 non-zeros spread over n rows, each row having at least one: at most m - 1 rows carry more than one non-zero, so when n \gg m almost every source point goes to a single target.

    And when n = m with uniform weights 1/n, Birkhoff’s theorem says that the vertices are permutation matrices divided by n — the optimal plan is then a map.

  9. ★★ Partial repair and repair speed (hint). In the 1D framework of th. 6.2, show that the level-\lambda partial repair sends the conditionals toward laws at distance W_2\big(\mathcal{L}(\tilde X^{(\lambda)}\mid S{=}0), \mathcal{L}(\tilde X^{(\lambda)}\mid S{=}1)\big) = (1-\lambda)\, W_2(\mu_0, \mu_1).

    Hint. Write the interpolated quantile functions Q^{(\lambda)}_s = (1-\lambda)Q_s + \lambda Q^\star and use prop. 2.6: the difference factorizes, Q^{(\lambda)}_0(u) - Q^{(\lambda)}_1(u) = (1-\lambda)(Q_0(u) - Q_1(u)).

  10. ★★ Limits of FGW (hint). With the convention of def. 5.3 (that of POT), check that \mathrm{FGW}_{\alpha=0} recovers the OT of the features and \mathrm{FGW}_{\alpha=1} pure GW, then build two graphs where the FGW ranking changes from one to the other (consistent features but opposite structures).

    Hint. Take two 3-node graphs: the same star; features swapped between center and leaves; plot FGW as a function of \alpha (continuity, def. 5.3) on a synthetic set in POT.

  11. ★★ Binary equalized odds (hint). Two groups of equal sizes, Y binary and balanced within each, perfect scores for group 0 (\hat Y = Y) and random scores (coin flips) for group 1. Determine the randomized post-processing of prop. 6.3 that achieves EO, and its accuracy.

    Hint. In ROC coordinates (FPR, TPR), randomization makes the feasible set of each group convex: for group 0 (perfect scores) it is the triangle with vertices (0,0), (0,1), (1,1); for group 1 (coin flips) it is only the diagonal \mathrm{TPR} = \mathrm{FPR}.

    EO forces a common point, hence a point of the diagonal, where (balanced classes) the accuracy in both groups is \tfrac12\mathrm{TPR} + \tfrac12(1 - \mathrm{FPR}) = \tfrac12 . Group 0 must be “noised” down to chance level. Discuss this cost (the debate of ch. 6).

  12. ★★★ Synthesis lab — OTDA + FGW in POT. (a) Generate two 2D “source/target” clouds (shifted moons): full OTDA of ch. 4 with ot.da.SinkhornLpl1Transport (class-regularized transport, then transform), accuracy before/after.

    1. Two attributed 15-node graphs (stochastic block models): FGW alignment (ot.gromov.fused_gromov_wasserstein), recovered permutation matrix (f-score); sweep \alpha and \varepsilon, multiple initializations (GW non-convex, def. 5.1).

    Deliverables: curves, transport plan visualized (ot.plot.plot1D_mat), a short analysis.

Projects and assessment

The official assessment is a group project: “reading, understanding and numerical implementation of scientific papers, followed by an oral presentation of the results”, which carries 100% of the grade. The modality on the 2026–2027 sheet is “oral presentation by the group of the final project”, displayed for the engineering degree, the exchange programmes and the AI & Advanced Visual Computing MScT; the LLGA section of the sheet displays none. The subjects below are proposals of these notes, not official rules.

The group subjects follow the official format, a paper reimplemented, extended and presented orally by the group, and can stand for the graded project. The solo subjects train for it, or serve as individual variants if the instructors allow them. The written exam is a self-assessment proposal only, since the official grade has no exam.

The projects exercise mainly O1 (the mathematics and algorithms under OT losses), O8 (fairness repair and its limits) and O4 (Gromov-Wasserstein on graphs). The knowledge-graph subject adds O5, the evaluation suite adds O2 and O6, and every subject exercises O7 (hands-on work with POT, on real data except in the first solo subject).

Solo projects

  1. [Solo · ≈ 20 h] Sinkhorn from scratch, and as a loss. When is entropic OT a faithful, differentiable stand-in for exact OT, and at which statistical rate?
    • Work: log-domain Sinkhorn with ε-scaling and the debiased divergence S_\varepsilon, in NumPy then PyTorch (ch. 3); the gradient in a given by the potential \lambda^\star of th. 3.4 (not the log-scaling f of the ch. 3 code) compared with autodiff through the iterations; timings against ot.sinkhorn and ot.emd.
    • Experiments: a small MLP pushed from a Gaussian onto two moons with an S_\varepsilon loss; distances between two independent n-samples of the same law, for exact W_2, S_\varepsilon and sliced W_2, in dimensions 2, 10 and 50.
    • Data: synthetic only (Gaussians, sklearn.datasets.make_moons); a laptop is enough.
    • Success criterion: plans within 10^{-6} of POT; potential and autodiff gradients equal up to an additive constant; log-log slopes with intervals over 20 repetitions, compared with the rates of th. 4.5.
    • Deliverables: code, a 4–6 page report, a 10-minute talk; ch. 0–4.
  2. [Solo · ≈ 25 h] Paper study: OT domain adaptation (Courty, Flamary, Tuia and Rakotomamonjy, 2016) and JDOT (Courty, Flamary, Habrard and Rakotomamonjy, 2017). Does transporting the source onto the target beat a source-only classifier, and what does the class regularizer buy?
    • Work: OTDA with exact, entropic and class-regularized plans (ot.da.EMDTransport, SinkhornTransport, SinkhornLpl1Transport), out-of-sample mapping (ch. 4, step 5) and JDOT; first on shifted two moons, then on frozen ResNet-50 features. Baselines: source-only and a target-supervised oracle. An ablation with different class proportions in the target (label shift) breaks the covariate-shift assumption of def. 4.1.
    • Data: Office-31 (Saenko, Kulis, Fritz and Darrell, 2010), pairs A→W, D→W and W→A; MNIST→USPS as a fallback.
    • Success criterion: target accuracy per pair over 5 seeds, with intervals; the gain of the class regularizer measured at fixed \varepsilon; the label-shift failure observed and explained.
    • Deliverables: code, report, talk; ch. 1–4 and ch. 7. Extension: cross-subject EEG with Convolutional Monge Mapping Normalization (Gnassounou, Flamary and Gramfort, 2023).

Group projects

  1. [Group of 3 · ≈ 30 h each] Paper study: fair learning by Wasserstein-barycenter repair (Gordaliza, Del Barrio, Gamboa and Loubes, 2019). How much accuracy does demographic parity cost on real data, and which transport repair buys it most cheaply?
    • Data: Adult (UCI; Becker and Kohavi, 1996) with sex as the sensitive attribute; the COMPAS data released by ProPublica (Angwin, Larson, Mattu and Kirchner, 2016) as a second set.
    • Work: the per-feature partial repair of the ch. 6 lab; multivariate repair toward an entropic barycenter (def. 4.3) with the barycentric projection; equalized-odds post-processing by quantile coupling (prop. 6.3); accuracy against the DP and EO gaps as \lambda varies, on held-out data; calibration per group.
    • Split: 1D repair and the check of exercise 9; multivariate repair; EO post-processing and calibration; shared evaluation code.
    • Success criterion: \lambda = 0 reproduces the baseline exactly; for one feature, the W_2 distance between the repaired group laws follows (1-\lambda)\,W_2(\mu_0, \mu_1) within sampling error; Pareto curves with intervals over 5 splits; the calibration–EO incompatibility (Kleinberg, Mullainathan and Raghavan, 2017) observed and explained.
    • Deliverables: code, an 8–10 page joint report, a 20-minute group talk (the official format); ch. 2–4 and ch. 6. It is the fairness option of the Y1.3 news-recommendation project, where the groups are news categories and the repaired quantity is exposure.
  2. [Group of 3 · ≈ 30 h each] Paper study: entity alignment between knowledge graphs with Fused Gromov-Wasserstein (Vayer, Chapel, Flamary, Tavenard and Courty, 2019). How far does unsupervised FGW go on a real benchmark, and when does the structure term help over the attributes alone?
    • Data: DBP15K (Sun, Hu and Li, 2017), the ZH–EN pair, cut into samples of 500–1,000 aligned entity pairs with their induced subgraphs; node attributes from a multilingual sentence encoder such as LaBSE (Feng et al., 2022) applied to entity names; shortest-path distances on the relation graph.
    • Work: GW, FGW and entropic FGW, with \alpha swept in the POT convention (def. 5.3) and \varepsilon scaled down; COOT on the attribute matrices (def. 5.4); several initializations (non-convexity). Baselines: attribute-only OT (\alpha = 0) and nearest-neighbour matching.
    • Split: graph and attribute construction; solvers and sweeps; evaluation, plus an entity-disambiguation step for GraphRAG (Graph ML, ch. 10).
    • Success criterion: Hits@1 and Hits@10 against the gold alignment, with intervals over samples; an \alpha-curve whose best value is explained; runtime against the number of entities.
    • Deliverables: code, joint report, group talk; ch. 3, ch. 5 and ch. 7. It is the alignment option of the Y1.1 GraphRAG project and the alignment baseline of Y2.1.
  3. [Group of 3 · ≈ 30 h each] An OT evaluation suite for generative models: FID, Sinkhorn divergence, sliced Wasserstein and FGW. Do these metrics rank generators the same way, and how do their bias and variance depend on the sample size and the dimension (th. 4.5)?
    • Data: CIFAR-10 test images under a ladder of corruptions (noise, blur, black rectangles, as in Heusel et al., 2017), plus samples of the public DDPM checkpoint google/ddpm-cifar10-32 on a free GPU tier; for graphs, the generators of Graph ML, ch. 9 on community graphs or QM9.
    • Work: FID from the Bures formula (th. 2.7) on Inception features, checked against clean-fid (Parmar, Zhang and Zhu, 2022); S_\varepsilon and sliced W_2 on the same features; an FGW distance between sets of graphs (def. 5.3); bias and variance against n and against the feature dimension (PCA).
    • Split: image metrics; graph metrics; the statistical study.
    • Success criterion: the Bures FID equal to clean-fid on identical features; rank correlations between the metrics over the ladder; bias curves compared with th. 4.5 and with the 1/n bias of FID (Chong and Forsyth, 2020); one disagreement between metrics explained.
    • Deliverables: code, joint report, group talk; ch. 2–5. It reuses the evaluation chapter of Multimodal Generative AI and prepares the evaluation of graph generators in Graph Generative Models.

Written exam (proposal)

Two hours, one handwritten A4 sheet allowed, no calculator needed; four questions. The official grade has no written exam, so this proposal is for self-assessment.

  1. Question (4 points). State Monge’s problem and Kantorovich’s relaxation. Explain with \mu = \delta_0 and \nu = \tfrac12\delta_{-1} + \tfrac12\delta_{1} why the relaxation is needed, and state when an optimal plan is induced by a map.
    • Expected: Monge minimizes \int c(x, T(x))\,d\mu under T_\#\mu = \nu; Kantorovich minimizes \int c\,d\gamma over the couplings \Pi(\mu, \nu), a linear program in the discrete case (ch. 1).
    • Any map gives T_\#\delta_0 = \delta_{T(0)}, a single atom, so no map reaches \nu; the plan \tfrac12\delta_{(0,-1)} + \tfrac12\delta_{(0,1)} splits the mass (example 1.2).
    • Brenier (cor. 2.3): if \mu \ll \mathrm{Leb} and the cost is quadratic, the optimal plan is unique and induced by T = \nabla\varphi with \varphi convex.
  2. Question (6 points). Three closed-form computations; give exact values.
      1. \mu uniform on \{0, 1, 3\} and \nu uniform on \{1, 2, 5\}: compute W_1(\mu, \nu) and W_2^2(\mu, \nu).
      1. W_2^2 between \mathcal{N}(0, \Sigma_1) and \mathcal{N}(e_1, \Sigma_2), with \Sigma_1 = \mathrm{diag}(4, 1) and \Sigma_2 = \mathrm{diag}(1, 4).
      1. The Wasserstein barycenter of \mathcal{N}(0, 1) and \mathcal{N}(0, 9) with weights 1/4 and 3/4.
    • Expected: (a) in 1D the optimal plan matches the sorted points (prop. 2.6): 0 \to 1, 1 \to 2, 3 \to 5, so W_1 = 4/3 and W_2^2 = (1 + 1 + 4)/3 = 2.
      1. The covariances commute, so the trace term of th. 2.7 is the sum of the squared differences of the standard deviations, (2-1)^2 + (1-2)^2 = 2; adding \|e_1\|^2 = 1 gives W_2^2 = 3.
      1. Corollary 2.8 gives \mathcal{N}(0, \sigma^2) with \sigma = \tfrac14 \cdot 1 + \tfrac34 \cdot 3 = 2.5: variance 6.25, not the mean of the variances, 7.
  3. Question (5 points). Two short proofs.
      1. Show that W_1(\mu, \nu) \leq W_2(\mu, \nu).
      1. Let \Gamma \in U(a, b) couple the points x_i and z_j, with barycentric projection \hat T (ch. 4, OTDA step 3) and costs C_{ij} = \|x_i - z_j\|^2. Prove that \sum_i a_i\, \|x_i - \hat T(x_i)\|^2 \;\leq\; \langle C, \Gamma\rangle , and give an example where \hat T does not push a onto b.
    • Expected: (a) take an optimal plan \gamma for W_2; it is admissible for W_1, and Cauchy–Schwarz gives W_1 \leq \int d\,d\gamma \leq \Big(\int d^2\,d\gamma\Big)^{1/2} = W_2 .
      1. \hat T(x_i) is the mean of z_j under the conditional weights \Gamma_{ij}/a_i, and \|x_i - \cdot\|^2 is convex.
    • Jensen bounds \|x_i - \hat T(x_i)\|^2 by the conditional mean of \|x_i - z_j\|^2; multiply by a_i and sum over i.
    • Example: \mu = \delta_0 and \nu = \tfrac12\delta_{-1} + \tfrac12\delta_1 (example 1.2). The only plan splits the mass, \hat T(0) = 0, and \hat T pushes \mu onto \delta_0 \neq \nu: the barycentric map of OTDA only approximates a Monge map.
  4. Question (5 points). A score R is uniform on [0, 1] in group s = 0 and uniform on [0, 1/2] in group s = 1; the groups have equal sizes, and the decision is R > 1/2.
      1. Give the demographic-parity gap. (b) Give the barycentric quantile function of th. 6.2 and the gap after full repair. (c) Same for the partial repair with \lambda = 1/2, and give the W_2 distance between the two repaired score laws.
    • Expected: (a) positive rates 1/2 and 0, so the gap is 1/2.
      1. Q_0(u) = u and Q_1(u) = u/2, so Q^\star(u) = \tfrac34 u: both groups become uniform on [0, 3/4], the positive rate is 1/3 in each, and the gap is 0 (proof of th. 6.2).
      1. The repaired quantile functions are \tfrac78 u and \tfrac58 u: positive rates 3/7 and 1/5, gap 8/35 \approx 0.23.
    • They differ by u/4, so W_2 = \sqrt{1/48} \approx 0.144: half of the initial \sqrt{1/12} \approx 0.289, as exercise 9 predicts.

Grading rubric (proposal)

Criterion Weight What earns the marks
Understanding of the paper 20 % the paper’s question, assumptions and main result restated in the notation of the course, with the chapter that proves or uses each tool
Correct implementation 25 % code validated against POT or a reference implementation with a stated tolerance; the limiting cases checked (\lambda = 0, \alpha \in \{0, 1\}, isometric inputs, \varepsilon \to 0)
Experimental protocol 20 % held-out data, several seeds or initializations (GW is non-convex), uncertainty reported, \varepsilon, \alpha and \lambda swept without tuning on the test set
Analysis tied to the theory 20 % each result, failures included, explained by a statement of the course: rates of th. 4.5, entropic bias, invariance of th. 5.2, incompatibility results of ch. 6
Oral presentation 15 % the official modality: a group talk on time, each member presenting a part, figures that answer the question, honest limits

References