E FFICIENT , S TABLE , AND A NALYTIC D IFFERENTIATION OF THE S INKHORN L OSS
Anonymous authors
Paper under double-blind review
A BSTRACT
Optimal transport and the Wasserstein distance have become indispensable building blocks of modern deep generative models, but their computional costs greatly prohibit their applications in statistical machine learning models.
Recently, the
Sinkhorn loss, as an approximation to the Wasserstein distance, has gained massive popularity, and much work has been done for its theoretical properties.
To embed the Sinkhorn loss into gradient-based learning frameworks, efﬁcient algorithms for both the forward and backward passes of the Sinkhorn loss are required.
In this article, we ﬁrst demonstrate issues of the widely-used Sinkhorn’s algorithm, and show that the L-BFGS algorithm is a potentially better candidate for the forward pass.
Then we derive an analytic form of the derivative of the Sinkhorn loss with respect to the input cost matrix, which results in a very efﬁcient backward algorithm.
We rigorously analyze the convergence and stability properties of the advocated algorithms, and use various numerical experiments to validate the superior performance of the proposed methods.
I NTRODUCTION
Optimal transport (OT, Villani, 2009) is a powerful tool to characterize the transformation of probability distributions, and has become an indispensable building block of generative modeling.
At the core of OT is the Wasserstein distance, which measures the difference between two distributions.
For example, the Wasserstein generative adversarial network (WGAN, Arjovsky et al., 2017) uses the 1-Wasserstein distance as the loss function to minimize the difference between the data distribution and the model distribution, and a huge number of related works emerge afterwards.
Despite the various appealing theoretical properties, one major barrier for the wide applications of
OT is the difﬁcuilty in computing the Wasserstein distance.
For two discrete distributions, OT solves a linear programming problem of nm variables, where n and m are the number of Diracs that deﬁne the two distributions.
As a result, the computational cost of OT quickly becomes formidable, except for some special cases (Peyré et al., 2019).
To resolve this issue, many approximate solutions to OT have been proposed, among which the
Sinkhorn distance, or Sinkhorn loss, has gained massive popularity (Cuturi, 2013).
The Sinkhorn loss can be viewed as an entropic-regularized Wasserstein distance, which adds a smooth penalty term to the original objective function of OT.
The Sinkhorn loss is attractive as its optimization problem can be efﬁciently solved, at least in exact arithmetics, via Sinkhorn’s algorithm (Sinkhorn, 1964; Sinkhorn & Knopp, 1967), which merely involves matrix-vector multiplications and some other minor operations.
Therefore, it is especially suited to modern computing hardware such as the graphics processing units (GPUs).
Many existing works on the Sinkhorn loss focus on its theoretical properties, for example Mena &
Niles-Weed (2019) and Genevay et al.
In this article, we are mostly concerned with the computational aspect.
Since modern deep generative models mostly rely on the gradient-based learning framework, it is crucial to use the Sinkhorn loss with differentiation support.
One simple and natural method to enable Sinkhorn loss in back-propagation is to unroll Sinkhorn’s algorithm, adding every iteration to the auto-differentiation computing graph (Genevay et al., 2018; Cuturi et al., 2019).
However, this approach is typically costly when the number of iterations are large.
Instead, in this article we have derived an analytic expression for the derivative of Sinkhorn loss based on quantities computed from the forward pass, which drastically simpliﬁes the back-propagation of the Sinkhorn loss.
More importantly, one critical pain point of the Sinkhorn loss, though typically ignored in theoretical studies, is that Sinkhorn’s algorithm is numerically unstable (Peyré et al., 2019).
We show in numerical experiments that even for very simple settings, Sinkhorn’s algorithm can quickly lose precision.
Various stabilized versions of Sinkhorn’s algorithm, though showing better numerical stability, still suffer from slow convergence in these cases.
In this article, we have rigorously analyzed the solution to the Sinkhorn optimization problem, and have designed both forward and backward algorithms that are provably efﬁcient and stable.
The highlights of this article are summarized as follows:
• We have derived an analytic expression for the derivative of the Sinkhorn loss, which can be efﬁciently computed in back-propagation.
• We have rigorously analyzed the advocated forward and backward algorithms for the Sinkhorn loss, and show that they have superior efﬁciency and stability properties.
• We have implemented the Sinkhorn loss as an auto-differentiable function in the PyTorch and JAX frameworks, using the analytic derivative obtained in this article.
The code to reproduce the results in this article is available at https://1drv.ms/u/s!
ArsORq8a24WmoFjNQtZYE_BERzDQ .
T HE ( SHARP ) S INKHORN LOSS AS APPROXIMATE OT
Throughout this article we focus on discrete OT problems.
Denote by ∆ n = { w ∈ R n + : w T 1 n = 1 } the n -dimensional probability simplex, and let µ = (cid:80) ni
=1 a i δ x i and ν = (cid:80) mj
=1 b j δ y
j be two discrete probability measures supported on data points { x i } ni =1 and { y j } mj =1 , respectively, where a = ( a 1 , . .
. , a n ) T ∈ ∆ n , b = ( b 1 , . . .
, b m ) T ∈ ∆ m , and δ x is the Dirac at position x .
Deﬁne Π( a, b ) =
{ T ∈ R n × m + : T 1 m = a, T T 1 n = b } , and let M ∈ R n × m be a cost matrix with entries M ij , i = 1 , . . . , n, j = 1 , . . .
, m .
Without loss of generality we assume that n ≥ m , as their roles can be exchanged.
Then OT can be characterized by the following optimization problem,
[Equation]
where (cid:104) A, B (cid:105) = tr( A T B ) .
An optimal solution to (1), denoted as P ∗ , is typically called an optimal transport plan, and can be viewed as a joint distribution whose marginals coincide with µ and ν .
The optimal value W ( M, a, b ) = (cid:104) P ∗ , M (cid:105) is then called the Wasserstein distance between µ and ν if the cost matrix M satisﬁes some suitable conditions (Proposition 2.2 of Peyré et al., 2019).
As is introduced in Section 1, solving the optimization problem (1) can be difﬁcult even for moderate n and m .
One approach to regularizing the optimization problem is to add an entropic penalty term to the objective function, leading to the entropic-regularzied OT problem (Cuturi, 2013):
[Equation]
where h ( T ) =
(cid:80) ni
=1 (cid:80) mj
=1 T ij (1 − log T ij ) is the entropy term.
The new objective function S λ ( T ) is λ − 1 -strongly convex on Π( a, b ) , so (2) has a unique global solution, denoted as T ∗ λ .
In this article,
T ∗ λ is referred to as the Sinkhorn transport plan.
The entropic-regularized Wasserstein distance, also known as the Sinkhorn distance or Sinkhorn loss in the literature (Cuturi, 2013), is then deﬁned as
[Equation]
To simplify the notation, we omit the subscript λ in T ∗ λ hereafter when no confusion is caused.
It is worth noting that in the literature, S λ and ˜ S λ are sometimes referred to as the sharp and regularized Sinkhorn loss, respectively. The following proposition from Luise et al.
(2018) suggests that S λ achieves a faster rate at approximating the Wasserstein distance than ˜ S λ . Due to this reason, in this article we focus on the sharp version, and simply call S λ the Sinkhorn loss for brevity.
Proposition 1 (Luise et al., 2018) .
There exist constants C 1 , C 2 > 0 such that for any λ > 0 , | S λ ( M, a, b ) − W ( M, a, b ) | ≤ C 1 e − λ and | ˜ S λ ( M, a, b ) − W ( M, a, b ) | ≤ C 2 /λ .
The constants Cand C 2 are independent of λ , and depend on µ and ν .
D IFFERENTIATION OF THE S INKHORN LOSS
To use the Sinkhorn loss in deep neural networks or other machine learning tasks, it is also crucial to obtain the derivative of S λ ( M, a, b ) with respect to its input parameters.
Differentiating the Sinkhorn loss typically involves two stages, the forward and backward passes.
In the forward pass, the Sinkhorn loss or the transport plan is computed using some optimization algorithm, and in the backward pass the derivative is computed, using either an analytic expression or the automatic differentiation technique. In this section we analyze both passes in details. Throughout this article we use the following notations. For x, y ∈ R , x ∧ y means min { x, y } .
For a vector v = ( v 1 , . . .
, v k ) T , let v − = ( v − 1 1 , . . .
, v − 1 k ) T , ˜ v = ( v 1 , . . .
, v k − 1 ) T , and denote by diag ( v ) the diagonal matrix formed by v .
Let u
= ( u 1 , . .
. , u l ) T be another vector, and denote by u ⊕ v the l × k matrix with entries ( u i + v j ) .
For a matrix A
= ( a ij ) =
( A 1 , . . . ,
A k ) with column vectors
A 1 , . . . ,
A k , let ˜ A
= ( A 1 , . . .
, A k − 1 ) , and e λ
[ A ] be the matrix with entries e λa ij .
The symbol (cid:12) denotes the elementwise multiplication operator between matrices or vectors.
Finally, we globally deﬁne η ≡ λ − 1 for simplicity. 3. I SSUES OF S INKHORN ’ S ALGORITHM In the existing literature, one commonly-used method for the forward pass of the Sinkhorn loss is Sinkhorn’s algorithm (Sinkhorn, 1964; Sinkhorn & Knopp, 1967).
Unlike the original linear programming problem (1), the solution to the Sinkhorn problem has a special structure.
Cuturi (2013) shows that the optimal solution T ∗ can be expressed as
[Equation]
for some vectors u ∗ and v ∗ , where M e = (cid:0) e − λM ij (cid:1) .
Sinkhorn’s algorithm starts from an initial vector v (0)
∈
R m + , and generates iterates
u ( k ) ∈
R n + and v ( k ) ∈
R m + as follows:
[Equation]
It can be proved that u ( k ) → u ∗ and v ( k ) → v ∗ , and then the Sinkhorn transport plan T ∗ can be recovered by (3).
Sinkhorn’s algorithm is very efﬁcient, as it only involves matrix-vector multiplication and other inexpensive operations.
However, one major issue of Sinkhorn’s algorithm is that the entries of
M e = (cid:0) e − λM ij (cid:1) may easily underﬂow when λ is large, making some elements of the vectors M e v ( k ) and M T e u ( k +1) close to zero.
As a result, some components of u ( k +1) and v ( k +1) would overﬂow.
Therefore, Sinkhorn’s algorithm in its original form is unstable, and in practice the iterations (4) are typically carried out in the logarithmic scale, which we call the Sinkhorn-log algorithm for simplicity.
Besides, there are some other works also attempting to improve the numerical stability of Sinkhorn’s algorithm (Schmitzer, 2019; Cuturi et al., 2022).
Despite the advancements of Sinkhorn’s algorithm, one critical issue observed in practice is that
Sinkhorn-type algorithms may be slow to converge, especially for small regularization parameters.
This would severly slow down the computation, and may even give misleading results when the user sets a moderate limit on the total number of iterations.
Below we show a motivating example to highlight this issue.
Consider a triplet ( M, a, b ) for the Sinkhorn problem, and ﬁx the regularization parameter η to be 0.001, where the detailed setting is provided in Section B.1.
The true T ∗ matrix is visualized in Figure 1, along with the solutions given by various widely-used algorithms, including
Sinkhorn’s algorithm, Sinkhorn-log, the stabilized scaling algorithm (Stabilized, Algorithm 2 of Schmitzer, 2019), and the Greenkhorn algorithm (Altschuler et al., 2017; Lin et al., 2022).
The maximum number of iterations is 10000 for Greenkhorn and 1000 for other algorithms.
In Figure 1, it is clear that the plans given by Sinkhorn’s algorithm and Greenkhorn are farthest to the true value, and Greenkhorn generates NaN values reﬂected by the white stripes in the plot. In contrast, the stable algorithms Sinkhorn-log and Stabilized greatly improve them.
Sinkhorn’s algorithm and Sinkhorn-log are equivalent in exact arithmetics, so their numerical differences highlight the need for numerically stable algorithms.
However, Sinkhorn-log and Stabilized still have visible inconsistencies with the truth even after 1000 iterations. [Figure]
3. T HE ADVOCATED ALTERNATIVE FOR FORWARD PASS
To this end, we advocate an alternative scheme to solve the optimal plan T ∗ , and we show both theoretically and empirically that this method enjoys great efﬁciency and stability.
Consider the dual problem of (2), which has the following form (Proposition 4.4 of Peyré et al., 2019):
[Equation]
Let α ∗ =
( α ∗ 1 , . .
, α ∗ n ) T and β ∗ =
( β ∗ 1 , . .
. , β ∗ m ) T be one optimal solution to (5), and then the
Sinkhorn transport plan T ∗ can be recovered as T ∗ =
e λ [ α ∗ ⊕ β ∗ − M ] .
Remarkably, (5) is an unconstrained convex optimization problem, so a simple gradient ascent method sufﬁces to ﬁnd its optimal solution.
But in practice, quasi-Newton methods such as the limited memory BFGS method (L-BFGS, Liu & Nocedal, 1989) can signiﬁcantly accelerate the convergence.
Using L-BFGS to solve (5) is a known practice (Cuturi & Peyré, 2018; Flamary et al., 2021), but little is known about its stability in solving the regularized OT problem.
We ﬁrst brieﬂy describe the algorithm below, and in Section 4 we rigorously prove that L-BFGS converges fast and generates stable iterates.
It is worth noting we can reduce the number of variables to be optimized in (5) based on the following two ﬁndings.
First, as pointed out by Cuturi et al.
(2019), the variables ( α, β ) have one redundant degree of freedom: if ( α ∗ , β ∗ ) is one solution to (5), then so is ( α ∗ + c 1 n , β ∗ − c 1 m ) for any c .
Therefore, we globally set β m = 0 without loss of generality.
Second, let α ∗ ( β ) = arg max α L ( α, β ) for a given β =
(˜ β T , β m ) T = (˜ β T , 0) T , and deﬁne f ( β ) =
−L ( α ∗ ( β ) , β ) . Then we only need to minimize f ( β ) with ( m − 1) free variables to get β ∗ , and α ∗ can be recovered as α ∗ = α ∗ ( β ∗ ) .
In the appendix we show that α ∗ ( β ) , f ( β ) , and ∇ ˜ β f have simple closed-form expressions:
[Equation]
With f ( β ) and ∇ ˜ β f , the L-BFGS algorithm can be readily used to minimize f ( β ) and obtain β ∗ .
Each gradient evaluation requires O ( mn ) exponentiation operations, which is comparable to Sinkhorn-log. Although exponentiation is more expensive than matrix multiplication as in
Sinkhorn’s algorithm, this extra cost can be greatly remedied by modern hardware such as GPUs. On the other hand, we would show in Section 4 that L-BFGS has a strong guarantee on numerical stability, which is critical for many scientiﬁc computing problems.
For the motivating example in Section 3.1, we demonstrate the advantage of L-BFGS by showing its transport plan in the rightmost plot of Figure 1.
We limit its maximum number of gradient evaluations to 1000, and hence comparable to other methods.
Clearly, the L-BFGS solution is visually identical to the ground truth.
To study the difference between L-BFGS and Sinkhorn’s algorithm in more depth, we compute the objective function value of the dual problem (6) at each iteration for both Sinkhorn-log and L-BFGS.
The results are visualized in Figure 2, with three different η values, η = 0 .
Since each L-BFGS iteration may involve more than one gradient evaluation, for L-BFGS we plot the values against both the outer iteration and gradient evaluation counts.
[Figure] Figure 2 gives a clear clue to the issue of Sinkhorn-log: it has a surprisingly slow convergence speed compared to L-BFGS when η is small.
Theoretically, Sinkhorn algorithms will eventually converge with sufﬁcient iterations, but in practice, a moderate limit on computational budget may prevent them from generating accurate results.
To this end, L-BFGS appears to be a better candidate when one needs a small η for better approximation to the OT problem. In Section B.2 we have designed more experiments to study the forward pass stability and accuracy of different algorithms.
3. T HE ANALYTIC BACKWARD PASS
For the backward pass, one commonly-used method is unrolled Sinkhorn’s algorithm, which is based on the fact that Sinkhorn’s forward pass algorithm is differentiable with respect to a , b , and M .
Therefore, one can use automatic differentiation software to compute the corresponding derivatives in the backward pass.
This method is used in Genevay et al.
(2018) for learning generative models with the Sinkhorn loss, but in practice it may be extremely slow if the forward pass takes a large number of iterations.
To avoid the exessive cost of unrolled algorithms, various implicit differentiation methods have been developed for the Sinkhorn loss (Feydy et al., 2019; Campbell et al., 2020; Xie et al., 2020; Eisenberger et al., 2022), but they still do not provide the most straightforward way to compute the gradient.
To this end, we advocate the use of analytic derivatives of the Sinkhorn loss, which solves the optimization problem (2) in the forward pass, and use the optimal dual variables ( α ∗ , β ∗ ) for the backward pass.
The analytic form for ∇ a,b S λ ( M, a, b ) has been studied in Luise et al.
(2018), and to our best knowledge, few result has been presented for ∇ M S λ ( M, a, b ) .
Our ﬁrst main theorem, given in Theorem 1, ﬁlls this gap and derives the analytic form for ∇ M S λ ( M, a, b ) .
Theorem 1.
For a ﬁxed λ > 0 ,
[Equation]
where T ∗ =
e λ [ α ∗ ⊕ β ∗ − M ] , s u =
a − 1 (cid:12) ( µ r − ˜ T ∗ ˜ s v ) , s v =
(˜ s T v , 0) T , µ r =
( M (cid:12) T ∗ ) 1 m , ˜ µ c = ( ˜ M (cid:12)
˜
T ∗ ) T 1 n , ˜ s v = D − 1 (cid:104) ˜ µ c − ˜ T ∗ T ( a − 1 (cid:12) µ r ) (cid:105) , and D = diag (˜ b ) − ˜ T ∗ T diag ( a − 1 )
˜ T ∗ .
In addition, D is positive deﬁnite, and hence invertible, for any λ > 0 , a ∈ ∆ n , b ∈ ∆ m , and M .
Assuming n ≥ m , the main computational cost is in forming D , which requires O ( m 2 n ) operations for matrix-matrix multiplication, and in computing ˜ s v , which costs O ( m 3 ) operations for solving a positive deﬁnite linear system.
C ONVERGENCE AND STABILITY ANALYSIS
In Sections 3.2 and 3.3, we have introduced the advocated forward and backward algorithms for the Sinkhorn loss, respectively.
In this section, we focus on the theoretical properties of these algorithms, and show that they enjoy provable efﬁciency and stability.
As a ﬁrst step, we consider the target of the optimization problem (6), and show that f ( β ) has a well-behaved minimizer, which does not underﬂow or overﬂow.
Theorem 2.
Denote by f ∗ the minimum value of f ( β ) and β ∗ an optimal solution, and let α ∗ = α ∗ ( β ∗ ) .
Then f ∗ > −∞ , β ∗ is unique, (cid:107) α ∗ (cid:107) < ∞ , and (cid:107) β ∗ (cid:107) < ∞ .
In particular, let I = arg max i T ∗ im , a max = max i a i , and c = log( n/b m ) . Then L α i ≤ L α i ≤ α ∗ i ≤ U α i and
L β j ≤ β ∗ j ≤ U β j ≤ U β j for all i = 1 , . . . , n and j = 1 , . . .
, m , where U
[Equation]
log [Equation] Theorem 2 shows that the optimal dual variables γ ∗ are bounded, and more importantly, the bounds are roughly at the scale of the cost matrix entries M ij and the log-weights log( a i ) and log( b j ) .
Therefore, at least the target of the optimization problem is well-behaved.
Moreover, one useful application of Theorem 2 is to impose a box constraint on the variables, adding further stability to the optimization algorithm.
After verifying the properties of the optimal solution, a more interesting and critical problem is to seek a stable algorithm to approach the optimal solution.
Indeed, in Theorem 3 we prove that the
L-BFGS algorithm for minimizing (6) is one such method.
Theorem 3.
Let { ˜ β
( k ) } be a sequence of iterates generated by the L-BFGS algorithm starting from a ﬁxed initial value ˜ β (0) , and deﬁne β ( k )
=
(˜ β ( k )T , 0) T , T ( k ) =
e λ [ α ∗ ( β ( k ) ) ⊕ β ( k ) − M ] , and f ( k ) =
f ( β ( k ) ) .
Then there exist constants 0 ≤ r < 1 and C 1 , C 2 > 0 such that for each k > 0 :
(a) f ( k ) − f ∗ ≤ r k
( f (0) − f ∗ ) :
= ε ( k ) .
(Linear convergence for the objective value) (b) (cid:107) β
k ) − β ∗ (cid:107) 2 ≤ C 1 ε ( k ) . (Linear convergence for the iterates) (c) T ( k ) 1 m = a , (cid:107)∇ ˜ β f ( β ( k ) ) (cid:107) 2 = (cid:107)
˜ T ( k {+)T 1 n − ˜ b (cid:107) 
+}
≤ C 2 ε ( k ) .
(Exponential decay of the gradient) (d) T ( k ) ij < min { a i , b j + (cid:112) C
ε ( k ) } , 1 ≤ j ≤ m − 1 .
[-(e) max i T ( k ) ij > ( b j − (cid:112) C 
-]overﬂow
(e) max j T ( k ) ij >a i /m , max i T ( k ) ij > ( b j − (cid:112) C 2 ε ( k ) ) /n , 1 ≤ j ≤ m − 1 .
( T ( k ) does not underﬂow
The explicit expressions for the constants C 1 , C 2 , r are given in Section A.
Theorem 3 reveals some important information.
First, both the objective function value and the iterates have linear convergence speed, so the forward pass using L-BFGS takes O (log(1 /ε ))
iterations to obtain an ε -optimal solution.
Second, the marginal error for µ , measured by (cid:107) T ( k ) 1 m − a (cid:107) , is exactly zero due to the partial optimization on α .
The other marginal error (cid:107) ˜ T ( k )T 1 n − ˜ b (cid:107) , which is equal to the gradient norm, is also bounded at any iteration, and decays exponentially fast to zero.
This validates the numerical stability of the L-BFGS algorithm.
Third, the estimated transport plan at any iteration k , T ( k ) , is also bounded and stable.
This result can be compared with the formulation in (3): it is not hard to ﬁnd that u ∗ , v ∗ , and M e , when computed individually, can all be unstable due to the exponentiation operations, especially when η is small.
In contrast, T ∗ and T ( k ) , thanks to the results in Theorem 3, do not suffer from this issue.
We emphasize that Theorem 3 provides novel results that are not direct consequences of the L-BFGS convergence theorem given in Liu & Nocedal (1989). First, classical theorems only guarantee the convergence of objective function values and iterates as in (a) and (b), whereas we provide richer information such as the marginal errors and transport plans speciﬁc to OT problems.
More importantly, our results are all nonasymptotic with computable constants.
To achieve this, we carefully analyze the eigenvalue structure of the dual Hessian matrix, which is of interest by itself.
Likewise, we show that the derivative of ∇ M S λ ( M, a, b ) as in Theorem 1 can also be computed in a numerically stable way.
Let (cid:92) ∇ M S be the k -step approximation to ∇ M S :=
∇ M S λ ( M, a, b ) using the L-BFGS algorithm, i.e. , replacing every T ∗ in ∇ M S by T ( k ) .
Then we show that the error on gradient also decays exponentially fast.
Theorem 4.
Using the symbols deﬁned in Theorems 1 and 3, let σ = 1 /σ min ( D ) , where σ min ( D ) is the smallest eigenvalue of D .
Assume that for some k 0 ,
[Equation]
and then for every k ≥ k 0 ,
[Equation]
where the explicit expression for C S is given in Section A.
A PPLICATION : S INKHORN GENERATIVE MODELING
The Sinkhorn loss is useful in unsupervised learning tasks that attempt to match two distributions p θ and p ∗ , where p ∗ stands for the data distribution, and p θ is the model distribution.
If p θ and p ∗ can be represented or approximated by two discrete measures µ θ and ν , respectively, then one would wish to minimize the Sinkhorn loss S λ ( M θ , a θ , b θ ) between µ θ and ν , where the cost matrix M and weights a, b may depend on learnable parameters θ .
In gradient-based learning frameworks, the key step of seeking the optimal parameter θ that minimizes S λ ( M θ , a θ , b θ ) is to compute the gradient ∇ θ S λ ( M θ , a θ , b θ ) , which further reduces to evaluating ∇ a,b S λ ( M, a, b ) and ∇ M S λ ( M, a, b ) .
Luise et al.
(2018) assumes that M is ﬁxed, and studies the gradients ∇ a,b S λ ( M, a, b ) .
However, in many generative models it is more important to derive ∇ M S λ ( M, a, b ) , as the weights a and b are typically ﬁxed, whereas the cost matrix M is computed from the output of some parameterized layers.
Consider a data set X 1 , . .
, X n that follows the distribution p ∗ , X i ∈ R p , and our target is to ﬁt a deep neural network g θ : R r
→ R p such that g θ ( Z ) approximately follows p ∗ , where
Z ∼ N (0 , I r ) .
To this end, we ﬁrst generate random variates Z 1 , . . .
, Z m ∼ N (0 , I r ) , and let
Y j = g θ
( Z j ) .
The two weight vectors are simply taken to be a = n − 1 1 n , b
= m − 1 1 m , and the cost matrix between X i and Y j is given by M θ ∈ R n × m , where ( M θ ) ij = (cid:107)
X i − g
θ
( Z j ) (cid:107) 2 .
Then we learn the network parameter θ by minimizing the Sinkhorn loss (cid:96) ( θ ) =
S λ
( M θ , n − 1 1 n , m − 1 1 m ) .
We show such applications in Section 7.
R ELATED WORK
In Table 1 we list some related work on the differentiation of the Sinkhorn loss, and provide a brief summary of the contribution and limitation of each work.
The target of our work is closest to that of Genevay et al.
(2018), i.e. , to differentiate the Sinkhorn loss with respect to the input cost matrix.
However, they use unrolled Sinkhorn’s algorithm, so there is no analytic form for ∇ M S λ .
Our work is mostly motivated by Luise et al.
, but they consider the derivative with respect to the weights instead of the cost matrix.
Similarly, Cuturi et al.
(2019) and Cuturi et al.
(2020) consider gradients on weights and data points, but not the general cost matrix.
Campbell et al.
Xie et al.
(2020); Eisenberger et al.
(2022) all consider the derivative of the transport plan T ∗ using implicit differentiation.
Although this is a more general problem than computing ∇ M S λ , it loses the special structure of the Sinkhorn loss.
As a result, the compact matrix form of the derivative presented in
Theorem 1 is unique.
Furthermore, the storage requirement for our result is O ( nm ) , whereas some existing works need to store much larger matrices.
Finally, very few work has rigorously analyzed the stability of the algorithm, in both the forward and backward passes.
N UMERICAL EXPERIMENTS 7. R UNNING TIME OF FORWARD AND BACKWARD PASSES
In our subsequent experiments, we compare three algorithms for differentiating the Sinkhorn loss: the proposed method (“Analytic”) using L-BFGS for the forward pass and the analytic derivative for backward pass, the implicit differentiation method (“Implicit”), and the unrolled Sinkhorn algorithm (“Unroll”).
Both Implicit and Unroll use Sinkhorn-log for the forward pass, and are implemented in the OTT-JAX library (Cuturi et al., 2022).
We simulate cost matrices of different dimensions, and compare the forward time and total time of different algorithms with both η = 0 .
1 and η = 0 .
The detailed experiment setting and results are given in Section B.3, Table 2, and Table 3.
The main conclusion is that under the same accuracy level, the forward pass of Analytic is typically faster than those of the other two algorithms, and the backward time is signiﬁcantly faster.
Overall, the proposed analytic differentiation method demonstrates visible advantages on computational efﬁciency. [Table]
article [Table] 7. G ENERATIVE MODELS ON TOY DATA SETS
In this section we apply the Sinkhorn loss to generative modeling [Table] and test the accuracy and efﬁciency of the proposed algorithm.
Following the methods in Section 5, we consider a toy data set with n = 1000 and p = 2 (shown in Figure 3) [Table] and we attempt to learn a neural network g θ such that g θ approximately pushes forward Z 1 , . .
, Z m ∼ N (0 , I r ) to the data distribution.
In our experiments, g θ is a fully-connected ReLU neural network with input dimension r = 5 and hidden dimensions 64-128-64.
The number of latent data points is m = 1000 .
In the ﬁrst setting, we intentionally keep both the observed data and the latent points Z 1 , . . .
, Z m ﬁxed, so that the optimization of g θ is a deterministic process without randomness, and the optimization variable obtained from each forward pass is used as the warm start for the next training iteration.
At every ten iterations, we compute the 2-Wasserstein distance between the observed data and the pushforward points { g θ ( Z i ) } , and we train g θ for 2000 iterations using the Adam optimizer with a learning rate of 0.001.
This setting, though not common in generative modeling, helps us to monitor the computation of gradients without the impact of random sampling.
Moreover, the Wasserstein distance has an achievable lower bound of zero if g θ is sufﬁciently expressive, so we can study the accuracy and efﬁciency of gradient computation by plotting the metric against running time.
The comparison results for the three algorithms are shown in the second and third plots of Figure 3, from which we have the following ﬁndings.
First, when η = 0 . 5 , the 2-Wasserstein distance will increase after certain number of iterations, indicating that the Sinkhorn loss is not an accurate approximation to the Wasserstein distance when η is large.
Second, it is clear that the Unroll method has the slowest computation, as it needs to unroll a potentially large computational graph in automatic differentiation.
Third, the proposed anlaytic differentiation shows visible advantages on computational efﬁciency, thanks to the closed-form expression for the derivative.
Finally, to examin the performance of differentiation methods in a genuine generative modeling setting, we use a regular training scheme that randomly samples the observed data and latent points at each iteration.
Due to the ﬁrst ﬁnding above, we choose the smaller η value for the Sinkhorn loss, and use a mini-batch of size n = m = 256 for training.
We run 5000 iterations in total, and the metric curves are shown in the last plot of Figure 3.
It can be found that the performance of the three algorithms are similar to the ﬁxed- Z case: all three methods properly reduce the Wasserstein distance over time, but the proposed algorithm uses less time to accomplish the computation. Additional experiments on simulated data sets are given in Section B.4.
7. D EEP GENERATIVE MODELS
Finally, we use the Sinkhorn loss to train larger and deeper generative models on the MNIST (LeCun et al., 1998) and Fashion-MNIST (Xiao et al., 2017) data sets.
In this experiment, we do not pursue training the best possible generative model; instead, we primarily validate our claims on the [Figure] [Figure] efﬁciency of the proposed analytic differentiation method.
The architecture of neural networks and details of the training process are given in Section B.5.
During the training process, we compute the 2-Wasserstein distance between randomly sampled test data and model-generated images over iterations, and Figure 4 show the results of Analytic, Implicit, and Unroll algorithms.
The conclusion is similar: the proposed analytic differentiation method achieves the same learning performance as existing methods, but is able to reduce the overall computing time.
This once again demonstrates the value of the proposed method.
C ONCLUSION
In this article we study the differentiation of the Sinkhorn loss with respect to its cost matrix, and have derived an analytic form of the derivative, which makes the backward pass of the differentiation easy to implement.
Moreover, we study the numerical stability of the forward pass, and rigorously prove that L-BFGS is a stable and efﬁcient algorithm that complements the widely-used Sinkhorn’s algorithm and its stabilized versions.
In particular, L-BFGS typically converges faster for Sinkhorn problems with a weak regularization.
It is worth noting that the proposed analytic differentiation method can be combined with different forward algorithms, and a reasonable scheme is to use LBFGS for weakly regularized OT problems, and to choose Sinkhorn’s algorithm otherwise.
The differentiable Sinkhorn loss has many potential applications in generative modeling and permutation learning (Mena et al., 2018), and we anticipate that the technique developed in this article would boost future research on those directions. R A E XPLICIT EXPRESSIONS FOR CONSTANTS We ﬁrst deﬁne a few user constants for the L-BFGS algorithm.
Let m 0 be the maximum number of correction vectors used to construct the BFGS matrix B k , and c 1 ∈ (0 , 1 / 2) , c 2 ∈ ( c 1 , 1) are two constants related to the Wolfe condition: we assume the L-BFGS algorithm uses some line search algorithm to select the step sizes α k that satisfy: [Equation] where f ( · ) and g ( · ) stand for the objective function and gradient function, respectively, x k is the k -th iterate, g k = g ( x k ) , d k = − B − 1 k g k is the search direction, and B k is the BFGS matrix that approximates the Hessian matrix.
m 0 , c 1 , and c 2 are selected by the user.
For Theorem 3, let ˜ β
(0) be the initial value, and let µ = M T a and u i = max j M ij , i = 1 , . . . , n .
Then we deﬁne the following constants:
[Equation]
For Theorem 4,
[Equation]
B A DDITIONAL EXPERIMENT DETAILS B. S ETTINGS OF THE MOTIVATING EXAMPLE
Consider a small problem of n = 90 and m = 60 .
Let x i =
( i − 1) /
( n − 1) , i = 1 , . .
. , n be equally-spaced points on [0 , 5] , and similarly deﬁne y j
= 5( j − 1) / ( m − 1) , j = 1 , . . .
, m .
The cost matrix is set to M ij =
( x i − y j ) 2 , and the weights a and b are speciﬁed as follows.
Let f 1 be the density function of an exponential distribution with mean 1, and f 2 be the density function of a mixture of two normal distributions, 0 .
· N (1 , 0 .
04)+0 .
8 · N (3 , 0 . 25) .
And then we set ˜ a
i = f 1 ( x i ) , ˜
[Equation]
We ﬁx the regularization parameter η to be 0.001.
This value is selected such that the resulting
Sinkhorn plan T ∗ λ is visually close to the OT plan P ∗ .
In Figure 5, we show the Wasserstein and
Sinkhorn transport plans under different values of η .
It can be seen that when η ≤ 0 . 001 , T ∗ λ is visually indistinguishable from P ∗ .
We compute the true T ∗ λ using the ε -scaling algorithm
(Algorithm 3 of Schmitzer, 2019).
This algorithm is typically accurate, but it requires solving a sequence of Sinkhorn problems with increasing λ ’s, where the solution corresponding to the previous λ is used as a warm start for the next one.
Therefore, its computational cost is typically large, and it does not compare fairly with other methods.
Due to this reason, in this article we mainly use the ε -scaling algorithm to compute high-precision reference values, and do not include it for method comparison. [Figure] [Figure] [Figure]
F ORWARD PASS STABILITY AND ACCURACY
To further compare the numerical stability and accuracy of different algorithms for computing the
Sinkhorn loss, we consider the following experiment.
First, we simulate data X 1 , . . .
, X n ∼ f 1 ( x ) and Y 1 , . . .
, Y m ∼ f 2 ( y ) from some speciﬁc distributions f 1 ( x ) and f 2 ( y ) , x, y ∈ R p , and construct the cost matrix as M = ( M ij ) , where M ij = (cid:107)
X i − Y j (cid:107) 2 .
The weights are ﬁxed as a = n − 1 1 n and b = m − 1 1 m .
For each of the ﬁve methods compared in the motivating example in Section 3.1, let
T = ( T ij ) be the computed Sinkhorn transport plan and T ∗ be the true value (computed using the ε -scaling algorithm), and then we compute two types of errors: the error on the transport plan, [Equation] and the error on the Sinkhorn loss value,
[Equation]
For each conﬁguration of the experiment, we simulate the data 100 times, and visualize the distribution of the errors using boxplots.
In our experiment, we ﬁx n = 150 , m = 200 , and consider varying dimensions p = 1 , 10 , 50 .
The
Sinkhorn regularization parameters compared are η = 0 .
001 , and for each η we set a speciﬁc maximum number of iterations for all algorithms. Two data generation models are considered: (a) Both f 1 ( x ) and f 2 ( y ) are multivariate normal distributions N (0 , I p ) ; (b) Both f 1 ( x ) and f 2 ( y ) have independent components. Each marginal distribution of f 1 is an exponential distribution with mean 1, and each marginal distribution of f 2 is a mixture of two normal distributions, 0 .
2 · N (1 , 0 . 04)
+ 0 .
8 · N (3 , 0 . 25) .
The ﬁnal results are demonstrated in Figure 6, where all the errors are shown in the log-scale.
In Figure 6, many boxplots for the Stabilized and Greenkhorn algorithms are missing, since they produce all NaN values in the 100 simulations due to numerical overﬂows. For Sinkhorn, even if it generates no NaNs values explicitly for η = 0 . 001 , it does not give any meaningful results either. This implies that numerical stability is a critical issue in computing the Sinkhorn loss.
For Sinkhorn-log, it gives reasonably small errors when the regularization is large ( η = 0 . 01 ) with sufﬁcient number of iterations, but its accuracy quickly deteriorates when η decreases to 0.001.
Moreover, we can ﬁnd that Sinkhorn-log is sensitive to the limits on number of iterations.
For example, when p = 1 and η = 0 .
01 , the loss value error can be as small as 10 − 6 givenmaximum number of iterations, but if we restrict the limit to 200, the error can be as large as 10 −or even 10 0 , depending on the data distribution.
In contrast, the difference on maximum number of iterations has a minor effect on the L-BFGS algorithm, indicating that it converges fast, and additional iterations are not needed.
These ﬁndings demonstrate the advantage of the advocated L-BFGS method in both numerical stability and accuracy.
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
t
i
[Table]
i
[Table]
S i n k ho r n
S i n
[Table]
ho r n − l og
S t ab ili
[Table]
ed G r een
[Table]
ho
[Table]
n L − B F G S
[Table]
n
[Table]
[Figure]
Log − sca l e
E rr o r
[Figure]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
og
[Table]
ab
[Table]
ed
[Table]
een
[Table]
ho
[Table]
G S
S
[Table]
og
[Table]
og
[Table]
[Figure]
[Table]
[Figure]
Log − sca l e
E rr o r
[Figure]
B. R UNNING TIME OF FORWARD AND BACKWARD PASSES
In this section we compare the running time of three algorithms on differenting the Sinkhorn loss.
(a) The proposed algorithm “Analytic”:
L-BFGS in the forward pass, and analytic differentiation in the backward pass.
(b) “Implicit” implemented in the OTT-JAX library (Cuturi et al., 2022): Sinkhorn-log in the forward pass, and implicit differentiation in the backward pass.
(c) “Unroll” implemented in the OTT-JAX library: Sinkhorn-log in the forward pass, and unrolled automatic differentiation in the backward pass.
We use the second data generation model in Section B.2 to simulate data points, and use the three algorithms above to compute the Sinkhorn loss and its derivative with respect to the cost matrix.
For each conﬁguration, we randomly generate the data 100 times, and compute their mean forward time and mean total time.
The stopping rule implemented in the OTT-JAX library is (cid:107) T 1 m − a (cid:107) +
(cid:107) T T 1 n − b (cid:107) < ε ott , and one of the terms would be exactly zero in the last iteration.
The stopping rule for L-BFGS is (cid:107) T T 1 n − b (cid:107) ∞ < ε lbfgs .
To account for such a difference, we set ε lbfgs = 10 − 6 , and let ε ott =
(cid:112) max { n, m }· ε lbfgs .
In fact, this setting favors the competing method, as its stopping criterion is strictly weaker than the proposed one. To test whether the algorithms actually converge under the given criteria, we also report the number of converging cases within the 100 repetitions. Results for different data dimensions and regularization parameters are given in Table 2 and Table 3, where the former uses 1000 maximum number of iterations, and the latter uses 10000. [Table]
Implicit 29.
Unroll 29.
m =
n =p =
η = 0 . Analytic 28. Implicit 33. Unroll 33.
m =
n =p =
η = 0 .
Analytic 43.
Implicit 33.
Unroll 33.
m =
n =p =
η = 0 .
Analytic 41.
Implicit 46.
Unroll 46.
m =
n =p
[Table]
η = 0 .
Analytic 67.
Implicit 46.
Unroll 46.
B
[Table]
M
ORE EXPERIMENTS ON SIMULATED DATA
We experiment on more simulated data to compare the computational efﬁciency of Analytic and
Implicit.
We do not include Unroll since it is too time-consuming.
The results are given in Figure 7, as analogues of Figure 3.
Three more simulated data sets are studied, and we also include the
Sinkhorn loss as a metric to evaluate the model performance over time.
[Table]
[Table]
[Table]
m =
n =p =
η =
[Table]
Analytic
[Table]
[Table]
[Table]
Analytic
[Table]
Implicit
[Table]
[Table]
[Table]
Unroll
[Table] [Table] B. A RCHITECTURES FOR DEEP GENERATIVE MODELS For the deep generative models on MNIST and Fashion-MNIST data in Section 7.4, the architectures of the generators are given in Table 4, where FC d stands for a fully-connected layer with d output dimensions, and Conv c,k,s,pin,pout is the transposed convolutional layer with c output channels, kernel size k , stride s , input padding pin , and output padding pout .
Both models are trained using the Adam optimizer with learning rate 0.0001, on mini-batches of size 600.
The Sinkhorn regularization parameter is set to η = 0 .
1 , and the training process consists of two stages.
In the ﬁrst stage, we use the squared L 2 distance to construct the cost matrix, and in the second stage we switch to the L 1 distance.
The intuition is that the squared L 2 distance has smoother derivatives, thereby making the training more stable in early steps; on the other hand, the
L 1 distance makes the generated images sharper.
The two stages are run for 20 and 30 epochs, respectively.
The Wasserstein distances values in Figure 4 are computed in the ﬁrst stage. [Figure] [Table] [Figure]
[Table]
[Figure] [Table] [Figure] [Table]
[Figure]
[Table]
i n i s t a n c e
[Table]
[Figure] B. C OMPUTING ENVIRONMENT All of the experiments in this article were conducted on a personal computer with an Intel i9-11900K
CPU and an Nvidia RTX 3090 GPU.
For the motivating example in Section 3.1 and the experiments in Section B.2, results for Sinkhorn’s algorithm, Sinkhorn-log, Stabilized, and Greenkhorn are computed using the Python Optimal Transport (POT) library (Flamary et al., 2021).
For the experiments in Sections 7.2, 7.3, B.3, and B.4, the Implicit and Unroll algorithms are implemented in the OTT-JAX library (Cuturi et al., 2022).
[Table]
C P ROOFS OF THEOREMS C. T ECHNICAL L EMMAS
In this section we state a few technical lemmas that are used to prove our main theorems.
Lemmato Lemma 3 below are standard conclusions in vector calculus, Lemma 4 and Lemma (5) are derived from the eigenvalue theory, and Lemma (7) and Lemma (8) are related to the Sinkhorn problem.
We ﬁrst introduce the following notations.
For any x ∈ R , let [ x ] + = max { x, 0 } .
For a matrix A =
( a ij ) ∈ R n × m , the vectorization operator, vec ( A ) , creates a vector by stacking the column vectors of A together, i.e. ,
[Equation]
For two matrices A
= ( a ij ) ∈ R n × m and B ∈ R p × q , the Kronecker product of A and B is deﬁned as
[Equation]
  . For a differentiable vector-valued function f : R n → R m , the partial derivative of f with respect to x is deﬁned as
[Equation]
We use I n to denote the n × n identity matrix, and σ max ( · ) and σ min ( · ) stand for the largest and smallest eigenvalues of some symmetric matrix, respectively.
Lemma 1.
Given two matrices A ∈ R m × n and B ∈ R n × r ,
[Equation]
Lemma 2.
Let f : R m → R n and g : R m → R n be two vector-valued differentiable functions of x ∈ R m .
Then
[Equation]
Lemma 3.
Let f : R m → R l and g : R m → R r be two vector-valued differentiable functions of x ∈ R m .
Then
[Equation]
Lemma 4.
Let A and B be two n × n positive deﬁnite matrices, and let α 1 ≥ · · · ≥ α n > 0 and β 1 ≥ · · · ≥ β n > 0 be the ordered eigenvalues of A and B , respectively.
Then for any x ∈ R n ,
[Equation]
Proof.
Let U 1 × n = x T A 1 / 2 , and then u := UU T = x T Ax ≤ α 1 (cid:107) x (cid:107) 2 , and UBU T = x T A 1 / 2 BA 1 / 2 x .
By Theorem A.4 in page 788 of Marshall et al.
, we immediately get [Equation]
Lemma 5.
Let A and B be two symmetric matrices of the same size. Then [Equation] Proof.
Using the well-known identity σ max ( A ) = max
[Equation]
x
[Equation]
=1 x T Ax , we have
[Equation]
Applying the inequality above to − ( A + B ) , we get the result on the opposite direction.
Lemma 6.
Let x = ( x 1 , . . .
, x n ) T and y
=
( y 1 , . . .
, y n ) T be two vectors.
Deﬁne LSE( x ) = log (cid:80) ni
{+=
+}
e x i , and then for any x, y ∈ R n ,
[Equation]
Proof.
It is easy to ﬁnd that ∇ x LSE( x ) = softmax( x ) =
( s 1 , . . .
, s n ) T is the softmax function, where s i =
e x i / (cid:80) nk =1 e x k ∈
By the mean value theorem, we have
LSE( x ) − LSE( y ) =
softmax( wx + (1 − w ) y ) T ( x − y )
for some 0 < w < 1 .
Let z = softmax( wx + (1 − w ) y ) , and then
LSE( x ) − LSE( y ) =
n
[Equation]
∞ , and similarly, LSE( x ) − LSE( y ) ≥ min i ( x i − y i ) ≥ −(cid:107) x − y (cid:107) ∞ .
Lemma 7.
Let f ( β ) be deﬁned as in (6), and let µ = M T a and u i = max j M ij , i = 1 , . .
. , n .
If f ( β ) ≤ c , then we have max j β j ≤ U c and min j β j ≥ L c , where
[Equation]
Proof.
By deﬁnition,
[Equation]
− η n (cid:88) i =
a i log a
i − β T b + η.
If f ( β ) ≤ c , then c 0 := c + η n (cid:88) i =
a i log a
i − η ≥ η n (cid:88) i =
a i log   m (cid:88)
j = e λ ( β j − M ij ) 
 − β T b.
By deﬁnition we have β m = 0 , and let J = arg max 1 ≤ j ≤ m − 1 β j .
Then c 0 ≥ η n (cid:88)
i = a i log (cid:104)
e λ ( β J − M iJ ) (cid:105) − β T b = n (cid:88)
i = a i ( β J − M iJ )
− m − 1 (cid:88)
j = β j b j ≥ β J − n (cid:88) i = a i M iJ − β J m − 1 (cid:88)
j = b j = b m β J − µ J ≥
b m β J − max 1 ≤ j ≤ m − 1 µ j , which veriﬁes (7) by noting that max j β j = [ β J ] + .
Next, let K = arg min 1 ≤ j ≤ m − 1 β j .
We can assume that β K < 0 , since otherwise the trivial bound min j β j = β m = 0 is already met.
Consider the sets S + = { j : β j > 0 } and S − =
{ j : β j < 0 } .
Then clearly, β
[Equation]
Also note that log( (cid:80) mj
=1 e x j ) ≥ max j x j for any x 1 , . .
, x n ∈ R , so η n (cid:88) i =
a i log  
[Equation]
(cid:88)
[Equation]

[Equation]
i
[Equation]
log  
[Equation]


[Equation]
λu
[Equation]


[Equation]
log
[Equation]

[Equation]

 −
[Equation]
i = a i u
[Equation]
max
[Equation]
λβ j ) − n
[Equation]
i = a i u i = max j β j − n (cid:88)
i =
a i u i =
[ β J ] + − n (cid:88) i =
a i u i .
As a result,
[Equation]
=
[Equation]
[Equation]
[Equation]
and then
[Equation]
which veriﬁes (8).
Lemma 8.
Let T be an n × m matrix with strictly positive entries, and suppose that n ≥ m .
Deﬁne µ = T 1 m , ν = T T 1 n , and
[Equation]
1 ˜ T.
Then
[Equation]
Proof.
Consider the matrix S
= H − sJ , where J is an ( n + m − 1)
× ( n + m − 1) matrix ﬁlled of ones, and s is a positive scalar.
Let
[Equation]
. , n + m − 1 .
Suppose s ≤ min 1 ≤ i ≤ n, 1 ≤ j ≤ m − 1 T ij , and then for k = 1 , . .
. , n , it is easy to ﬁnd that
R k = ( n − 1) s + m − 1 (cid:88)
j = ( T kj − s )
=
( n − 1) s + µ k − T km − ( m − 1)
s
=
( n − m ) s + µ k − T km , and for k = n + 1 , . .
. , n + m − 1 ,
R k =
[Equation]
m −
[Equation]
n (cid:88)
[Equation]
Then it is easy to see that
[Equation]
Let min
[Equation] and then s = min 1 ≤ i ≤ n T im / (2 n − 2 m + 2) , and [Equation] for all k .
By the Gershgorin circle theorem, every eigenvalue of S must be greater than L .
Since
H = S + sJ and J is nonnegative deﬁnite, we also have σ min ( H ) ≥ L > 0 , implying that H is positive deﬁnite.
Finally, it is easy to ﬁnd that the D matrix is the Schur complement of the block diag ( µ ) of the
H matrix.
So by Theorem 3.1 of Fan (2002), we have σ min ( D ) ≥ σ min ( H ) and σ max ( D ) ≤ σ max ( diag (˜ ν ))
=
max 1 ≤ j ≤ m − 1 ν j .
C. P ROOF OF (6)
Let T =
e λ [ α ⊕ β − M ] , and then it is easy to ﬁnd that ∇ α L ( α, β )
= a − T 1 m and ∇ ˜ β L ( α, β ) =
˜ b − ˜ T T 1 n .
Since α ∗ ( β ) = arg max α L ( α, β ) , we ﬁnd that α i ≡ α ∗ ( β ) i is the solution to the equation a − T 1 m = 0 .
By deﬁnition, we have
[Equation]
so the solution is α i =
η log a
i − η log (cid:16)(cid:80) mj
=1 e λ ( β j − M ij ) (cid:17) .
Since T 1 m = a , we immediately get 1 T n T 1 m = 1 , so
[Equation]
, and we get the expression for f ( β ) =
−L ( α ∗ ( β ) , β ) .
Finally,
[Equation]
Since α ∗ ( β ) =
arg max α L ( α, β ) implies that ∇ α L ( α, β ) | α
= α ∗ ( β ) = 0 , we have ∇ ˜ β L ( α ∗ ( β ) , β ) = ∇
˜ β L ( α, β ) (cid:12)(cid:12)(cid:12) α
= α ∗ ( β ) , and hence ∇
[Equation]
C. P ROOF OF T HEOREM
By deﬁnition we have
[Equation]
so Lemma 2 gives
[Equation]
Obviously, ∂ vec ( M ) /∂ vec ( M ) T is the ( nm ) × ( nm ) identity matrix
I ( nm ) , so the second term of (9) is essentially vec ( T ∗ ) T , and the remaining task is to derive ∂ vec ( T ∗ )
/∂ vec ( M ) T .
Let R =
α ∗ ⊕ β ∗ − M = α ∗ 1 T m + 1 n β ∗ T − M , and then T ∗ =
e λ [ R ] .
Using the chain rule of derivatives, we have
[Equation]
It is easy to ﬁnd that ∂ vec ( T ∗ ) /∂
vec ( R ) T is an ( nm ) ×
( nm ) diagonal matrix with diagonal elements vec ( λT ∗
[Equation]
, so
[Equation]
Furthermore,
[Equation]
where the second identity is an application of Lemma 3.
Combine (10), (11) and (12), and then we get [Equation]
[Equation]
which is the ﬁrst term of (9) [Equation]
Using the identities in Lemma
[Equation]
we have
[Equation]
Since we have set β ∗ m = 0 , (9) simpliﬁes to ∂S λ ( M
[Equation]
a [Equation]
b )
[Equation]
Let w ∗ =
( α ∗ T , ˜ β ∗ T ) T
[Equation]
and then the main challenge is to calculate ∂w ∗ /∂
vec ( M ) T .
First, note that the optimality condition for ( α ∗ , β ∗ ) =
arg max α,β L ( α, β ) is
[Equation]
Section C.2 has shown that ∇ α L ( α, β )
= a − T 1 m and ∇ ˜ β L ( α, β ) =
˜ b − ˜ T T 1 n .
Moreover,
[Equation]
Deﬁne the function
[Equation]
where w = ( α T , ˜ β T ) T , and then ˜ w ∗ satisﬁes the equation F ( w ∗ , M ) = 0 , indicating that w ∗ is implicitly a function of M , written as w ∗ = w ( M ) .
By the implicit function theorem,
[Equation]
Note that
[Equation]
Then by the inversion formula for block matrices [Equation] we have
[Equation]
where ˜∆ = ˜ D − ˜ B T A − 1 ˜ B .
For g = ( µ T r , ˜ µ T c ) T , the vector ˜ s
=
( s T u , ˜ s T v ) T = − λF − 1 w ˜ g has the following expression:
[Equation]
After some simpliﬁcation, we obtain
[Equation]
Next, partition F M as F M = (cid:18) G M ˜ H M (cid:19) , where G M ∈ R n × ( nm ) and ˜ H M ∈ R ( m − 1) × ( nm ) .
By deﬁnition,
[Equation]
This indicates that G M = λ ( diag ( T 1 ) , . .
, diag ( T m )) , where T 1 , . .
, T m are the column vectors of T .
Similarly, for H j = − (cid:80) ni =1 T ij ,
[Equation]
implying that
[Equation]
As a result,
[Equation]
Finally
[Equation]
substitute (16) into (13)
[Equation]
and we have
[Equation]
Transforming back to the matrix form, and we obtain
[Equation]
Replacing T with T ∗ and noting that a = T ∗ 1 m , ˜ b
= ˜ T ∗ T 1 n , we get the stated result.
The positive deﬁniteness of the ˜∆ matrix is a direct consequence of Lemma 8.
C. P ROOF OF T HEOREM
In the proof of Theorem 1 we have already shown that [Equation] where T = e λ [ α ⊕ β − M ] .
Plugging α ∗ ( β ) into L ( α, β ) , and then ∇ 2˜ β L ( α ∗ ( β ) , β ) is the Schur complement of the top left block of ∇ 2 α, ˜ β L ( α, β ) , given by
[Equation]
{+Since f ( β ) = −L ( α ∗ ( β ) , β ) , by Lemma 
 we ﬁnd that ∇ 2˜ β f ( β ) is positive deﬁnite, so f ( β ) is strictly convex on ˜ β ,+} and hence β ∗ is unique. The optimality conditions for ( α ∗ , β ∗ ) are T ∗ 1 m = a and T ∗ T 1 n = b , where T ∗ =
e λ [ α ∗ ⊕ β ∗ − M ] .
Since T ∗ ij = exp { λ ( α ∗ i + β ∗
j − M ij ) } ≥ 0 and a i = (cid:80) m j =1 T ∗ ij , b j = (cid:80) ni
=1 T ∗ ij , we have T ∗ ij ≤ min { a i , b j } for all i and j , implying that
[Equation]
Since β ∗ m = 0 by design, we have α ∗ i ≤
U α i < + ∞ , i = 1 , . .
. , n , where U α
i
=
U
im =
M im + λ − 1 min { log( a i ) , log( b m ) } .
This indicates that α ∗ i is upper bounded.
Next, let I = arg max i T ∗ im .
Since T ∗ T 1 n = b implies that b m = (cid:80) ni
=1 T ∗ im ≤ nT ∗
Im , we have
[Equation] exp { λ [Equation] ∗ I −
[Equation] } ≥ b m / [Equation] , and hence α ∗
I ≥ M Im + λ − 1 log( b m /n ) .
Again, since α ∗ i + β ∗ j ≤ U ij for all i and j , it holds that
[Equation]
On the other hand, T ∗ T 1 n = b implies that b j = (cid:80) ni
=1 T ∗ ij = e λβ ∗ j ·
[Equation]
ni =
[Equation]
λ
[Equation]
α ∗ i [Equation] M ij ) for any j , so
[Equation]
It is well-known that
[Equation]
for any x 1 , . . .
, x n ∈ R , so
[Equation]
Then (17) and (18) together show that | β ∗ j | < ∞ .
Similarly, T ∗ 1 m = a , so
[Equation]
The trivial bounds L α i and U β j are obtained by removing the unknown index I . The results above verify that | α ∗ i | < ∞ and | β ∗ j | < ∞ , and hence (cid:107) α ∗ (cid:107) < ∞ and (cid:107) β ∗ (cid:107) < ∞ .
Finally, plugging in β ∗ to the objective function, and we immediately get f ∗ > −∞ .
C. P ROOF OF T HEOREM
Claims (a) and (b) are direct consequences of the convergence property of the L-BFGS algorithm (Theorem 7.1, Liu & Nocedal, 1989), and we only need to verify its three assumptions. The new results here are explicit expressions for the constants C 1 , C 2 , and r .
First, f is twice continuously differentiable, so Assumption 7.1(1) of Liu & Nocedal (1989) is veriﬁed.
Second, f is a closed convex function, and we deﬁne the level set of f as L c = { ˜ β ∈ R m − 1 : f ( β ) ≤ c } .
Theorem 2 has shown that f ∗ > −∞ , and when c = f ∗ , obviously L c = { ˜ β ∗ } is non-empty and bounded.
Then Corollary 8.7.1 of Rockafellar (1970) shows that L c is bounded for every c .
In particular, for a ﬁxed initial value ˜ β (0) , deﬁne L = { ˜ β : f ( β ) ≤ f ( β (0) ) } , and then L is a bounded, closed, and convex set, which veriﬁes Assumption 7.1(2) of Liu & Nocedal (1989).
Third, let H ( β ) := ∇ 2˜ β f ( β ) , and then in the proof of Theorem 2 we have already shown that [Equation] where T = e λ [ α ∗ ( β ) ⊕ β − M ] . Lemma 8 veriﬁes that
[Equation]
− 1 ν j , where ν = T T 1 n . On the L set, Lemma 7 shows that max j β j ≤ U c and min j β j ≥ L c , with c = f ( β (0) ) . Therefore, α i
[Equation]
(cid:88)
[Equation]
=
[Equation]
β j − M ij )
[Equation]
  e −
[Equation]
m − 1 (cid:88)
j = e λ ( U c
[Equation]
(cid:88)
j
[Equation]
e
[Equation]
T im =
e λ ( α i − M im ) ≥ e λ
( A i − M im ) .
On the other hand, T ij must satisfy T ij > 0 and (cid:80) mj
=1 T ij = a i for any i and j , so for j = 1 , . . .
, m − 1 , we have T ij ≤ a i − T im .
Therefore,
[Equation]
This implies that there exist constants M 1 , M 2 > 0 such that
[Equation]
for all x ∈ R m − 1 and ˜ β ∈ L , with
[Equation] This veriﬁes Assumption 7.1(3) of Liu & Nocedal (1989).
Next, we derive the explicit constants in the theorem.
Following the notations in equation (7.3) of Liu & Nocedal (1989), the BFGS matrix B k for the L-BFGS algorithm has the following expression [Equation] where ˜ m
= min { k + 1 , m 0 } , m 0 is a user-deﬁned constant explained in Section A, and { y l } and { s l } are two sequences of vectors.
We also choose B (0)
=
I to be the identity matrix.
Fix l = ˜ m , and let cos
θ k = s T l B ( l ) s l / ( (cid:107) s l (cid:107) · (cid:107)
[Equation]
( l ) s l (cid:107) ) , ρ k = y T l s l / (cid:107) s l (cid:107) 2 , τ k = (cid:107) y l (cid:107) 2 /y
T l s l , and q k = s T l B ( l ) s l / (cid:107) s l (cid:107) 2 .
Then it can be veriﬁed that
[Equation]
Deﬁne ψ ( B ) = tr( B ) − log det( B ) , and it is known that ψ ( B ) > 0 for any positive deﬁnite matrix
B .
Equation (6.50) of Nocedal & Wright (2006) shows that
[Equation]
Under the assumptions veriﬁed above, equations (7.8) and (7.9) of Liu & Nocedal (1989) show that
[Equation]
and
[Equation]
y
[Equation]
M 2 for every l , so M 1 ≤ ρ k ≤ M 2 and τ k ≤ M 2 .
Since h ( x ) = 1 − x + log( x ) ≤ 0 for all x > 0 , we have
[Equation]
[Equation]
Now we show that ψ ( B k ) can be upper bounded.
First, Lemma 5 implies that for l = 0 , . . . ,
˜ m − 1 ,
[Equation]
max
[Equation]
B
[Equation]
l
[Equation]
l
[Equation]
, so σ max ( B k ) ≤ 1 + m 0 M 2 .
This also implies that q k ≤ 1 + m 0 M 2 .
Next, (19) shows that tr( B k ) ≤ m − 1 + m 0 M 2 , and (20) gives log
[Equation]
1 + m
[Equation]
{+M 2 ) , implying that log det( B k ) ≥ m 
+}
[log M 1 − log(1 + m 0 M 2 )] .
As a result, we get
[Equation]
[Equation]
Combining (21) and (22), we have cos 2 θ k > e − ( M 3 + M 4 ) .
Finally, using the argument in Byrd et al.
(1987), we have f ( k +1)
− f ∗ ≤ r ( f ( k ) − f ∗ ) , where
[Equation]
and c 1 , c 2 are two constants for the Wolfe condition as explained in Section A.
The constant C 1 is simply 2 /M 1 .
For (c), we follow the analysis in Nocedal et al. Let g ( β ) = ∇ ˜ β f ( β ) , and then g ( β ∗ ) = 0 . By Taylor’s theorem we have
[Equation]
where H 1 = H ( ξ ) for some ξ in the line segment connecting ˜ β and ˜ β ∗ .
Also,
[Equation]
Combining (23) and (24), we get
[Equation]
for any ˜ β ∈ L .
Let x = H 1 / 2 1 (˜ β − ˜ β ∗ ) , and then
[Equation]
It is easy to ﬁnd that
[Equation]
] − 1 ≤ M − 1 1 , σ max ( H 22 ) =
[ σ max ( H 2 )] 2 ≤ M 22 .
By Lemma 4, we have x T H − 1 /
H
H − 1 / 2x ≤ M − 1 1 M 22 (cid:107) x (cid:107) 2 for any x ∈ R m − 1 , and hence (cid:107) g β ) (cid:107) 2 ≤ C 2 ( f ( β ) − f ∗ ) for all ˜ β ∈ L , where C 2 = 2 M − 1 1 M 22 .
Since f ( k ) ≤ f (0) due to claim (a), we ﬁnd that ˜ β ( k ) ∈ L for all k > 0 .
Therefore,
[Equation]
and claim (c) is proved.
Claims (d) and (e) can be veriﬁed as follows.
For any ˜ β ∈ L , recall that T =
e λ [ α ∗ ( β ) ⊕ β − M ] , and then T 1 m − a = 0 and
[Equation]
, indicating that
[Equation]
Then 0 < T ij ≤ (cid:80)
mj =1 T ij = a i and 0 < T ij ≤ (cid:80) ni =1 T ij ≤ b j + (cid:107)∇ ˜ β f ( β ) (cid:107) .
The gradient (cid:107)∇ ˜ β f ( β ) (cid:107) can be bounded using claim (c), so (d) is also proved.
On the other hand, (25) shows that
[Equation]
and similarly we have
[Equation]
Replacing (cid:107)∇ ˜ β f ( β ) (cid:107) by its upper bound, and claim (e) is veriﬁed.
For matrix A n × m = ( a ij ) , deﬁne (cid:107) A (cid:107) ∞ = max i,j | a ij | , and the notation A ≥ 0 means a ij ≥ 0 for all i and j .
First, it is easy to show that (cid:107) A (cid:12) B (cid:107) F ≤ (cid:107) A (cid:107) ∞ (cid:107) B (cid:107) F , since
[Equation] A
[Equation]
Next, we show that if B n × m ≥ 0 , C p × n ≥ 0 , and v ≥ 0 , where v is a vector, then (cid:107) C ( A (cid:12) B ) v (cid:107) ≤ (cid:107) A (cid:107) ∞ (cid:107) CBv (cid:107) .
Proof.
Let u i be the i -th element of ( A (cid:12) B ) v , and then u i = m (cid:88)
j = a ij b ij v j , | u i | ≤ (cid:107) A (cid:107) ∞
[Equation]
j =
[Equation]
b ij v j . Consequently, (cid:107) C
( A (cid:12) B ) v (cid:107) =
(cid:118) (cid:117) (cid:117) (cid:116) p (cid:88) k
= (cid:12) (cid:12)(cid:12)(cid:12)(cid:12) n (cid:88) i =
c ki u
i (cid:12) (cid:12)(cid:12)(cid:12)(cid:12) ≤ (cid:118) (cid:117) (cid:117) (cid:116) p (cid:88) k
= (cid:32) n (cid:88) i
= c ki | u i | (cid:33)≤ (cid:107) A (cid:107) ∞ (cid:118)(cid:117) (cid:117) (cid:117) (cid:116)
p (cid:88) k =   n (cid:88) i =
c ki   m (cid:88)
j = b ij v j   
 =
(cid:107) A (cid:107) ∞ (cid:107) CBv (cid:107) .
Similarly, if A ≥ 0 and v ≥ 0 , then [Equation]
i = (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) m
[Equation]
j = a ij u
[Equation]
j (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤ (cid:107)
[Equation]
(cid:107) ∞ (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) n (cid:88) i =
  m (cid:88)
j = a ij v j   = (cid:107) u (cid:107) ∞ (cid:107) Av (cid:107) .
Moreover, for matrices B n × m ≥ 0 , and C m × p ≥ 0 , let C j be the j -th column of C , and then (cid:107) ( A (cid:12)
[Equation]
Let α = α ∗ + f and β = β ∗ + g for some perturbation vectors f and g , and deﬁne T =
e λ [ α ⊕ β − M ] .
Then it is easy to ﬁnd that
[Equation]
Let E T =
e λ [ f ⊕ g ] − 1 n [-
-]1 (cid:48) m , so T − T ∗ =
E T (cid:12) T ∗ .
Since | e x − 1 | < 2 | x | for | x | < 1 , we have
[Equation]
as long as λ | f
i + g j | < 1 .
This can be achieved by assuming ε := 2 λ ( (cid:107) f (cid:107) ∞ + (cid:107) g (cid:107) ∞ ) < 1 , since in this case λ | f
i + g j | ≤ λ ( (cid:107) f (cid:107) ∞ + (cid:107) g (cid:107) ∞ ) < 1 / 2 .
Then clearly (cid:107) E T (cid:107) ∞ < ε .
Consider ˆ s u
= s u + δ u
and ˆ s v =
s v + δ v for some perturbation vectors δ u and δ v , and let
[Equation]
u ⊕ ˆ s v − M ) (cid:12) T =
T + λ
( s u ⊕ s v − M ) (cid:12) T + λ ( δ u ⊕ δ v ) (cid:12) T = ∇ M S + E T (cid:12) ∇ M S + λ ( δ u ⊕ δ v ) (cid:12) ( T ∗ + E T (cid:12) T ∗ ) .
Then we have (cid:107)
[Equation]
∇ M S − ∇ M S (cid:107) F ≤ (cid:107) E T (cid:12) ∇ M S (cid:107) F + (cid:107) λ ( δ u ⊕ δ v ) (cid:12) ( T ∗ + E T (cid:12) T ∗ ) (cid:107) F ≤ (cid:107) E T (cid:107) ∞ (cid:107)∇ M S (cid:107) F + λ (cid:107) δ u ⊕ δ v (cid:107) ∞ (cid:107) T ∗ + E T (cid:12) T ∗ (cid:107) F < ε (cid:107)∇ M S (cid:107) F + λ (cid:107) δ u ⊕ δ v (cid:107) ∞ (cid:107) 1 n 1 (cid:48) m
+ E T (cid:107) ∞ (cid:107) T ∗ (cid:107) F ≤ ε (cid:107)∇ M S (cid:107) F + λ (cid:107) δ u ⊕ δ v (cid:107) ∞ (1 + (cid:107) E T (cid:107) ∞ ) (cid:107) T ∗ (cid:107) F < ε (cid:107)∇ M S (cid:107) F + λ (1 + ε ) (cid:107) δ u ⊕ δ v (cid:107) ∞ (cid:107) T ∗ (cid:107) F < ε (cid:107)∇ M S (cid:107) F + 2 λ (cid:107) T ∗ (cid:107) F ( (cid:107) δ u (cid:107) ∞
+ (cid:107) δ v (cid:107) ∞ ) .
Therefore
[Equation]
we just need to show proper bounds for (cid:107) δ u (cid:107) ∞ and (cid:107) δ v (cid:107) ∞ .
Consider ˆ µ r =
( M (cid:12) T ) 1 m and ˆ µ c = ( M (cid:12) T ) T 1 n
[Equation]
and then
[Equation]
It can be easily veriﬁed that
[Equation]
Deﬁne b v = µ c − T ∗ T ( a − (cid:12) µ r ) and ˆ b v =
ˆ µ c − T T ( a − (cid:12) ˆ µ r ) , and we have
[Equation]
As a result
[Equation]
< ε (cid:107) µ c (cid:107) + ε (cid:107) T ∗ T ( a − (cid:12) µ r ) (cid:107) + ε (cid:107) T ∗ T ( a − (cid:12) µ r ) (cid:107) + ε 2 (cid:107) T ∗ T ( a − (cid:12) µ r ) (cid:107) <
ε (cid:107) µ c (cid:107) + 3 ε (cid:107) T ∗ T ( a − (cid:12) µ r ) (cid:107) .
On the other hand, let ˆ t ij be the ( i, j ) element of the matrix ˜ T T diag ( a − ) ˜ T , and t ij be the ( i, j ) element of ˜ T ∗ T diag ( a − )
˜ T ∗ .
Then
[Equation]
This implies that
[Equation]
j | ˆ t ij − t ij | 2 ≤ 3 ε (cid:107) D (cid:107) F . Then by Theorem 7.2 of Higham (2002), if 3 εσ (cid:107) D (cid:107) F < 1 , we have (cid:107) δ v (cid:107) (cid:107) s v (cid:107) ≤ εσ 1 − 3 εσ (cid:107) D (cid:107) F (cid:18) (cid:107) µ c (cid:107) + 3 (cid:107) T ∗ T ( a − (cid:12) µ r ) (cid:107) (cid:107) s v (cid:107) + 3 (cid:107) D (cid:107) F (cid:19) .
where σ = (cid:107) D − 1 (cid:107) op = 1 /σ min ( D ) .
Assume that ε < min { 1 , 1 / (6 σ (cid:107) D (cid:107) F ) } , then with slight simpliﬁcation, we have (cid:107) δ v (cid:107) ∞ ≤ (cid:107) δ v (cid:107) ≤ C v ε , where C [Equation] =
[Equation]
σ (
[Equation]
µ
[Equation]
(cid:107)
[Equation]
( a
[Equation]
(cid:12) µ r ) (cid:107) +
[Equation]
(cid:107) D (cid:107) F (cid:107) s v (cid:107) ) .
On the other hand,
[Table] [Equation]
Combining the results together, we get
[Equation]
where C u =
[Equation]
Finally, Theorem 3(b) shows that (cid:107) g (cid:107) ∞ ≤ (cid:107) g (cid:107) = (cid:107) β ( k ) − β ∗ [Equation]
≤
[Equation]
C 1 ε ( k ) . In addition, by (6) we have [Equation] Then using Lemma (6), we obtain
[Equation]
≤ η (cid:107) λ ( β ( k ) j − β ∗ j ) (cid:107) ∞
= (cid:107) g (cid:107) ∞ , implying that (cid:107) f (cid:107) ∞
{+= (cid:107) α ∗ ( β ( k ) ) − α ∗ (cid:107) ∞ ≤ (cid:107) g (cid:107) ∞ ≤ (cid:112) C 
 ε ( k ) .+}
{+As a result, ε = 2 λ ( (cid:107) f (cid:107) ∞ + (cid:107) g (cid:107) ∞ ) ≤ 4 λ (cid:112) C 
+}
ε ( k ) .