Integration by parts is a highlight of any calculus class. It leads to multiple classical applications for integration of logarithms, exponentials, etc., and it is the source of an infinite number of exercises and applications to special functions. In this post, I will look at a classical discrete extension that is useful in machine learning and optimization, namely Abel transformation, with applications to convergence proofs for the (stochastic) subgradient method. Next month, extensions to higher dimensions will be considered, with applications to score functions [2, 3] and randomized smoothing [4, 5].
Abel transformation: from continuous to discrete
The most classical version of integration by parts goes as follows. Given two continuously differentiable functions from R to R, we have:
This is valid for less regular functions, but this is not the main concern here. The proof follows naturally from the derivative of a product, but there is a nice “proof without words” (see, e.g., [1, p. 42] or here).
There is a discrete analogue referred to as Abel transformation or summation by parts, where derivatives are replaced by increments: given two real-valued sequences (an)n≥0 and (bn)n≥0 (the second sequence could also be taken vector-valued), we can expand
In other words, we can transfer the first-order difference from the sequence (bk)k≥0 to the sequence (ak)k≥0. A few remarks:
Warning! It is very easy/common to make mistakes with indices and signs.
I gave the direct proof but a proof through explicit integration by part is also possible, by introducing the piecewise-constant function f equal to ak on [k,k+1), and g continuous piecewise affine equal to bk+(t−k)(bk+1−bk) for t∈[k,k+1], and integrating between 0+ and n+.
There are classical applications for the convergence of series (see here), but in this post, I will show how it can lead to an elegant result for stochastic gradient descent for non-smooth functions and decaying step-sizes.
Decaying step-sizes in stochastic gradient descent
The Abel summation formula is quite useful when analyzing optimization algorithms, and we give a simple example below. We consider a sequence of random potentially non-smooth convex functions (fk)k≥0 which are independent and identically distributed functions from Rd to R, with expectation F. The goal is to find a minimizer x∗ of F over a some convex bounded set C, only being given access to some stochastic gradients of fk at well-chosen points. The most classical example is supervised machine learning, where fk(θ) is the loss of a random observation for the predictor parameterized by θ. The difficulty here is the potential non-smoothness of the function fk (e.g., for the hinge loss and the support vector machine).
We consider the projected stochastic subgradient descent method. The deterministic version of this method dates back to Naum Shor [6] in 1962 (see nice history here). The method goes as follows: starting from some θ0∈Rd, we perform the iteration
θk=ΠC(θk−1–γk∇fk(θk−1)),
where ΠC:Rd→Rd is the orthogonal projection onto the set C, and ∇fk(θk−1) is any subgradient of fk at θk−1.
One step of projected (sub)gradient descent: from a vector θ, we go down the direction of a negative subgradient ∇f(θ) of the function f (here typically a random function) and an orthogonal projection is performed to obtain the new vector θ+.
We make the following standard assumptions: (a) the set C is convex and compact with diameter Δ (with respect to the ℓ2-norm), (b) the functions fk are almost surely convex and B-Lipschitz-continuous (or equivalently with gradients bounded in ℓ2-norm by B). We denote by θ∗ a minimizer of f on C (there can be multiple ones).
For non-smooth problems, choosing a constant step-size does not lead to an algorithm converging to a global minimizer: decaying step-sizes are then needed.
Convergence proof through Lyapunov functions
Since the functions fk are non-smooth, we cannot use Taylor expansions, and we rely on a now classical proof technique dating back from the 1960’s (see, e.g., a paper by Boris Polyak [7] in Russian), that has led to several extensions in particular for online learning [8]. The proof relies on the concept of “Lyapunov functions“, often also referred to as “potential functions”. This is a non-negative function V(θk) of the iterates θk, that is supposed to go down along iterations (at least in expectation). In optimization, standard Lyapunov functions are V(θ)=F(θ)–F(θ∗) or V(θ)=∥θ–θ∗∥22.
For the subgradient method, we will not be able to show that the Lyapunov function is decreasing, but this will lead through a manipulation which is standard in linear dynamical system analysis to a convergence proof for the averaged iterate: that is, if V(θk)⩽V(θk−1)–W(θk−1)+εk, for a certain function W and extra positive terms εk, then, using telescoping sums,
We can then either use Jensen’s inequality to get a bound on W(n1∑k=1nθk−1), or directly get a bound on mink∈{1,…,n}W(θk−1). The first solution gives a performance guarantee for a well-defined iterate, while the second solution only shows that among the first n−1 iterates, one of them has a performance guarantee; in the stochastic set-up where latex W is an expectation, it is not easily possible to know which one, so we will consider only averaging below.
Standard inequality. We have, by contractivity of orthogonal projections:
The last term is upper-bounded by γk2B2 because of the regularity assumption on fk. For the middle term, we use the convexity of fk, that is, the function fk is greater than its tangent at θk−1. See figure below.
Convex function above its tangent at θk−1, leading to the desired inequality.
At this point, except the last term, all terms are random. We can now take expectations, with a particular focus on the term E[fk(θk−1)], for which we can use the fact that the random function fk is independent from the past, so that
At this point, the “optimization part” of the proof is done. Only algebraic manipulations are needed to obtain a convergence rate. This is where Abel transformation will come in.
From fixed horizon to anytime algorithms
The lazy way. At this point, many authors (including me sometimes) will take a constant step-size γk=γ so as to obtain a telescopic sum, leading to
which is less than 2nγΔ2+2γB2, and minimized for γ=BnΔ, leading to a convergence rate less than nBΔ. Using Jensen’s inequality, we then get for θˉn=n1∑k=1nθk−1:
E[F(θˉn)]–F(θ∗)⩽nBΔ.
This result leads to the desired rate but can be improved in at least one way: the step-size currently has to depend on the “horizon” n (which has to be known in advance), and the algorithm is not “anytime”, which is not desirable in practice (where one often launches an algorithm and stops it when it the performance gains have plateaued or when the user gets bored waiting).
Non-uniform averaging. Another way [9] is to consider the non-uniform average
ηk=∑k=1nγk∑k=1nγkθk−1,
for which telescoping sums apply as before, to get
E[F(ηk)]–F(θ∗)⩽21∑k=1nγkΔ2+B2∑k=1nγk2.
Then, by selecting a decaying step-size γk=BkΔ, that depends on the iteration number, we get a rate proportional to nBΔ(1+logn). We now have an anytime algorithm, but we have lost a logarithmic term, which is not the end of the world, but still disappointing. In [9], “tail-averaging” (only averaging iterates between a constant times n and n) is proposed, that removes the logarithmic term but requires to store iterates (moreover, the non-uniform averaging puts too much weight on the first iterates, slowing down convergence).
Using Abel transformation. If we start to sum inequalities from k=1 to k=n, we get, with δk=E[∥θk–θ∗∥22] (which is always between 0 and Δ2):
which is up to a factor 23 exactly the same bound as with a constant step-size, but now with an anytime algorithm.
Experiments
To illustrate the behaviors above, let’s consider minimizing Ex∥x–θ∥1, with respect to θ, with fk(θ)=∥xk−θ∥1, where xk is sampled independently from a given distribution (here independent log-normal distributions for each coordinate). The global optimum θ∗ is the per-coordinate median of the distribution of x’s.
When applying SGD, the chosen subgradient of fk has components in {−1,1}. Hence in the plots below in two dimensions, the iterates are always on a grid. With a constant step-size: if the γ is too large (right), there are large oscillations, while if γ is too small (left), optimization is too slow. Note that while the SGD iterate with a constant step-size is always oscillating, the averaged iterate converges to some point (which is not the global optimum, and is typically at distance O(γ) away from it [11]).
Stochastic gradient descent (averaged or not), with constant step-size. Left: small step-size. Right: large step-size (8 times larger).
With a decaying step-size (figure below), the initial conditions are forgotten reasonably fast and the iterates converge to the global optimum (and of course, we get an anytime algorithm!).
Stochastic gradient descent (averaged or not), with decreasing step-size.
We can now compare in terms of function values, showing that a constant step-size only works well for a specific range of iteration numbers.
Comparison of expected performance for decaying and constant-step sizes. Several constant step-sizes are tested, with uniform spacings in log-scale (hence the the uniform spacings in performance for large n).
Conclusion
Being able to deal with decaying step-sizes and anytime algorithms is arguably not a major improvement, but quite a satisfactory one, at least to me! Discrete integration by parts is the key enabler here.
There is another rewarding aspect which is totally unrelated to integration by parts: when applied to supervised machine learning, we just obtained from elementary principles (convexity) and few calculations a generalization bound on unseen data, which is as good as regular bounds from statistics [10] that use much more complex tools such as Rademacher complexities (but typically no convexity assumptions): here, statistics considered independently from optimization is not only slower (considering the empirical risk and minimizing it using the plain non-stochastic subgradient method would lead to an n times slower algorithm) but also more difficult to analyze!