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 computational 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, efficient algorithms for both the forward and backward passes of the Sinkhorn loss are required.
In this article, we first 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 an efficient backward algorithm.
We rigorously analyze the convergence and stability properties of the advocated algorithms, and use various numerical experiments to validate the 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 difficulty 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 define the two distributions.
Assuming n = m , standard linear programming solvers for OT have a complexity of O ( n 3 log n ) (Pele & Werman, 2009), which quickly becomes formidable as n gets large, 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 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 efficiently solved, at least in exact arithmetics, via Sinkhorn’s algorithm (Sinkhorn, 1964; Sinkhorn & Knopp, 1967), which merely involves matrix-vector multiplications and some minor operations.
Therefore, it is especially suited to modern computing hardware such as the graphics processing units (GPUs).
Recent theoretical results show that Sinkhorn’s algorithm has a computational complexity of O ( n 2 ε − 2 ) to output an ε -approximation to the unregularized OT (Dvurechensky et al., 2018).
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 greatly simplifies 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 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 efficient and stable.
The main contribution of this article is as follows:
• We have derived an analytic expression for the derivative of the Sinkhorn loss, which can be efficiently computed in back-propagation.
• We have rigorously analyzed the advocated forward and backward algorithms for the Sinkhorn loss, and show that they have desirable efficiency 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 .
Define Π( 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 ⟨ A, B ⟩ = 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 ) = ⟨ P ∗ , M ⟩ is then called the Wasserstein distance between µ and ν if the cost matrix M satisfies some suitable conditions (Proposition 2.2 of Peyré et al., 2019).
As is introduced in Section 1, solving the optimization problem (1) can be difficult 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-regularized 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 defined 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 ⊙ denotes the elementwise multiplication operator between matrices or vectors.
∥ · ∥ and ∥ · ∥ F stand for the Euclidean norm for vectors and Frobenius norm for matrices, respectively.
Finally, we globally define η ≡ λ − 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 efficient, 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 underflow 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 overflow.
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 severely 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 fix the regularization parameter η to be 0.001, where the detailed setting is provided in Appendix 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 reflected 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]
[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 efficiency 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 equivalent to an unconstrained convex optimization problem, so a simple gradient ascent method suffices to find its optimal solution.
But in practice, quasi-Newton methods such as the limited memory BFGS method (L-BFGS, Liu & Nocedal, 1989) can significantly accelerate the convergence.
Using LBFGS 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 first briefly 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 findings.
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 define 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-vector 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 scientific 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 sufficient 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 Appendix 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 excessive 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 first main theorem, given in Theorem 1, fills this gap and derives the analytic form for ∇ M S λ ( M, a, b ) .
Theorem 1.
For a fixed λ > 0 ,
[Equation]
where T ∗ =
e λ [ α ∗ ⊕ β ∗ − M ] , s u =
a − 1 ⊙ ( µ r − ˜ T ∗ ˜ s v ) , s v = (˜ s T v , 0) T , µ r =
( M ⊙ T ∗ ) 1 m , ˜ µ c = ( ˜ M ⊙ ˜
T ∗ ) T 1 n , ˜ s v = D − 1 (cid:104) ˜ µ
c − ˜ T ∗ T ( a − 1 ⊙ µ r ) (cid:105) , and D = diag (˜ b ) − ˜ T ∗ T diag ( a − 1 )
˜ T ∗ .
In addition, D is positive definite, 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 definite 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 efficiency and stability.
As a first step, we consider the target of the optimization problem (6), and show that f ( β ) has a well-behaved minimizer, which does not underflow or overflow.
Theorem 2.
Denote by f ∗ the minimum value of f ( β ) and β ∗ an optimal solution, and let α ∗
= α ∗ ( β ∗ ) .
Then f ∗ > −∞ , β ∗ is unique, ∥ α ∗ ∥ < ∞ , and ∥ β ∗ ∥ < ∞ .
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]
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 fixed initial value ˜ β (0) , and define β ( 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 ) .
) (b) ∥ β ( k ) − β ∗ ∥ 2 ≤ C 1 ε ( k ) .
(c) T ( k ) 1 m = a , ∥∇ ˜ β
f ( β ( k ) )
∥ 2 = ∥
˜ T ( k )T 1 n − ˜[-b (cid:107) 
-]
b ∥ 2 ≤ C 2 ε ( k ) .
(d) T ( k ) ij < min { a i , b j + (cid:112) C [-
-]2 ε ( k ) } , 1 ≤ j ≤ m − 1 .
(e) max j T ( k ) ij >a
i /m , max i T
k ) ij >
b j − 2 ε
The explicit expressions for the constants C 1 , C 2 , r are given in Appendix 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 ∥ T ( k ) 1 m − a ∥ , is exactly zero due to the partial optimization on α .
The other marginal error ∥ ˜ T ( k )T 1 n − ˜ b ∥ , 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 find 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 specific 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 defined 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 , ∥ (cid:92) ∇ M S − ∇ M S ∥ F ≤ C S √ ε ( k ) =
C S (cid:112) f (0) − f ∗ · r k/ 2 , where the explicit expression for C S is given in Appendix A. k 0 always exists as ε ( k ) decays to zero exponentially fast as ensured by Theorem 3(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 fixed, 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 fixed, 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 fit 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 first 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 = ∥
X i − g
θ
( Z j ) ∥ 2 .
Then we learn the network parameter θ by minimizing the Sinkhorn loss ℓ ( θ ) =
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 Appendix 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 significantly faster.
Overall, the proposed analytic differentiation method demonstrates visible advantages on computational efficiency.
[Table]
∇ M S λ ✗ ✓ ✗ ✗ ✗
[Table]
∇ a,b S
[Table]
✓ ✗ — ✓ ✗
[Table]
∇ a,x T ∗ ✗ ✗ — ✗ ✓
[Table]
∇ b,x T ∗ ✓ ✗ — ✓ ✗
[Table]
∇ M T ∗ ✓ ✓ ✗ ✓ ✗
[Table]
∇ M T ∗ ✓ ✓ ✗ ✓ ✗
[Table]
M T ∗ ✓ ✓ ✗ ✗ ✗
[Table]
article
[Equation]
✓ ✓
7. G ENERATIVE MODELS ON TOY DATA SETS
In this section we apply the Sinkhorn loss to generative modeling, and test the accuracy and efficiency 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), 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 first setting, we intentionally keep both the observed data and the latent points Z 1 , . . .
, Z m fixed, 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 sufficiently expressive, so we can study the accuracy and efficiency 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 findings.
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 analytic differentiation shows visible advantages on computational efficiency, thanks to the closed-form expression for the derivative.
Finally, to examine 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 first finding 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 fixed- 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 Appendix 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]
e s t D a t a
[Figure]
i n k h
o r n
D i v e r g e n c e
[Figure]
efficiency of the proposed analytic differentiation method.
The architecture of neural networks and details of the training process are given in Appendix B.5.
During the training process, we compute the Sinkhorn divergence (Feydy et al., 2019) and 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 efficient 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.
A E XPLICIT EXPRESSIONS FOR CONSTANTS
We first define 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 define the following constants:
[Equation]
M
[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 define 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 specified 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 ) , ˜ b
j = f 2 ( y j ) , a i = ˜ a i / (cid:80) nk =1 ˜ a k , and b j = ˜
b j / (cid:80) mk =1 ˜ b k .
We fix 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]
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 specific distributions f 1 ( x ) and f 2 ( y ) , x, y ∈ R p , and construct the cost matrix as M = ( M ij ) , where M ij = ∥
X i − Y j ∥ 2 .
The weights are fixed as a = n − 1 1 n and b = m − 1 1 m .
For each of the five 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 configuration of the experiment, we simulate the data 100 times, and visualize the distribution of the errors using boxplots.
In our experiment, we fix 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 specific 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 final 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 overflows.
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 sufficient number of iterations, but its accuracy quickly deteriorates when η decreases to 0.001.
Moreover, we can find 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 findings 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 differentiating 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 configuration, 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 ∥ T 1 m − a ∥ +
∥ T T 1 n − b ∥ < ε ott , and one of the terms would be exactly zero in the last iteration.
The stopping rule for L-BFGS is ∥ T T 1 n − b ∥ ∞ < ε 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
[Table] [Table]
η [Table]
Analytic 28.
Implicit 33.
Unroll 33.
[Table] [Table]
[Table]
Analytic 43.
Implicit 33.
Unroll 33.
[Table] [Table]
[Table]
Analytic 41.
Implicit 46.
Unroll 46.
[Table] [Table]
[Table]
Analytic 67.
Implicit 46.
[Table]
[Table]
M ORE EXPERIMENTS ON SIMULATED DATA
We experiment on more simulated data to compare the computational efficiency 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]
m =
n =p =
[Table]
=
[Table]
Analytic
[Table]
Analytic
[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 first 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 first stage.
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
n h o r n
[Table]
[Table]
r g e n c e
[Table]
[Figure]
three additional data sets and the extra Sinkhorn divergence metric to evaluate model performance.
Finally, we illustrate the application of the Sinkhorn loss in an Wasserstein auto-encoder (WAE, Tolstikhin et al., 2018) generative model, based on the CelebA data set (Liu et al., 2015). The training data consist of 20000 human face images, each of size 64 × 64 .
The WAE model learns an encoder Q : R p
→ R r and a decoder G : R r
→ R p as a solution to the following optimization
[Table]
problem:
[Equation]
where p X , p Q ( X ) , and p Z are the distribution of data points X , the distribution of Q ( X ) , and a pre-specified latent distribution, respectively, and ξ is a regularization parameter to balance the two terms.
The first term in (7) is the reconstruction error, and the second term quantifies the divergence of the distribution of Q ( X ) to the latent distribution p Z .
We simply take p Z to be a multivariate standard normal distribution, and use the Sinkhorn divergence (Genevay et al., 2018) to define D ( · ) :
[Equation]
where µ and ν are two discrete distributions, and with slight abuse of notation, S λ ( µ, ν ) is the
Sinkhorn loss studied in this article.
In actual implementation, µ and ν are Diracs of data points from p Z and p Q ( X ) , respectively.
To generate new images, we sample latent data points Z 1 , . . .
, Z n from the latent distribution p Z , and then pass them to the generator to obtain images
Y i =
G ( Z i ) , i = 1 , . . . , n .
Since the focus of this article is on the computation and differentiation of the Sinkhorn loss
[Table]
we do not attempt to build and train the model with full complexity.
Instead, we only run 10 epochs for illustration purpose.
The architectures of the encoder and the decoder are given in Table
[Table]
and we set ξ = 1 and η = 0 .
We have found that the Implicit method generates NaNs after 72 mini-batch iterations
[Table]
so we only show the results for the proposed Analytic algorithm and the existing Unroll method.
Figure 8 shows the training process of the WAE model based on the Sinkhorn divergence, as well as the randomly generated images using the Analytic method.
It is clear that the proposed
Analytic method is faster than the Unroll method in training
[Table]
[Table]
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.
[Figure]
L o ss F un c t i o n V a l u e [Figure] 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).
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 first 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]
a
[Equation]
For two matrices A
= ( a ij ) ∈ R n × m and B ∈ R p × q , the Kronecker product of A and B is defined as
[Equation]
For a differentiable vector-valued function f : R n → R m , the partial derivative of f with respect to x is defined 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 definite 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]
T
[Equation]
x
[Equation]
Proof.
Let U 1 × n = x T A 1 / 2 , and then u := UU T = x T Ax ≤ α 1 ∥ x ∥ 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
UBU T = tr( UBU T ) ≤ β 1 u ≤ α 1 β 1 ∥ x ∥ 2 .
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 ∥ x ∥ =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.
Define LSE( x ) = log (cid:80) ni
=
e x i , and then for any x, y ∈ R n , −∥
[Equation]
Proof.
It is easy to find 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 (cid:88) i = [Equation] ≤
[Equation]
max [Equation] · n (cid:88) i = z i = max i ( x i − y i ) ≤ ∥ x − y ∥ ∞ , and similarly, LSE( x ) − LSE( y ) ≥ min i ( x i − y i ) ≥ −∥ x − y ∥ ∞ .
Lemma 7.
Let f ( β ) be defined 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 U [Equation] [Equation]
[Equation]
L
[Equation]
min
[Equation] (cid:19) [Equation] (cid:34) n
[Equation]
i = [Equation] a [Equation]
u
[Equation]
η n
[Equation]
Proof.
By definition,
[Equation]
If f ( β ) ≤ c , then
[Equation]
By definition we have β m = 0 , and let J = arg max 1 ≤ j ≤ m − 1 β j .
Then
[Equation]
which verifies (8) 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   m (cid:88) j = e λ ( β j − M ij )   ≥ η n (cid:88) i = a i log   m (cid:88)
j = e λ ( β j − u i ) 
 =
η n (cid:88) i = a i   log   m (cid:88)
j = e λβ j 

− λu i 
 =
η log   m (cid:88)
j = e λβ j   − n (cid:88)
i =
a i u i ≥ η · max j ( λβ j ) − n (cid:88)
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, c 0 ≥ η n (cid:88) i =
a i log   m (cid:88)
j = e λ ( β j − M ij ) 
 − β T b ≥ [ β J ] + − n (cid:88) i =
a i u i − β K b K − [ β J ] + (1 − b m ) =
b m [ β J ] + − n (cid:88)
i =
a i u i − β K b K ≥ − n (cid:88) i = a i u i − β K b K , and then β K ≥ − b − 1 K (cid:34) n (cid:88) i =
a i u i + c(cid:35)
+ ≥ − (cid:18) min 1 ≤ j ≤ m − 1 b j (cid:19) − 1 (cid:34) n (cid:88)
i =
a i u i + c(cid:35)
+ , which verifies (9).
Lemma 8.
Let T be an n × m matrix with strictly positive entries, and suppose that n ≥ m .
Define µ = T 1 m , ν = T T 1 n , and
[Equation]
Then
[Equation]
Proof.
Consider the matrix S
= H − sJ , where J is an ( n + m − 1)
× ( n + m − 1) matrix filled of ones, and s is a positive scalar.
Let
[Equation]
Suppose s ≤ min 1 ≤ i ≤ n, 1 ≤ j ≤ m − 1 T ij , and then for k = 1 , . .
. , n , it is easy to find that
[Equation]
and for k = n + 1 , . . . , n + m − 1 , R k = ( m
[Equation]
Then it is easy to see that
[Equation]
Let
[Equation]
and then s = min 1 ≤ i ≤ n T im / (2 n − 2 m + 2) , and S
[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 definite, we also have σ min ( H ) ≥ L > 0 , implying that H is positive definite.
For the second formula, it is easy to find 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 .
Finally, let c = max 1 ≤ j ≤ m − 1 ν j , and then D can be expressed as D = cI m − 1 − B , where B = ˜
T T diag ( µ ) − 1 ˜ T + diag ( c 1 m − 1 − ˜ ν ) is a matrix that have nonnegative entries.
In addition, we have proved that D is positive definite, so D is a nonsingular M -matrix by the definition in Tian & Huang (2010).
Then Theorem 3.2 of Tian & Huang (2010) shows that
[Equation]
Let δ = D 1 m − 1 , and then clearly min 1 ≤ i ≤ m − 1 (cid:80) m − 1 j =1 D ij = min i δ i .
Note that
[Equation]
where T m stands for the m -th column of T .
Therefore,
[Equation]
C. P ROOF OF (6)
Let T =
e λ [ α ⊕ β − M ] , and then it is easy to find that ∇ α L ( α, β )
= a − T 1 m and ∇ ˜ β L ( α, β ) =
˜ b − ˜ T T 1 n .
Since α ∗ ( β ) = arg max α L ( α, β ) , we find that α i ≡ α ∗ ( β ) i is the solution to the equation a − T 1 m = 0 .
By definition, 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]
[Equation]
Since α ∗ ( β ) =
arg max α L ( α, β ) implies that ∇ α L ( α, β ) | α
= α ∗ ( β ) = 0 , we have ∇ ˜ β L ( α ∗ ( β ) , β ) = ∇
˜ β L ( α, β ) (cid:12) (cid:12)(cid:12) α
= α ∗ ( β ) , and hence ∇ ˜ β f
[Equation]
C. P ROOF OF T HEOREM
By definition 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 (10) is essentially vec ( T ∗ )
T
[Equation]
and the remaining task is to derive ∂ vec ( T ∗ ) /∂
vec ( M ) T .
Let R =
α ∗ ⊕ β ∗ − M = α ∗ 1 T m + 1 n β ∗ T − M [Equation] and then T ∗ =
e λ [ R ] .
Using the chain rule of derivatives
[Equation]
we have
[Equation] [Equation]
It is easy to find that ∂ vec ( T ∗ ) /∂ vec ( R ) T is an ( nm ) ×
( nm ) diagonal matrix with diagonal elements vec ( λT ∗ ) , so
[Equation]
Furthermore,
[Equation]
where the second identity is an application of Lemma 3.
Combine (11), (12) and (13) [Equation] and then we get
[Equation]
which is the first term of (10).
Using the identities in Lemma 1, we have
[Equation]
Since we have set β ∗ m = 0 , (10) simplifies to ∂S
[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]
[Equation]
[Equation]
Section C.2 has shown that ∇ α L ( α, β )
= a − T 1 m and ∇ ˜ β L ( α, β ) =
˜ b − ˜ T T 1 n .
Moreover, ∇
[Equation]
α L ( α,
[Equation]
[Equation]
Define the function
[Equation]
where w = ( α T , ˜ β T ) T
[Equation]
and then ˜ w ∗ satisfies 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 simplification, 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 definition,
[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, substitute (17) into (14)
[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 definiteness 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 [-
-]8 we find that ∇ 2˜ β f ( β ) is positive definite, 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) mj
=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] , 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]
[Equation]
On the other hand, T ∗ T 1 n = b implies that b j = (cid:80) ni
=1 T ∗ ij =
e λβ ∗ j · (cid:80) ni
=1 e λ ( α ∗ i − M ij ) for any j , so
[Equation]
It is well-known that
[Equation]
for any x 1 , . . .
, x n ∈ R , so
[Equation]
Then (18) and (19) 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 ∥ α ∗ ∥ < ∞ and ∥ β ∗ ∥ < ∞ .
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 verified.
Second, f is a closed convex function, and we define 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 fixed initial value ˜ β
(0) , define L = { ˜ β : f ( β ) ≤ f ( β (0) ) } , and then
L is a bounded, closed, and convex set, which verifies 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 verifies that
[Equation]
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,
[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, v j = n (cid:88)
[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 verifies 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-defined 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 / ( ∥ s l ∥ · ∥ B ( l ) s l ∥ ) , ρ k = y T l s l / ∥ s l ∥ 2 , τ k = ∥
y l ∥ 2 /y T l s l , and q k = s T l B ( l ) s l / ∥ s l ∥ 2 .
Then it can be verified that
[Equation]
Define ψ ( B ) = tr( B ) − log det( B ) , and it is known that ψ ( B ) > 0 for any positive definite matrix
B .
Equation (6.50) of Nocedal & Wright (2006) shows that
[Equation]
Under the assumptions verified above, equations (7.8) and (7.9) of Liu & Nocedal (1989) show that
M 1 ≤ y T l s l / ∥ s
l ∥ 2 ≤ M 2 and ∥ y l ∥ 2 /y T l s l ≤ 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]
Now we show that ψ ( B k ) can be upper bounded.
First, Lemma 5 implies that for l = 0 , . . . ,
˜ m − 1 , σ
[Equation]
≤
[Equation]
B
[Equation]
+ 0 + ∥ y l ∥
[Equation]
y T
[Equation]
s l ≤ σ max ( B ( l ) )
+ {+M 2 , so σ max ( B k ) ≤ 1 + m 
 M 2 . This also implies that q k ≤ 1 + m 0 M 2 . Next, (20) shows that tr( B+} k ) ≤ m − 1 + m 0 M 2 , and (21) gives
[Equation]
0 M 2 ) , implying that log det( B k ) ≥ m
[log M 1 − log(1 + m 0 M 2 )] .
As a result, we get
[Equation]
Combining (22) and (23), 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 (24) and (25), we get
[Equation]
for any ˜ β ∈ L .
Let x = H 1 / 2 1 (˜ β − ˜ β ∗ ) , and then ∥ g
[Equation]
[-β ) (cid:107) 2 = 2 x T H − 1 / 
-]
[-H 
-]
It is easy to find that
[Equation]
By Lemma 4, we have x T H − 1 /
H
H − 1 / 2x ≤ M − 1 1 M 22 ∥ x ∥ 2 for any x ∈ R m − 1 , and hence ∥ g ( β ) ∥ 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 find that ˜ β ( k ) ∈ L for all k > 0 .
Therefore,
[Equation]
and claim (c) is proved.
Claims (d) and (e) can be verified 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 + ∥∇ ˜ β f ( β ) ∥ .
The gradient ∥∇ ˜ β f ( β ) ∥ can be bounded using claim (c), so (d) is also proved.
On the other hand, (26) shows that a
[Equation]
and similarly we have
[Equation]
Replacing ∥∇ ˜ β
f ( β ) ∥ by its upper bound, and claim (e) is verified.
C. P ROOF OF T HEOREM
For matrix A n × m = ( a ij ) , define ∥ A ∥ ∞ = 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 ∥ A ⊙ B ∥ F ≤ ∥ A ∥ ∞ ∥ B ∥ F , since
[Equation]
∥ A ∥ 2 ∞ b 2 ij = ∥ A ∥ ∞
∥ B ∥ F .
Next, we show that if B n × m ≥ 0 , C p × n ≥ 0 , and v ≥ 0 , where v is a vector, then ∥ C ( A ⊙ B ) v ∥ ≤ ∥ A ∥ ∞ ∥ CBv ∥ .
Proof.
Let u i be the i -th element of ( A ⊙ B ) v , and then u i = m (cid:88)
j = a ij b ij v j , | u i | ≤ ∥
A ∥ ∞ m (cid:88)
j = b ij v j .
Consequently, ∥ C ( A ⊙ B ) v ∥ =
(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)≤ ∥ A ∥ ∞ (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   
 =
∥ A ∥ ∞ ∥ CBv ∥ .
Similarly, if A ≥ 0 and v ≥ 0 , then ∥ A ( u ⊙ v ) ∥ = (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) n (cid:88) i = (cid:12)(cid:12)(cid:12)(cid:12) (cid:12) (cid:12) m (cid:88)
j = a ij u j v j (cid:12)(cid:12)(cid:12)(cid:12) (cid:12) (cid:12) ≤ [Equation]
u ∥ ∞ (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) n (cid:88) i =   m (cid:88)
j = a ij v j   = ∥ u ∥ ∞ ∥
Av ∥ . Moreover, for matrices B n × m ≥ 0 , and C m × p ≥ 0 , let C j be the j -th column of C , and then ∥ ( A ⊙ B ) C ∥ F = (cid:118)(cid:117)(cid:117)(cid:116) p (cid:88)
j = ∥ ( A ⊙ B ) C i ∥ 2 ≤ ∥ A ∥ ∞ (cid:118)(cid:117)(cid:117)(cid:116) p (cid:88)
j = ∥ BC i ∥ 2 = ∥ A ∥ ∞ ∥ BC ∥ F .
Let α = α ∗ + f and β = β ∗ + g for some perturbation vectors f and g , and define T =
e λ [ α ⊕ β − M ] .
Then it is easy to find that
[Equation]
Let E T =
e λ [ f ⊕ g ] − 1 n {+
+} m , so T − T ∗ =
E T ⊙ 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 λ ( ∥ f ∥ ∞ + ∥ g ∥ ∞ ) < 1 , since in this case λ | f
i + g j | ≤ λ ( ∥ f ∥ ∞ + ∥ g ∥ ∞ ) < 1 / 2 .
Then clearly ∥ E T ∥ ∞ < ε .
Consider ˆ s u
= s u + δ u
and ˆ s v =
s v + δ v for some perturbation vectors δ u and δ v , and let (cid:92)
[Equation]
Then we have
[Equation]
Therefore, we just need to show proper bounds for ∥ δ u ∥ ∞ and ∥ δ v ∥ ∞ .
Consider ˆ µ r =
( M ⊙ T ) 1 m and ˆ µ c = ( M ⊙ T ) T 1 n , and then
[Equation]
It can be easily verified that
[Equation]
Define b v = µ c − T ∗ T ( a − ⊙ µ r ) and ˆ b v = ˆ µ c − T T ( a − ⊙ ˆ µ r )
[Equation]
and we have ˆ
[Equation]
As a result,
[Equation]
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]
Then by Theorem 7.2 of Higham (2002), if 3 εσ ∥ D ∥ F < 1 , we have
[Equation]
where σ =
∥
D − 1 ∥ op = 1 /σ min ( D ) .
Assume that ε < min { 1 , 1 / (6 σ ∥ D ∥ F ) } , then with slight simplification, we have ∥ δ v ∥ ∞ ≤ ∥ δ v ∥ ≤ C v ε , where
[Equation]
On the other hand,
[Equation]
Combining the results together
[Equation]
we get
[Equation]
where C u = ∥ µ r ∥ + 2 C v ∥ diag ( a − ) T ∗ ∥ F + ∥ a − ⊙ ( T ∗ s v ) ∥ .
Finally [Equation] Theorem 3(b) shows that ∥ g ∥ ∞ ≤ ∥ g ∥ =
∥ β ( k ) − β ∗ ∥ ≤ (cid:112) C 1 ε ( k ) .
In addition, by (6) we have
[Equation]
Then using Lemma (6), we obtain | α
[Equation]
implying that ∥ f ∥ ∞ =
∥
α ∗ ( β ( k ) ) − α ∗ ∥ ∞ ≤ ∥ g ∥ ∞ ≤ (cid:112) C
ε ( k ) .
As a result, ε = 2 λ ( ∥ f ∥ ∞ + ∥ g ∥ ∞ ) ≤ 4 λ (cid:112) C [-
-]1 ε ( k ) .