Skip to main content
NIHPA Author Manuscripts logoLink to NIHPA Author Manuscripts
. Author manuscript; available in PMC: 2023 Nov 15.
Published in final edited form as: Proc AAAI Conf Artif Intell. 2022 Jun;36(9):10119–10128. doi: 10.1609/aaai.v36i9.21251

Efficient Discrete Optimal Transport Algorithm by Accelerated Gradient Descent

Dongsheng An 1, Na Lei 2,*, Xiaoyin Xu 3, Xianfeng Gu 1
PMCID: PMC10652357  NIHMSID: NIHMS1943443  PMID: 37974660

Abstract

Optimal transport (OT) plays an essential role in various areas like machine learning and deep learning. However, computing discrete OT for large scale problems with adequate accuracy and efficiency is highly challenging. Recently, methods based on the Sinkhorn algorithm add an entropy regularizer to the prime problem and obtain a trade off between efficiency and accuracy. In this paper, we propose a novel algorithm based on Nesterov’s smoothing technique to further improve the efficiency and accuracy in computing OT. Basically, the non-smooth c-transform of the Kantorovich potential is approximated by the smooth Log-Sum-Exp function, which smooths the original non-smooth Kantorovich dual functional. The smooth Kantorovich functional can be efficiently optimized by a fast proximal gradient method, the fast iterative shrinkage thresholding algorithm (FISTA). Theoretically, the computational complexity of the proposed method is given by O(n52lognϵ), which is lower than current estimation of the Sinkhorn algorithm. Experimentally, compared with the Sinkhorn algorithm, our results demonstrate that the proposed method achieves faster convergence and better accuracy with the same parameter.

Introduction

Optimal transport (OT) is a powerful tool to compute the Wasserstein distance between probability measures and widely used to model various natural and social phenomena, including economics (Galichon 2016), optics (Glimm and Oliker 2003), biology (Schiebinger et al. 2019), physics (Jordan, Kinderlehrer, and Otto 1998) and in other scientific fields. Recently, OT has been successfully applied in machine learning and statistics, such as parameter estimation in Bayesian non-parametric models (Nguyen 2013), computer vision (Arjovsky, Chintala, and Bottou 2017; Courty et al. 2017; Tolstikhin et al. 2018; An et al. 2020; Lei et al. 2020), and natural language processing (Kusner et al. 2015; Yurochkin et al. 2019). In these areas, the complex probability measures are approximated by summations of Dirac measures supported on the samples. To obtain the Wasserstein distance between the empirical distributions, we then solve the discrete OT problems.

Discrete Optimal Transport

In discrete OT problem, where both the source and target measures are discrete, the Kantorovich functional becomes a convex function defined on a convex domain. Due to the lack of smoothness, conventional gradient descend method can not be applied directly. Instead, it can be optimized with the sub-differential method (Nesterov 2005), in which the gradient is replaced by the sub-differential. To achieve an approximation error less than ε, the sub-differential method requires O(1ε2) iterations. Recently, several approximation methods have been proposed to improve the computational efficiency. In these methods (Cuturi 2013; Benamou et al. 2015; Altschuler, Niles-Weed, and Rigollet 2017), a strongly convex entropy function is added to the prime Kantorovich problem and thus the regularized problem can be efficiently solved by the Sinkhorn algorithm. More detailed analysis shows that the computational complexity of the Sinkhorn algorithm is O~(n2ε2) (Dvurechensky, Gasnikov, and Kroshnin 2018) by setting λ=ϵ4logn. Also, a series of primal-dual algorithms are proposed, including the APDAGD (adaptive primal-dual accelerated gradient descent) algorithm (Dvurechensky, Gasnikov, and Kroshnin 2018) with computational complexity O~(n2.5ϵ), the APDAMD (adaptive primal-dual accelerated mirror descent) algorithm (Lin, Ho, and Jordan 2019) with O~(n2rϵ) where r is a complex constant of the Bregman divergence, and the APDRCD (accelerated primal-dual randomized coordinate descent) algorithm (Guo, Ho, and Jordan 2020) with O~(n2.5ϵ). But all of the three methods need to build a matrix with space complexity O(n3), making them difficult to compute when n is large.

Our Method

In this work, instead of starting from the prime Kantorovich problem like the Sinkhorn based methods, we directly deal with the dual Kantorovich problem. The key idea is to approximate the original non-smooth c-transform of the Kantorovich potential by Nesterov’s smoothing technique. Specifically, we approximate the max function by the Log-Sum-Exp function, which has also been used in (Schmitzer 2019; Peyré and Cuturi 2018), such that the original non-smooth Kantorovich functional is converted to an unconstrained (n1)-dimensional smooth convex energy. By using the Fast Proximal Gradient Method named FISTA (Beck and Teboulle 2009), we can quickly optimize the smoothed energy to get a precise estimate of the OT cost. In theory, the method can achieve the approximate error ε with the space complexity O(n2) and computational complexity O(n2.5lognε). Additionally, we show that the induced approximate OT plan by our algorithm is equivalent to that of the Sinkhorn algorithm. The contributions of our work are as follows.

  • We convert the dual Kantorovich problem to an unconstrained smooth convex optimization problem by approximating the non-smooth c-transform of the Kantorovich potential with Nesterov’s smoothing idea.

  • The smoothed Kantorovich functional can be efficiently solved by the FISTA algorithm with computational complexity O~(n2.5ε). At the same time, the computational complexity of the Kantorovich functional itself is given by O~(n2.5ε).

  • The experiments demonstrate that compared with the Sinkhorn algorithm, the proposed method achieves faster convergence and better accuracy with the same parameter λ.

Notation

In this work, R0 represents the non negative real numbers, 0 and 1 represents the all-zeros and all-ones vectors of appropriate dimension. The set of integers {1,2,,n} is denoted as [n]. And 1 and are the 1 and 2 norms, v1=ivi and v=ivi2, respectively. R(C) is the range of the cost matrix C=(cij), namely CmaxCmin, where Cmax and Cmin represent the maximum and minimum of the elements of C with cij>0. We use νmin to denote the minimal element of ν and to denote element wise division.

Related Work

Optimal transport plays an important role in various kinds of fields, and there is a huge literature in this area. Here we mainly focus on the most related works. For detailed overview, we refer readers to (Peyré and Cuturi 2018).

When both the source and target measures are discrete, the OT problem can be treated as a standard linear programming (LP) task and solved by interior-point method with computational complexity O~(n52) (Lee and Sidford 2014). But this method requires a practical solver of the Laplacian linear system, which is not currently available for large dataset. Another interior-point based method to solve the OT problem is proposed by Pele and Werman (Pele and Werman 2009) with complexity O~(n3). Generally speaking, it is unrealistic to solve the large scale OT problem with the traditional LP solvers.

The prevalent way to compute the OT cost between two discrete measures involves adding a strongly convex entropy function to the prime Kantorovich problem (Cuturi 2013; Benamou et al. 2015). Most of the current solutions for the discrete OT problem follow this strategy. Genevay et al. (Genevay et al. 2016) extend the algorithm in its dual form and solve it by stochastic average gradient method. The Greenkhorn algorithm (Altschuler, Niles-Weed, and Rigollet 2017; Abid and Gower 2018; Chakrabarty and Khanna 2021) is a greedy version of the Sinkhorn algorithm. Specifically, Altschuler et al. (Altschuler, Niles-Weed, and Rigollet 2017) show that the complexity of their algorithm is O~(n2ϵ3). Later, Dvurechensky et al. (Dvurechensky, Gasnikov, and Kroshnin 2018) improve the complexity bound of the Sinkhorn algorithm to O~(n2ϵ2), and propose an APDAGD method with complexity O~(min{n94ϵ,n2ϵ2}). Jambulapati et al. (Jambulapati, Sidford, and Tian 2019) introduce a parallelelizable algorithm to compute the OT problem with complexity O~(n2Cmaxϵ). Through screening the negligible components by directly setting them at that value before entering the Sinkhorn problem, the screenkhorn (Alaya et al. 2019) method solves a smaller Sinkhorn problem and improves the computation efficiency. Based on a primal-dual formulation and a tight upper bound for the dual solution, Lin et al. (Lin, Ho, and Jordan 2019) improve the complexity bound of the Greenkhorn algorithm to O~(n2ϵ2), and propose the APDAMD algorithm, whose complexity bound is proven to be O~(n2rϵ), where r(0,n] refers to some constants in the Bregman divergence. Recently, a practically more efficient method called APDRCD (Guo, Ho, and Jordan 2020) is proposed with complexity O~(n2.5ϵ). But all these three primal-dual based methods need to build a matrix with space complexity O(n3), which makes them impractical when n is large. By utilizing Newton-type information, Blanchet et al. (Blanchet et al. 2018) and Quanrud (Quanrud 2018) propose algorithms with complexity O~(n2ϵ). However, the Newton-based methods only give the theoretical upper bound and provide no practical algorithms.

Besides the entropy regularizer based methods, Blondel et al. (Blondel, Seguy, and Rolet 2018) use the squared 2-norm and group LASSO (least absolute shrinkage and selection operator) to regularize the prime Kantorovich problem and then use the quasi-Newton method to accelerate the algorithm. Xie et al. (Xie et al. 2019b) develop an Inexact Proximal point method for exact optimal transport. By utilizing the structure of the cost function, Gerber and Maggioni (Gerber and Maggioni 2017) optimize the transport plan from coarse to fine. Meng et al. (Meng et al. 2019) propose the projection pursuit Monge map, which accelerates the computation of the original sliced OT problem. Xie et al. (Xie et al. 2019a) also use the generative learning based method to model the optimal transport. But the theoretical analysis of these algorithms is still nascent.

In this work, we introduce a method based on Nesterov’s smoothing technique, which is applied to the dual Kantorovich problem with computational complexity O(n2.5lognε) (or equivalently O~(n2.5ε) and approximation error bound 2λlogn.

Optimal Transport Theory

In this section, we introduce some basic concepts and theorems in the classical optimal transport theory, focusing on Kantorovich’s approach and its generalization to the discrete settings via c-transform. The details can be found in Villani’s book (Villani 2008).

Optimal Transport Problem

Suppose XRd, YRd are two subsets of the Euclidean space Rd,μ,ν are two probability measures defined on X and Y with equal total measure, μ(X)=ν(Y).

Kantorovich’s Approach

Depending on the cost functions and the measures, the OT map between (X,μ) and (Y,ν) may not exist. Thus, Kantorovich relaxed the transport maps to transport plans, and defined joint probability measure π:X×YR0, such that the marginal probability of π equals to μ and ν, respectively. Formally, let the projection maps be ρx(x,y)=x, ρy(x,y)=y, then we define

π(μ,ν){P:X×YR0:(ρx)#P=μ,(ρy)#P=ν}. (1)

Problem 1 (Kantorovich Problem). Given the transport cost function X×YR, find the joint probability measure P:X×YR that minimizes the total transport cost

Mc(μ,ν)=minPπ(μ,ν)X×Yc(x,y)dP(x,y) (2)

Problem 2 (Dual Kantorovich Problem). Given two probability measures μ and ν supported on X and Y, respectively, and the transport cost function c:X×YR, the Kantorovich problem is equivalent to maximizing the following Kantorovich functional:

Mc(μ,ν)=max{Xϕdμ+Yψdν} (3)

where ϕL1(X,μ) and ψL1(Y,ν) are called Kantorovich potentials and ϕ(x)+ψ(y)c(x,y). The above problem can be reformulated as the following minimization form with the same constraints:

Mc(μ,ν)=min{XϕdμYψdν} (4)

Definition 3 (c-transform). Let ϕL1(X,μ) and ψL1(Y,ν), we define

ϕ(x)=ψc(x)=supyYψ(y)c(x,y).

With c-transform, Eqn. (4) is equivalent to solving the following optimization problem:

Mc(μ,ν)=min{Xψc(x)dμ(x)Yψ(y)dν(y)} (5)

where ψL1(Y,ν). When μ=i=1mμiδ(xxi) and ν=j=1nνjδ(yyj), ψ=(ψ1,ψ2,,ψn)T, Eqn. (5) gives the unconstrained convex optimization problem:

Mc(μ,ν)=minψE(ψ)=minψ{i=1mμiψc(xi)j=1nνjψj} (6)

where the c-transform of ψ is given by:

ψc(xi)=maxj{ψjcij} (7)

where cij=c(xi,yj). Suppose ψ is the solution to Eqn. (6), then it has the following properties:

  1. If the cost function is c^(x,y)=c(x,y)k, where k is a constant, the corresponding optimal solution is ψ^, then ψ^=ψ. At the same time, we have Mc(μ,ν)=Mc^(μ,ν)+k.

  2. ψ+k1 is also an optimal solution for Eqn. (6).

In order to make the solution unique, we add a constraint ψH using the indicator function IH, where H={ψj=1nψj=0}, and modify the Kantorovich functional E(ψ) in Eqn. (6) as:

E~(ψ)=E(ψ)+IH(ψ),IH(ψ)={0ψHψH} (8)

Then solving Eqn. (6) is equivalent to finding the solution to:

Mc(μ,ν)=minψE~(ψ)=minψ{i=1mμiψc(xi)j=1nνjψj+IH(ψ)} (9)

which is essentially an (n1)-dimensional unconstrained convex problem. According to the definition of c-transform in 7), ψc is non-smooth with respect to ψ.

Nesterov’s Smoothing of Kantorovich functional

Following Nesterov’s original strategy (Nesterov 2005), which has also been applied in the OT field (Peyré and Cuturi 2018; Schmitzer 2019), we smooth the non-smooth discrete Kantorovich functional E(ψ). We approximate ψc(x) with the Log-Sum-Exp function to get the smooth Kantorovich functional Eλ(ψ). Then through the FISTA algorithm (Beck and Teboulle 2009), we can easily induce that the computation complexity of our algorithm is O(n2.5lognε), with E~(ψt)E~(ψ)ϵ. By abuse of notation, in the following we call both E(ψ) and E~(ψ) the Kantorovich functional and both Eλ(ψ) and E~λ(ψ) the smooth Kantorovich functional.

Definition 4 ((α,β)-smoothable). A convex function f is called (α,β)-smoothable if, for any λ>0, a a convex function fλ such that

fλ(x)f(x)fλ(x)+βλfλ(y)fλ(x)+fλ(x),yx+α2λ(yx)T2fλ(x)(yx)

Here fλ is called a 1λ-smooth approximation of f with parameters (α,β).

In the above definition, the parameter λ defines a trade-off between the approximation accuracy and the smoothness, where the smaller the λ, the better approximation and the less smoothness we obtain.

Lemma 5 (Nesterov’s Smoothing). Given f:RnR, f(x)=max{xj:j=1,,n}, for any λ>0, we have its 1λ-smooth approximation with parameters (1,logn)

fλ(x)=λlog(j=1nexjλ)λlogn, (10)

Proof. We have xRn,

fλ(x)λlog(nmaxjexjλ)λlog(n)=f(x)f(x)=λlogmaxjexjλ<λlogj=1nexjλ=fλ(x)+λlogn

Furthermore, it is easy to prove that fλ(x) is 1λ-smooth. Therefore, fλ(x) is an approximation of f(x) with parameters (1,logn).

Recalling the definition of c-transform of the Kantorovich potential in Eqn. (7), we obtain the Nesterov’s smoothing of ψc by applying Eqn. (10)

ψλc=λlog(j=1ne(ψjcij)λ)λlogn. (11)

We use ψλc to replace ψc in Eqn. (9) to approximate the Kantorovich functional. Then the Nesterov’s smoothing of the Kantorovich functional becomes

Eλ(ψ)=λi=1mμilog(j=1ne(ψjcij)λ)j=1nνjψjλlogn (12)

and its gradient is given by

Eλψj=i=1mμie(ψjcij)λk=1ne(ψkcik)λνj,j[n] (13)

Furthermore, we can directly compute the Hessian matrix of Eλ(ψ). Let Kij=ecijλ and vj=eψjλ, and set Eλiλlogj=1nKijvj, i[m]. Direct computation gives the following gradient and Hessian matrix:

Eλ=diag(v)KT(μKv)ν2Eλ=i=1mμi2Eλi,2Eλi=1λ(11TViΛi1(1TVi)2ViViT) (14)

where Vi=(Ki1v1,Ki2v2,,Kinvn)T, and Λi=diag(Ki1v1,Ki2v2,,Kinvn). By the Hessian matrix, we can show that Eλ is a smooth approximation of E.

Lemma 6. Eλ(ψ) is a 1λ-smooth approximation of E(ψ) with parameters (1,logn).

Proof. From Eqn. (14), we see 2Eλi has K={k1:kR} as its null space. In the orthogonal complementary space of K, 2Eλi is diagonal dominant, therefore strictly positive definite.

Weyl’s inequality (Horn and Johnson 1991) states that the eigen value of A=B+C is no greater than the maximal eigenvalue of B minus the minimal eigenvalue of C, where B is an exact matrix and C is a perturbation matrix. Hence the maximal eigenvalue of 2Eλi, denoted as σi, has an upper bound,

0σi1λ11TVimaxj{Kijvj}1λ.

Thus the maximal eigenvalue of 2Eλ(ψ) is no greater than i=1nμiσi1λ. It is easy to find that Eλ(ψ)E(ψ)Eλ(ψ)+λlogn. Thus, Eλ(ψ) is a 1λ-smooth approximation of E(ψ) with parameters (1,logn).

Lemma 7. Suppose Eλ(ψ) is the 1λ-smooth approximation of E(ψ) with parameters 1,logn, ψλ is the optimizer of Eλ(ψ), then the approximate OT plan is unique and given by

(Pλ)ij=μie((ψλ)jcij)λk=1ne((ψλ)kcik)λ=μiKijvjKiv (15)

where Ki is the ith row of K and v=eψλλ.

Proof. By the gradient formula Eqn. (13) and the optimizer ψλ, we have

Eλ(ψ)ψj=i=1m(Pλ)ijνj=0j=1,,n.

On the other hand, by the definition of Pλ, we have

j=1n(Pλ)ij=μi,i=1,,m,

Combing the above two equations, we obtain that Pλπ(μ,ν) and it is the approximate OT plan.

Similar to the discrete Kantorovich functional in Eqn. (6), the optimizer of the smooth Kantorovich functional in Eqn. (12) is also not unique: given an optimizer ψλ, then ψλ+k1, kR is also an optimizer. We can eliminate the ambiguity by adding the indicator function as Eqn. (8), E~λ(ψ)=Eλ(ψ)+IH(ψ),

E~λ(ψ)=λi=1mμilog(j=1ne(ψjcij)λ)j=1nνjψjλlogn+IH(ψ) (16)

This energy can be optimized effectively through the following FISTA iterations (Beck and Teboulle 2009).

zt+1=ΠηtIH(ψtηtEλ(ψt))ψt+1=zt+1+θt1θt+1(zt+1zt) (17)

with initial conditions ψ0=v0=0, θ0=1, ηt=λ and θt+1=12(1+1+4θt2). Here ΠηtIH(z)=z1nj=1nzj is the projection of z to H (the proximal function of IH(x) (Parikh and Boyd 2014). Similar to the Sinkhorn’s algorithm, this algorithm can be parallelized, since all the operations are row based.

Theorem 8. Given the cost matrix C=(cij), the source measure μR+m and target measure νR+n with i=1mμi=j=1nνj=1, ψ is the optimizer of the discrete dual Kantorovich functional E~(ψ), and ψλ is the optimizer of the smooth Kantorovich functional E~λ(ψ). Then the approximation error is

E~(ψ)E~λ(ψλ)2λlogn

Proof. Assume ψ and ψλ are the minimizers of E(ψ) and Eλ(ψ) respectively. Then by the inequality in Eqn. (10)

Eλ(ψ)E(ψ)E(ψλ)Eλ(ψλ)+λlognEλ(ψλ)Eλ(ψ)E(ψ)Eλ(ψ)+λlogn

This shows Eλ(ψ)Eλ(ψλ)λlogn. Removing the indicator functions, we can get

E~(ψ)E~λ(ψλ)=E(ψ)Eλ(ψλ)E(ψ)Eλ(ψ)+Eλ(ψ)Eλ(ψλ)2λlogn

This also shows that E(ψλ) converges quickly to E(ψ) as the decrease of λ. The convergence analysis of FISTA is given as follows:

Theorem 9 (Thm 4.4 of (Beck and Teboulle 2009)). Assume (1)g(x) is convex and differentiable with dom(g)=Rn, g is Lipschitz continuous with Lipschitz constant L>0; and (2)h(x) is convex and its proximal function can be evaluated. Then from the minimization of f(x)=g(x)+h(x) by FISTA with fixed step size ηt=1L, we can get

f(xt)f(x)2L(t+1)2x0x2 (18)

Corollary 10. Suppose λ is fixed and ψ0=0, then for any t2ψλ2λε, we have

E~λ(ψt)E~λ(ψλ)ε, (19)

where ψλ is the optimizer of E~λ(ψ).

Proof. Under the settings of the smoothed Kantorovich problem Eqn. (12), Eλ(ψ) is convex and differentiable with 2Eλ(ψ)¯1λI, IH(ψ) is convex and its proximal function is given by ΠH(v). Thus, directly applying Thm. 9 and setting L=1λ, we can get E~λ(ψt)E~λ(ψλ)2λ(t+1)2ψλψ02. Set ψ0=0 and 2λ(t+1)2ψλ2ε, then we get that, when t2ψλ2λε, we have E~λ(ψt)E~λ(ψλ)ε.

With the above analysis of the convergence of the smooth Kantorovich functional E~λ(ψt), in the following we give the convergence analysis of the original Kantorovich functional E~(ψt) in Eqn. (9), where ψt is obtained by FISTA.

Theorem 11. If λ=ε2logn, then for any t8C¯2nlognϵ, with C¯=Cmaxλlogνmin, we have

E~(ψt)E~(ψ)<ε, (20)

where ψt is the solver of E~λ(ψ) after t steps in the iterations in Alg. 1, and ψ is the optimizer of E~(ψ). Then the total computational complexity is O(n2.5lognε).

Algorithm 1: Accelerated gradient descent for OT
1:Input:The cost matrixC=(cij),the corresponding sourceweightsμand target weightsν,the approximate parameterλ,and the step lengthη.2:Output:The smoothed Kantorovich functionalψλ.3:Initializeψ=(ψ1,ψ2,,ψn)(0,0,,0).4:Initializez(0,0,,0).5:InitializeK=eCλ,θ0=16:repeat7:vt=eψtλ.8:Eλ(ψt)=diag(v)KT(μKv)ν.9:zt+1=ψtηEλ(ψt)10:zt+1=zt+1mean(zt+1).11:ψt+1=zt+1+θt1θt+1(zt+1zt).12:θt+1=12(1+1+4θt2).13:t=t+114:untilConverge15:The OT costE(ψt)=i+1mμiψc(xi)j=1nψjtνj.

Proof. We set the initial condition ψ0=0. For any given ε>0, we choose iteration step t, such that 2λ(t+1)2ψλ2ε2, t8ψλ2lognϵ, where ψλ is the optimizer of E~λ(ψ). By theorem 9, we have

E~λ(ψt)E~(ψ)E~λ(ψt)E~λ(ψ)E~λ(ψt)E~λ(ψλ)2λ(t+1)2ψλ2ε2

By Eqn. (16), we have

E~(ψt)E~(ψ)=E(ψt)+IH(ψt)E(ψ)IH(ψ)=(E(ψt)Eλ(ψt))+(Eλ(ψt)+IH(ψt))(E(ψ)+IH(ψ))E(ψt)Eλ(ψt)+(E~λ(ψt)E~(ψ))λlogn+ε2=ε

Next we show that ψλ2nC¯2 by proving (ψλ)jC¯j[n]. According to Eq. (15),

νj=i=1mμie((ψλ)jcij)λk=1ne((ψλ)kcik)λ=i=1mμie(ψλ)jλk=1ne(ψλ)kλe(cijcik)λ (21)

Assume (ψλ)max is the maximal element of ψλ, we have k=1ne(ψλ)kλe(cijcik)λe(ψλ)maxλeCmaxλ, where Cmax is the maximal element of the matrix C. Thus,

νji=1nμie(ψλ)jλe(ψλ)maxλeCmaxλ=e(ψλ)jλe(ψλ)maxλeCmaxλ

Then, (ψλ)max(ψλ)j+Cmaxλlogvj and

(ψλ)max1nj=1n{(ψλ)j+Cmaxλlogνj}Cmaxλlogμmin (22)

According to the inequality of arithmetic and geometric means, we have k=1ne(ψλ)kλne1n(k=1n(ψλ)kλ)=n. Thus, νje(ψλ)jλneCmaxλ.

(ψλ)jλlognCmax+λlogνjλlogνminCmax (23)

Combine Eqn. (22) and (23), we have (ψλ)jCmaxλlogνmin=C¯. Hence, we obtain that when t8C¯2nlognϵ,E~(ψt)E~(ψ)<ε.

For each iteration in Eqn. (17), we need O(n2) times of operations, thus total the computational complexity of the proposed method is O(n2.5lognε).

Relationship with Softmax

If there exists an OT map from μ to ν, then each sample xi of the source distribution is classified into the corresponding yj=T(xi). If there does not exist an OT map, we can only get the OT plan, which can be treated as a soft classification problem: each weighted sample xi with weight μi will be sent to the corresponding yjs with weight μiPijk=1nPik where Pij>0. Here Pij=μiPijk=1nPik gives the OT plan from the source to the target distribution. The smoothed OT plan given by minimizing the smooth Kantorovich functional can be further treated as a relaxed OT plan. Instead of sending the weights of a specific sample to several target samples, the smooth solver tends to send each source sample to all of the target samples weighted by e(ψjcij)λk=1ne(ψkcik)λ. Sample xj weighted by μi will be sent to yj with weight μie(ψjcij)λk=1ne(ψkcik)λ.

Relationship with entropy regularized OT problem

The Sinkhorn algorithm is deduced from minimizing the entropy regularized OT problem (Cuturi 2013): P,C+λKL(Pμν) with Pπ(μ,ν). Its dual is given by (Genevay et al. 2016):

Wλ(μ,ν)=minψ{λi=1mμilog(j=1nνje(ψjcij)λ)j=1nνjψj+λ} (24)

with gradient Wλψj=i=1mμiνje(ψjcij)λk=1nνke(ψkcik)λνj. With the optimal solver ψ, the approximate OT plan is given by Pij=μiνje(ψjcij)λk=1nνke(ψkcik)λ. We can compare them with our gradient Eqn. (13) and approximated OT plan Eqn. (15) to see the subtle differences. Actually, by setting ψψlogν, the minimizing problem in Eqn. (24) is equivalent to our smoothed semi-discrete problem of Eqn. (16) with a different constant term.

Furthermore, if we set u=(u1,u2,,um)T with ui=μiKiv in Eqn. (15), the computed approximate OT plan can be rewritten as Pλ=diag(u)Kdiag(v), which is the same as the form of the Sinkhorn solution (Cuturi 2013). Since the solution of the Sinkhorn algorithm is unique, we conclude that the induced approximate optimal transport plan Eqn. (15) by our algorithm is equivalent to that of the Sinkhorn.

Experiments

In this section, we investigate the performance of the proposed algorithm under different parameters, and then compare it with the Sinkhorn algorithm (Cuturi 2013). In the following, we first introduce the various settings of the experiments including the parameters, the cost matrix and the evaluation metrics. Then we show the experimental results. All of the codes were written in MATLAB with GPU acceleration, including the proposed method and the Sinkhorn algorithm (Cuturi 2013). The experiments are also conducted on a Windows laptop with Intel Core i7-7700HQ CPU, 16 GB memory and NVIDIA GTX 1060Ti GPU.

Parameters

There are two parameters involved in the proposed algorithm, λ and ηt. The former is used to control the approximate accuracy between the Log-Sum-Exp function and the Kantorovich potential ψc in Eqn. (11), and the latter controls the step size of the FISTA algorithm in Eqn. (17). Basically, smaller λ gives better approximation.

In our experiments, to get λ as small as possible, based on the Property 1 of the Eqn. (6), we set the median of the cost matrix C equal to zero, so that the full range of the exponential of the floating-point numbers can be used, instead of only the negative part1. Thus we set C=CCmax+Cmin2 and call it the translation trick. If the range of C is denoted as R, then the accuracy parameter is set to be λ=RT, where T is a positive constant. For the FISTA algorithm, the ideal step size should be ηt=1σmax, where σmax is the maximal eigenvalue of the Hessian matrix 2E~λ(ψ) in Eqn. (14). By Nesterov smoothing, we know σmax1λ, so we set the step length ηt=ηλ, where η is a constant2. In practice we use (T,η) as control parameters instead of (λ,ηt).

Cost Matrix

In the following experiments, we test the performance of the algorithm with different parameters under different metrics. Specifically, we set μ=i=1mμiδ(xxi), ν=j=1nνjδ(yyj). Note that after the settings of μis and νjs, they are normalized by μi=μik=1mμk and νj=νjk=1nνk. To build the cost matrix, we use the Euclidean distance, squared Euclidean distance, spherical distance, and random cost matrix.

  • For Euclidean distance (ED) and the squared Euclidean distance (SED) experiments, in experiment 1, xis are randomly generated from the Gaussian distribution 𝒩(31d,Id) and yjs are randomly sampled from the uniform distribution Uni([0,1]d)5. Both μi and νj are randomly generated from the uniform distribution Uni([0,1]). Experiment 3 also uses a similar sampling strategy to build the discrete source and target measures. In experiment 2, like (Altschuler, Niles-Weed, and Rigollet 2017), we randomly choose one pair of images from the MNIST dataset (LeCun and Cortes 2010), and then add negligible noise 0.01 to each background pixel with intensity 0. μi and xi (νj and yj) are set to be the value and the coordinate of each pixel in the source (target) image. Then the Euclidean distance and squared Euclidean distance between xi and yj are given by c(xi,yj)=xiyj and c(xi,yj)=xiyj2, respectively.

  • For the spherical distance (SD) experiment, both μj νj are randomly generated from the uniform distribution Uni([0,1]). xis are randomly generated from the Gaussian distribution 𝒩(31d,Id) and yjs are randomly generated from the uniform distribution Uni([0,1]d). Then we normalize xi and yj by xi=xixi2 and yj=yjyj2. As a result, both xis and yjs are located on the sphere. The spherical distance is given by c(xi,yj)=arccos(xi,yj).

  • For the random distance (RD) matrix experiment, both μi and νj are randomly generated from the uniform distribution Uni([0,1]). Also, to build C, we randomly sample cij from the Gaussian distribution 𝒩(0,1), then C is defined as C=CCmin+1.0.

Evaluation Metrics

We use two metrics to evaluate the proposed method: the first one is the transport cost, which is defined by Eqn. (6) and is given by E(ψ); and the second is the L1 distance from the computed transport plan Pλ to the admissible distribution space π(μ,ν) defined in Eqn. (1), and the distance is defined as D(Pλ)=Pλ1μ1+PλT1ν1.

Experiment 1: The influence of different parameters

We test the performance of the proposed algorithm with different parameters under the SED and SD with m=n=100 and d=5, as shown in Fig. 1. The left column shows the results for SED and the right column is the result for SD. The top row illustrates the transport costs over iterations, and the bottom row is the distance D(Pλ).

Figure 1:

Figure 1:

The performance of the proposed algorithm with different parameters.

In the top row of Fig. 1, the black lines give the groundtruth transport costs, which are computed by linear programming. It is obvious that for the same η, by increasing T (decreasing λ, see the different types of the lines with the same color), the approximate accuracy is improved, and the convergence rate is increased; if T (equivalently λ) is fixed, by increasing η (see the different colors of the lines with the same type), we increase the convergence speed.

Experiment 2: Faster Convergence

For the experiments with ED and SED, the distributions come from the MNIST dataset (LeCun and Cortes 2010), as illustrated in the Cost Matrix. For the the experiments with SD and RD, we set m=n=500 and d=5. Then we compare with the Sinkhorn algorithm (Cuturi 2013) with respect to both the convergence rate and the approximation accuracy. We manually set T=500 to get a good estimate of the OT cost, and then adjust η to get the best convergence speed of the proposed algorithm. For the purpose of fair comparison, we use the same cost matrix with the same translation trick and the same λ for the Sinkhorn algorithm, where we treat each update of v as one step. We summarize the results in Fig. 2, where the green curves represent the groundtruth computed by linear programming, the blue curves are for the Sinkhorn algorithm, and the red curves give the results of our method. It is obvious that in all of the four experiments, our method achieves faster convergence than the Sinkhorn algorithm. Note that the computed approximate transport plan of the Sinkhorn algorithm is intrinsically equivalent to our induced transport plan in Eqn. (15).

Figure 2:

Figure 2:

Comparison with the Sinkhorn algorithm (Cuturi 2013) under different cost matrix.

In Tab. 1, we report the running time of our method, Sinkhorn (Cuturi 2013), its variants algorithms, including Greenkhorn (Altschuler, Niles-Weed, and Rigollet 2017) and Screenkhorn (Alaya et al. 2019), and APDAMD (Lin, Ho, and Jordan 2019) for the four experiments shown in Fig. 2 with T=700. The stop condition is set to be E(ψt+1)E(ψt)E(ψt)103. For all of the experiments, we can see that our proposed method achieves the fastest convergence.

Table 1:

Running time (s) of our method, Sinkhorn (Sink) (Cuturi 2013), Greenkhorn (Green) (Altschuler, Niles-Weed, and Rigollet 2017), Screenkhorn (Screen) (Alaya et al. 2019) and APDAMD (Lin, Ho, and Jordan 2019).

Sink Green Screen APDAMD Ours
ED 0.0596 0.0923 0.0541 3.76 0.0404
SED 0.0431 0.0870 0.0328 3.21 0.0197
SD 0.0564 0.0862 0.0400 2.29 0.0142
RD 0.0374 0.0726 0.0313 2.88 0.0227

Experiment 3: Better Accuracy

From Fig. 2, we can observe that E(ψλ) gives a comparable or better approximate of the OT cost than Pλ,C with the same small λ, especially for the Lp cost function c(x,y)=xyp with p>1, see the second column of Fig. 2 for an example of p=2. To achieve ϵ precision, Pλ,C (equivalent to the Sinkhorn result) needs to set λ=ϵ4logn (Dvurechensky, Gasnikov, and Kroshnin 2018), which is smaller than our requirement of λ=ϵ2logn according to Thm. 11. Thus, with the same λ, the results of our algorithm should be more accurate than the Sinkhorn solutions. To verify this point, we give more examples in Tab. 2 with p=1.5, 2, 3 and 4. Here we use the discrete measures similar to the squared Euclidean distance as stated in the Cost Matrix part, and set m=n=500, d=5. From the table, we can see that our method obtains more accurate results than Sinkhorn.

Table 2:

Comparison among the OT cost (GT) by linear programming, the Sinkhorn results (Cuturi 2013) denoted as ’Sink’ and the results of the proposed method denoted as ’Ours’ with T=500 and different p.

p GT Sink Ours Sink-GT Ours-GT
1.5 103.33 103.51 103.27 0.18 0.06
2 281.7 282.5 281.6 0.8 0.1
3 2189.8 2197.1 2187.5 7.3 2.3
4 16951.4 17038.5 16932.0 87.1 19.4

Conclusion

In this paper, we propose a novel algorithm based on Nesterov’s smoothing technique to improve the accuracy for solving the discrete OT problem. The c-transform of the Kantorovich potential is approximated by the smooth Log-Sum-Exp function, and the smoothed Kantorovich functional can be solved by FISTA efficiently. Theoretically, the computational complexity of the proposed method is given by O(n2.5lognε), which is lower than current estimation of the Sinkhorn method. Experimentally, our results demonstrate that the proposed method achieves faster convergence and better accuracy than the Sinkhorn algorithm.

Acknowledgement

An and Gu have been supported by NSF CMMI-1762287, NSF DMS-1737812, and NSF FAIN-2115095; Xu by NIH R21EB029733 and NIH R01LM012434; and Lei by NSFC 61936002, NSFC 61772105 and NSFC 61720106005.

Footnotes

1

For example, if double-precision floating-point format is used in 64-bit processors, the range of the number is about 2.2251e3081.7977e+308 when using MATLAB.

2

For one thing, if λ is relatively large, only with small step size, the algorithm may run out of the precision range of the processor and thus get ’Inf’ or ’NAN’. Thus, η may be far less that 1. For the other thing, we have H1λmaxi(maxiKijvjK1v)1λ, we may also choose η>1 when λ itself is small.

References

  1. Abid BK; and Gower RM 2018. Greedy stochastic algorithms for entropy-regularized optimal transport problems. In AISTATS. [Google Scholar]
  2. Alaya MZ; Berar M; Gasso G; and Rakotomamonjy A 2019. Screening Sinkhorn Algorithm for Regularized Optimal Transport. In Advances in Neural Information Processing Systems 32. [Google Scholar]
  3. Altschuler J; Niles-Weed J; and Rigollet P 2017. Near-linear time approximation algorithms for optimal transport via Sinkhorn iteration. In Advances in Neural Information Processing Systems 30. [Google Scholar]
  4. An D; Guo Y; Lei N; Luo Z; Yau S-T; and Gu X 2020. AE-OT: A new Generative Model based on extended semi-discrete optimal transport. In International Conference on Learning Representations. [Google Scholar]
  5. Arjovsky M; Chintala S; and Bottou L 2017. Wasserstein generative adversarial networks. In ICML, 214–223. [Google Scholar]
  6. Beck A; and Teboulle M 2009. A Fast Iterative Shrinkage-Thresholding Algorithm for Linear Inverse Problems. SIAM Journal on Imaging Sciences, 2(1): 183–202. [Google Scholar]
  7. Benamou J-D; Carlier G; Cuturi M; Nenna L; and Peyré G 2015. Iterative Bregman projections for regularized transportation problems. SIAM Journal on Scientific Computing, 37(2): A1111–A1138. [Google Scholar]
  8. Blanchet J; Jambulapati A; Kent C; and Sidford A 2018. Towards Optimal Running Times for Optimal Transport. In arxiv:1810.07717. [Google Scholar]
  9. Blondel M; Seguy V; and Rolet A 2018. Smooth and Sparse Optimal Transport. In Proceedings of the Twenty-First International Conference on Artificial Intelligence and Statistics, 880–889. [Google Scholar]
  10. Chakrabarty D; and Khanna S 2021. Better and Simpler Error Analysis of the Sinkhorn-Knopp Algorithm for Matrix Scaling. Mathematical Programming, 188(1): 395–407. [Google Scholar]
  11. Courty N; Flamary R; Tuia D; and Rakotomamonjy A 2017. Optimal Transport for Domain Adaptation. IEEE Transactions on Pattern Analysis and Machine Intelligence, 39(9): 1853–1865. [DOI] [PubMed] [Google Scholar]
  12. Cuturi M 2013. Sinkhorn Distances: Lightspeed Computation of Optimal Transportation Distances. In International Conference on Neural Information Processing Systems, volume 26, 2292–2300. [Google Scholar]
  13. Dvurechensky P; Gasnikov A; and Kroshnin A 2018. Computational optimal transport: Complexity by accelerated gradient descent is better than by Sinkhorn’s algorithm. In International Conference on Machine Learning, 1367–1376. [Google Scholar]
  14. Galichon A. 2016. Optimal Transport Methods in Economics. Princeton University Press. [Google Scholar]
  15. Genevay A; Cuturi M; Peyré G; and Bach F 2016. Stochastic optimization for large-scale optimal transport. In Advances in Neural Information Processing Systems, 3440–3448. [Google Scholar]
  16. Gerber S; and Maggioni M 2017. Multiscale Strategies for Computing Optimal Transport. Journal of Machine Learning Research. [Google Scholar]
  17. Glimm T; and Oliker V 2003. Optical design of single reflector systems and the Monge–Kantorovich mass transfer problem. Journal of Mathematical Sciences, 117(3): 4096–4108. [Google Scholar]
  18. Guo W; Ho N; and Jordan M 2020. Fast Algorithms for Computational Optimal Transport and Wasserstein Barycenter. In International Conference on Artificial Intelligence and Statistics (AISTATS), 2088–2097. [Google Scholar]
  19. Horn TA; and Johnson CR 1991. Topics in Matrix Analysis. Cambridge. [Google Scholar]
  20. Jambulapati A; Sidford A; and Tian K 2019. A Direct O~(1ϵ) Iteration Parallel Algorithm for Optimal Transport. In International Conference on Neural Information Processing System. [Google Scholar]
  21. Jordan R; Kinderlehrer D; and Otto F 1998. The variational formulation of the Fokker–Planck equation. SIAM Journal on Mathematical Analysis, 29(1): 1–17. [Google Scholar]
  22. Kusner M; Sun Y; Kolkin N; and Weinberger K 2015. From word embeddings to document distances. In Proceedings of the 32nd International Conference on Machine Learning, 957–966. [Google Scholar]
  23. LeCun Y; and Cortes C 2010. MNIST handwritten digit database. [Google Scholar]
  24. Lee YT; and Sidford A 2014. Path finding methods for linear programming: Solving linear programs in O~(sqrt(rank))iterations and faster algorithms for maximum flow. In 2014 IEEE 55th Annual Symposium on Foundations of Computer Science, 424–433. [Google Scholar]
  25. Lei N; An D; Guo Y; Su K; Liu S; Luo Z; Yau S-T; and Gu X 2020. A Geometric Understanding of Deep Learning. Engineering, 6(3): 361–374. [Google Scholar]
  26. Lin T; Ho N; and Jordan M 2019. On efficient optimal transport: An analysis of greedy and accelerated mirror descent algorithms. In International Conference on Machine Learning, 3982–3991. [Google Scholar]
  27. Meng C; Ke Y; Zhang J; Zhang M; Zhong W; and Ma P 2019. Large-scale optimal transport map estimation using projection pursuit. In Advances in Neural Information Processing Systems 32. [Google Scholar]
  28. Nesterov Y 2005. Smooth minimization of non-smooth functions. Mathematical Programming, 103(1): 127–152. [Google Scholar]
  29. Nguyen X 2013. Convergence of latent mixing measures in finite and infinite mixture models. Ann. Statist, 41: 370–400. [Google Scholar]
  30. Parikh N; and Boyd S 2014. Proximal Algorithms. Foundations and Trends in Optimization. [Google Scholar]
  31. Pele O; and Werman M 2009. Fast and robust earth mover’s distances. In 2009 IEEE 12th International Conference on Computer Vision (ICCV), 460–467. IEEE. [Google Scholar]
  32. Peyré G; and Cuturi M 2018. Computational Optimal Transport. https://arxiv.org/abs/1803.00567. [Google Scholar]
  33. Quanrud K. 2018. Approximating optimal transport with linear programs. In arXiv:1810.05957. [Google Scholar]
  34. Schiebinger G; Shu J; Tabaka M; Cleary B; Subramanian V; Solomon A; Gould J; Liu S; Lin S; Berube P; Lee L; Chen J; Brumbaugh J; Rigollet P; Hochedlinger K; Jaenisch R; Regev A; and Lander E 2019. Optimal-Transport Analysis of Single-Cell Gene Expression Identifies Developmental Trajectories in Reprogramming. Cell, 176(4): 928–943. [DOI] [PMC free article] [PubMed] [Google Scholar]
  35. Schmitzer B 2019. Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems. SIAM Journal on Scientific Computing, 41(3): A1443–A1481. [Google Scholar]
  36. Tolstikhin I; Bousquet O; Gelly S; and Schoelkopf B 2018. Wasserstein Auto-Encoders. In ICLR. [Google Scholar]
  37. Villani C 2008. Optimal transport: old and new, volume 338. Springer Science & Business Media. [Google Scholar]
  38. Xie Y; Chen M; Jiang H; Zhao T; and Zha H 2019a. On Scalable and Efficient Computation of Large Scale Optimal Transport. In Proceedings of the 36th International Conference on Machine Learning, 6882–6892. [Google Scholar]
  39. Xie Y; Wang X; Wang R; and Zha H 2019b. A Fast Proximal Point Method for Computing Wasserstein Distance. In Conference on Uncertainty in Artificial Intelligence, 433–453. [Google Scholar]
  40. Yurochkin M; Claici S; Chien E; Mirzazadeh F; and Solomon JM 2019. Hierarchical Optimal Transport for Document Representation. In Advances in Neural Information Processing Systems 32. [Google Scholar]

RESOURCES