SGD: General Analysis and Improved Rates

Robert Mansel Gower, Nicolas Loizou, Xun Qian, Alibek Sailanbayev, Egor Shulgin, Peter Richtarik

Introduction

Stochastic gradient descent (SGD) Robbins & Monro (1951); Nemirovski & Yudin (1978; 1983); Shalev-Shwartz et al. (2007); Nemirovski et al. (2009); Hardt et al. (2016), has become the workhorse for training supervised machine learning problems which have the generic form (1).

Linear convergence of SGD. Moulines & Bach (2011) provided a non-asymptotic analyses of SGD showing linear convergence for strongly convex ff up to a certain noise level. Needell et al. (2016) improved upon these results by removing the quadratic dependency on the condition number in the iteration complexity results, and considered importance sampling. The analysis of Needell et al. (2016) was later extended to a mini-batch variant where the mini-batches are formed by partitioning the data Needell & Ward (2017). These works are the main starting point for ours.

Contributions: We further tighten and generalize these results to virtually all forms of sampling. We introduce an expected smoothness assumption (Assumption 2.1), first introduced in Gower et al. (2018) in the context of a certain class of variance-reduced methods. This assumption is a joint property of ff and the sampling scheme D{\cal D} utilized by an SGD method, and allows us prove a generic complexity result (Theorem 3.1) that holds for arbitrary sampling schemes D{\cal D}. Our work is the first time SGD is analysed under this assumption. We obtain linear convergence rates without strong convexity; in particular, assuming strong quasi-convexity (this class includes some non-convex functions as well). Furthermore, we do not require the functions fif_{i} to be convex.

Contributions: Our analysis does not directly assume a growth condition. Instead, we make use of the remarkably weak expected smoothness assumption.

Optimal mini-batch size. Recently it was experimentally shown by Goyal et al. (2017) that using larger mini-batches sizes is key to efficient training of large scale non-convex problems, leading to the training of ImageNet in under 1 hour. The authors conjectured that the stepsize should grow linearly with the mini-batch size.

Contributions: We prove (see Section 4) that this is the case, upto a certain optimal mini-batch size, and provide exact formulas for the dependency of the stepsizes on the mini-batch sizes.

Learning schedules. Chee & Toulis (2018) develop techniques for detecting the convergence of SGD within a region around the solution.

Contributions: We provide a closed-form formula for when should SGD switch from a constant stepsize to a decreasing stepsize (see Theorem 3.2). Further, we clearly show how the optimal stepsize (learning rate) increases and the iteration complexity decreases as the mini-batch size increases for both independent sampling and sampling with replacement. We also recover the well known L/μlog⁡(1/ϵ)L/\mu\log(1/\epsilon) convergence rate of gradient descent (GD) when the mini-batch size is nn; this is the first time a generic SGD analysis recovers the correct rate of GD.

Over-parameterized models. There has been some recent work in analysing SGD in the setting where the underlying model being trained has more parameters than there is data available. In this zero–noise setting, Ma et al. (2018) showed that SGD converges linearly.

Contributions: In the case of over-parametrized models, we extend the findings of Ma et al. (2018)Recently, the results of Ma et al. (2018) were extended to the accelerated case by Vaswani et al. (2018); however, we do not study accelerated methods in this work. to independent sampling and sampling with replacement by showing that the optimal mini-batch size is 11. Moreover, we provide results in the more general setting where the model is not necessarily over-parametrized.

Practical performance. We corroborate our theoretical results with extensive experimental testing.

2 Stochastic reformulation

In this work we provide a single theorem through which we can analyse all importance sampling and mini-batch variants of SGD. To do this, we need to introduce a sampling vector which we will use to re-write our problem (1).

With each distribution D{\cal D} we now introduce a stochastic reformulation of (1) as follows

By the definition of the sampling vector, fv(x)f_{v}(x) and ∇fv(x)\nabla f_{v}(x) are unbiased estimators of f(x)f(x) and ∇f(x),\nabla f(x), respectively, and hence probem (4) is indeed equivalent (i.e., a reformulation) of the original problem (1). In the case of the gradient, for instance, we get

Similar but different stochastic reformulations were recently proposed by Richtárik & Takáč (2017) and further used in (Loizou & Richtárik, 2017; 2019) for the more special problem of solving linear systems, and by Gower et al. (2018) in the context of variance-reduced methods. Reformulation (4) can be solved using SGD in a natural way:

where vk∼Dv^{k}\sim{\cal D} is sampled i.i.d. at each iteration and γk>0\gamma^{k}>0 is a stepsize. However, for different distributions D{\cal D}, (6) has a different interpretation as an SGD method for solving the original problem (1). In our main result we will analyse (6) for any D{\cal D} satisfying (3). By substituting specific choices of D{\cal D}, we obtain specific variants of SGD for solving (1).

Expected Smoothness and Gradient Noise

In our analysis of SGD (6) applied to the stochastic reformulation (4) we rely on a generic and remarkably weak assumption of expected smoothness, which we now define and relate to existing growth conditions.

Expected smoothness Gower et al. (2018) is an assumption that combines both the properties of the distribution D{\cal D} and the smoothness properties of function ff.

We say that ff is L{\cal L}–smooth in expectation with respect to distribution D{\cal D} if there exists L=L(f,D)>0{\cal L}={\cal L}(f,{\cal D})>0 such that

There are scenarios where the above inequality is tight. Indeed, in the setting of stochastic reformulations of linear systems considered in Richtárik & Takáč (2017), one has fv(x)=12∥∇fv(x)∥2f_{v}(x)=\frac{1}{2}\|\nabla f_{v}(x)\|^{2}, ∇fv(x∗)=0\nabla f_{v}(x^{*})=0 and fv(x∗)=0f_{v}(x^{*})=0, which means that (7) holds as an identity with L=1{\cal L}=1.

In Section 3.3 we show how convexity and LiL_{i}–smoothness of fif_{i} implies expected smoothness. However, the opposite implication does not hold. Indeed, the expected smoothness assumption can hold even when the fif_{i}’s and ff are not convex, as we show in the next example.

where the last inequality follows from Proposition A.1. So, (f,D)∼ES(L)(f,{\cal D})\sim ES({\cal L}) for L=θLϕn2{\cal L}=\frac{\theta L_{\phi}}{n^{2}}.

2 Gradient noise

Our second key assumption is finiteness of gradient noise, defined next:

The gradient noise σ=σ(f,D)\sigma=\sigma(f,{\cal D}), defined by

3 Key lemma and connection to the weak growth condition

When the gradient noise is zero (σ=0\sigma=0), inequality (9) is known as the weak growth condition Vaswani et al. (2018). We have the following corollary:

If (f,D)∼ES(L)(f,{\cal D})\sim ES({\cal L}) and if σ=0\sigma=0, then ff satisfies the weak growth condition

This corollary should be contrasted with Proposition 2 in Vaswani et al. (2018) and Lemma 1 in Nguyen et al. (2018), where it is shown, by assuming the fif_{i} functions to be smooth and convex, that the weak growth condition holds with ρ=2Lmax⁡\rho=2L_{\max}. However, as we will show in Lemma E.1, Lmax⁡≥LL_{\max}\geq{\cal L}, and hence our bound is often tighter.

Convergence Analysis

We now present our main theorem, and include its proof to highlight how we make use of expected smoothness and gradient noise.

Assume ff is μ\mu-quasi-strongly convex and that (f,D)∼ES(L)(f,{\cal D})\sim ES({\cal L}). Choose γk=γ∈(0,12L]\gamma^{k}=\gamma\in(0,\frac{1}{2{\cal L}}] for all kk. Then iterates of SGD given by (6) satisfy:

Hence, given any ϵ>0\epsilon>0, choosing stepsize

Let rk=xk−x∗r^{k}=x^{k}-x^{*}. From (6), we have

Taking expectation conditioned on xkx^{k} we obtain:

Taking expectations again and using Lemma 2.4:

where we used in the last inequality that 2γL≤12\gamma{\cal L}\leq 1 since γ≤12L.\gamma\leq\frac{1}{2{\cal L}}. Recursively applying the above and summing up the resulting geometric series gives

To obtain an iteration complexity result from the above, we use standard techniques as shown in Section A.1. ∎

Note that we do not assume fif_{i} nor ff to be convex. Theorem 3.1 states that SGD converges linearly up to the additive constant 2γσ2/μ2\gamma\sigma^{2}/\mu which depends on the gradient noise σ2\sigma^{2} and on the stepsize γ\gamma. We obtain a more accurate solution with a smaller stepsize, but then the convergence rate slows down. Since we control D{\cal D}, we also control σ2\sigma^{2} and L{\cal L} (we compute these parameters for several distributions D{\cal D} in Section 3.3).

Furthermore, we can control this additive constant by carefully choosing the stepsize, as shown in the next result.

Assume ff is μ\mu-quasi-strongly convex and that (f,D)∼ES(L)(f,{\cal D})\sim ES({\cal L}). Let K:=L/μ\mathcal{K}:=\left.{\cal L}\right/\mu and

If k≥4⌈K⌉k\geq 4\lceil\mathcal{K}\rceil, then SGD iterates given by (6) satisfy:

2 Choosing 𝒟𝒟{\cal D}

For (6) to be efficient, the sampling vector vv should be sparse. For this reason we will construct vv so that only a (small and random) subset of its entries are non-zero.

The first analysis of a randomized optimization method with an arbitrary (proper) sampling was performed by Richtárik & Takáč (2016) in the context of randomized coordinate descent for strongly convex functions. This arbitrary sampling paradigm was later adopted in many other settings, including accelerated coordinate descent for strongly convex functions Hanzely & Richtárik (2018), coordinate and accelerated descent for convex functions Qu & Richtárik (2016), primal-dual methods Qu et al. (2015); Chambolle et al. (2018), variance-reduced methods with convex Csiba & Richtárik (2015) and nonconvex Horváth & Richtárik (2018) objectives. Arbitrary sampling arises as a special case of our more general analysis by specializing the sampling vector to one dependent on a sampling SS. We now define practical sampling vector v=v(S)v=v(S) as follows:

Let SS be a proper sampling, and let P^=Diag(p1,...,pn).{\hat{\bf P}}={\rm Diag}(p_{1},...,p_{n}). Then the random vector v=v(S)v=v(S) given by

We can further specialize and define the following commonly used samplings. Each sampling SS gives rise to a particular sampling vector v=v(S)v=v(S) (i.e., distribution D{\cal D}), which in turn gives rise to a particular stochastic reformulation (4) and SGD variant (6).

Independent sampling. The sampling SS includes every ii, independently, with probability pi>0p_{i}>0. This type of sampling was considered in different contexts in Horváth & Richtárik (2018); Hanzely & Richtárik (2018).

By assuming that the fif_{i} functions are convex and smooth we can calculate closed form expressions for the expected smoothness L{\cal L} and gradient noise σ2\sigma^{2}. In particular we make the following smoothness assumption:

To better relate the above assumption to the standard smoothness assumptions we make the following remark.

As a consequence of Assumption 3.4 we also have that each fif_{i} is Li:=λmax⁡(Mi)L_{i}:=\lambda_{\max}({\bf M}_{i})–smooth and ff is L:=1nλmax⁡(∑i=1nMi)L:=\frac{1}{n}\lambda_{\max}(\sum_{i=1}^{n}{\bf M}_{i})–smooth. Let Lmax⁡:=max⁡i∈[n]Li.L_{\max}:=\max_{i\in[n]}L_{i}.

Using Assumption 3.4 and a sampling we establish the following bounds on L{\cal L}.

and LC:=1nλmax⁡(∑j∈C1pjMj)L_{C}:=\frac{1}{n}\lambda_{\max}(\sum_{j\in C}\frac{1}{p_{j}}{\bf M}_{j}). If ∣S∣≡τ|S|\equiv\tau, then

By applying the above result to specific samplings, we obtain the following practical bounds on L{\cal L}:

(i) For single element sampling SS, we have

(ii) For partition sampling SS with partition G{\cal G}, we have

For τ\tau-nice sampling and independent sampling, we get the following very informative bounds on L{\cal L}.

(iii) For independent sampling SS, we have

Gazagnadou et al. (2019) were the first to suggest using (24) as an approximation for L{\cal L}. Through extensive experiments, they showed that the bound (24) is very tight. Here we give the first proof that (24) is indeed a valid upper bound.

For v=v(S)v=v(S) given by (17), formulas for the gradient noise σ2\sigma^{2} are provided in the next result:

Specializing the above theorem to specific samplings SS gives the following formulas for σ2\sigma^{2}:

(i) For single element sampling SS, we have

(iii) For τ\tau-nice sampling SS, we have

(iv) For partition sampling SS with partition G{\cal G}, we have

Generally, we do not know the values of hi=∇fi(x∗)h_{i}=\nabla f_{i}(x^{*}). But if we have prior knowledge that x∗x^{*} belongs to some set C{\cal C}, we can obtain upper bounds for σ2\sigma^{2} for these samplings from Proposition 3.10 in a straightforward way.

Optimal Mini-Batch Size

Here we develop the iteration complexity for different samplings by plugging in the bounds on L{\cal L} and σ\sigma given in Section 3.3 into Theorem 3.1. To keep the notation brief, in this section we drop the logarithmic term log⁡(2∥x0−x∗∥2/ϵ)\log\left(2\|x^{0}-x^{*}\|^{2}/\epsilon\right) from the iteration complexity results. Furthermore, for brevity and to better compare our results to others in the literature, we will use Li=λmax⁡(Mi)L_{i}=\lambda_{\max}({\bf M}_{i}) and Lmax⁡=max⁡i∈[n]LiL_{\max}=\max_{i\in[n]}L_{i} (see Remark 3.5). Finally let h‾=1n∑i∈[n]∥hi∥2\overline{h}=\frac{1}{n}\sum_{i\in[n]}\|h_{i}\|^{2} for brevity.

Gradient descent. As a first sanity check, we consider the case where ∣S∣=n|S|=n with probability one. That is, each iteration (6) uses the full batch gradient. Thus σ=0\sigma=0 and it is not hard to see that for τ=n\tau=n in (24) or pi=1p_{i}=1 for all ii in (23) we have Lmax⁡=L.{\cal L}_{\max}=L. Consequently, the resulting iteration complexity (12) is now k≥2L/μk\geq 2L/\mu. This is exactly the rate of gradient descent, which is precisely what we would expect since the resulting method is gradient descent. Though an obvious sanity check, we believe this is the first convergence theorem of SGD that includes gradient descent as a special case. Clearly, this is a necessary pre-requisite if we are to hope to understand the complexity of mini-batching.

To better appreciate how our iteration complexity evolves with increased mini-batch sizes, we now consider independent sampling with ∣S∣=τ|S|=\tau and τ\tau-nice sampling.

Independent sampling. Inserting the bound on L{\cal L} (23) and σ\sigma (27) into (12) gives the following iteration complexity

This is a completely new mini-batch complexity result, which opens up the possibility of optimizing the mini-batch size and probabilities of sampling. For instance, if we fix uniform probabilities with pi=τnp_{i}=\frac{\tau}{n} then (30) becomes k≥2μmax⁡{l(τ),r(τ)}k\geq\frac{2}{\mu}\max\left\{l(\tau),r(\tau)\right\}, where

This complexity result corresponds to using the stepsize

if τ<n\tau<n, otherwise only the left-hand-side term in the minimization remains. The stepsize (32) is increasing since both l(τ)l(\tau) and r(τ)r(\tau) decrease as τ\tau increases.

With such a simple expression for the iteration complexity we can choose a mini-batch size that optimizes the total complexity. By defining the total complexity T(τ)T(\tau) as the number of iterations kk times the number of gradient evaluations (τ\tau) per iteration gives

Minimizing T(τ)T(\tau) in τ\tau is easy because T(τ)T(\tau) is a max of a linearly increasing term τ×l(τ)\tau\times l(\tau) and a linearly decreasing term τ×r(τ)\tau\times r(\tau) in τ\tau. Furthermore n×l(n)≥0=n×r(n)n\times l(n)\geq 0=n\times r(n). Consequently, if l(1)≥r(1)l(1)\geq r(1), then τ∗=1\tau^{*}=1, otherwise

Since r(1)r(1) is proportional to the noise and 1/ϵ1/\epsilon and l(1)l(1) is proportional to the smoothness constants the condition l(1)≤r(1)l(1)\leq r(1) holds when there is comparatively a lot of noise or the precision is high. As we will see in Section 4.2 this logic extends to the case where the noise is zero, where the optimal mini-batch size is τ∗=1.\tau^{*}=1.

τ\tau–nice sampling. Inserting the bound on L{\cal L} (24) and σ\sigma (28) into (12) gives the iteration complexity k≥2μmax⁡{l(τ),r(τ)}k\geq\frac{2}{\mu}\max\{l(\tau),r(\tau)\}, where

Again, this is an increasing function in τ.\tau.

We are now again able to calculate the mini-batch size that optimizes the total complexity T(τ)T(\tau) given by T(τ)=2τμmax⁡{l(τ),r(τ)}.T(\tau)=\frac{2\tau}{\mu}\max\{l(\tau),r(\tau)\}. Once again T(τ)T(\tau) is a max of a linearly increasing term τ×l(τ)\tau\times l(\tau) and a linearly decreasing term τ×r(τ)\tau\times r(\tau) in τ\tau. Furthermore r(n)=0≤l(n)r(n)=0\leq l(n). Consequently, if r(1)≤l(1)r(1)\leq l(1) then τ∗=1\tau^{*}=1, otherwise

2 Zero gradient noise

Consider the case where the gradient noise is zero (σ=0\sigma=0). According to Theorem 3.1, the resulting complexity of SGD with constant stepsize γ=12L\gamma=\frac{1}{2{\cal L}} is given by the very simple expression

where we have dropped the logarithmic term log⁡(∥x0−x∗∥2/ϵ)\log\left(\left.\|x^{0}-x^{*}\|^{2}\right/\epsilon\right). In this setting, due to Corollary 2.5, we know that ff satisfies the weak growth condition. Thus our results are directly comparable to those developed in Ma et al. (2018) and in Vaswani et al. (2018).

In particular, Theorem 1 in Ma et al. (2018) states that when running SGD with mini-batches based on sampling with replacement, the resulting iteration complexity is

again dropping the logarithmic term. Now gaining insight into the complexity (39) is a matter of studying the expected smoothness parameter L{\cal L} for different sampling strategies.

Independent sampling. Setting σ=0\sigma=0 (thus h‾=0\overline{h}=0) and using uniform probabilities with pi=τnp_{i}=\frac{\tau}{n} in (30) gives

τ\tau –nice sampling. If we use a uniform sampling and σ=0\sigma=0 then the resulting iteration complexity is given by

Iteration complexities (40), (41) and (42) tell essentially the same story. Namely, the complexity improves as τ\tau increases to nn, but this improvement is not enough when considering the total complexity (multiplying by τ\tau). Indeed, for total complexity, these results all say that τ=1\tau=1 is optimal.

Importance Sampling

For single element sampling, plugging (21) and (26) into (12) gives the following iteration complexity

where 0<pi≤10<p_{i}\leq 1 and ∑i∈[n]pi=1\sum_{i\in[n]}p_{i}=1. In order to optimize this iteration complexity over pip_{i}, we need to solve a nn dimensional linearly constrained nonsmooth convex minimization problem, which could be harder than the original problem (1). So instead, we will focus on minimizing Lmax⁡{\cal L}_{\max} and σ2\sigma^{2} over pip_{i} seperately. We will then use these two resulting (sub)optimal probabilities to construct a sampling.

In particular, for single element sampling we can recover the partially biased sampling developed in Needell et al. (2016). First, from (21) it is easy to see that the probabilities that minimize Lmax⁡{\cal L}_{\max} are piL=Li/∑j∈[n]Lj,p_{i}^{\cal L}=\left.L_{i}\right/\sum_{j\in[n]}L_{j}, for all ii. Using these suboptimal probabilities we can construct a partially biased sampling by letting p^i:=12piL+12n.\hat{p}_{i}:=\frac{1}{2}p_{i}^{\cal L}+\frac{1}{2n}. Plugging this sampling in (21) gives Lmax⁡≤2L‾:=2n∑i∈[n]Li{\cal L}_{\max}\leq 2\overline{L}:=\frac{2}{n}\sum_{i\in[n]}L_{i}, and from (26), we have σ2≤2n∑i∈[n]∥hi∥2:=2h‾\sigma^{2}\leq\frac{2}{n}\sum_{i\in[n]}\|h_{i}\|^{2}:=2\overline{h}. This sampling is the same as the partially biased sampling in Needell et al. (2016). From (30) in Theorem 3.1, we get that the total complexity is now given by

For uniform sampling, Lmax⁡=max⁡i∈[n]Li≥L‾{\cal L}_{\max}=\max_{i\in[n]}L_{i}\geq\overline{L} and σ2=1n∑i∈[n]∥hi∥2\sigma^{2}=\frac{1}{n}\sum_{i\in[n]}\|h_{i}\|^{2}. Hence, compared to uniform sampling, the iteration complexity of partially biased sampling is at most two times larger, but could be n/2n/2 smaller in the extreme case where Lmax⁡=n L‾.L_{\max}=n\,\overline{L}.

2 Minibatches

Importance sampling for minibatches was first considered in (Csiba & Richtárik, 2018); but not in the context of SGD. Here we propose the first importance sampling for minibatch SGD. In Section J.2 in the appendix we introduce the use of partially biased sampling together with independent sampling with ∣S∣=τ|S|=\tau and show that we can achieve a total complexity of (by Proposition J.3)

which not only eliminates the dependence on Lmax⁡L_{\max}, but also improves as the mini-batch size τ\tau increases.

Experiments

In this section, we empirically validate our theoretical results. We perform three experiments in each of which we highlight a different aspect of our contributions.

In the first two experiments we focus on ridge regression and regularized logistic regression problems (problems with strongly convex objective ff and components fif_{i}) and we evaluate the performance of SGD on both synthetic and real data. In the second experiment (Section 6.2) we compare the convergence of SGD for several choices of the distribution D{\cal D} (different sampling strategies) as described in Section 3.2. In the last experiment (Section 6.3) we focus on the problem of principal component analysis (PCA) which by construction can be seen as a problem with a strongly convex objective ff but with non-convex functions fif_{i} Allen-Zhu & Yuan (2016); Garber & Hazan (2015); Shalev-Shwartz (2016).

In all experiments, to evaluate SGD we use the relative error measure ∥xk−x∗∥2∥x0−x∗∥2\frac{\|x^{k}-x^{*}\|^{2}}{\|x^{0}-x^{*}\|^{2}}. For all implementations, the starting point x0x^{0} is sampled from the standard Gaussian. We run each method until ∥xk−x∗∥2≤10−3\|x^{k}-x^{*}\|^{2}\leq 10^{-3} or until a pre-specified maximum number of epochs is achieved. For the horizontal axis we always use the number of epochs.

For more experiments we refer the interested reader to Section K of the Appendix.

Regularized Regression Problems: In the case of the ridge regression problem we solve:

while for the L2L2-regularized logistic regression problem we solve:

We now compare the performance of SGD in the constant and decreasing stepsize regimes considered in Theorems 3.1 (see (11)) and 3.2 (see (14)), respectively. Here we use a uniform single element sampling. As expected from theory, we see in Figure 1 that the decreasing stepsize regime is vastly superior at reaching a higher precision than the constant step-size variant. In our plots, the vertical red line denotes the value of 4⌈L/μ⌉4\lceil\mathcal{\left.{\cal L}\right/\mu}\rceil predicted from Theorem 3.2 and highlights the point where SGD needs to change its update rule from constant to decreasing step-size.

2 Minibatches

In Figures 2 and 5 we compare the single element sampling (uniform and importance), τ\tau independent sampling (uniform, uniform with optimal batch size and importance) and τ\tau nice sampling (with some τ\tau and with optimal τ∗\tau^{*}). The probabilities of importance samplings in the single element sampling and τ\tau independent sampling are calculated by formulas (67) and (77) in the Appendix. Formulas for optimal minibatch size τ∗\tau^{*} in independent sampling and τ\tau-nice samplings are given in (34) and (38), respectively. Observe that minibatching with optimal τ∗\tau^{*} gives the best convergence. In addition, note that for constant step size, the importance sampling variants depend on the accuracy ϵ\epsilon. From Figure 2 we can see that before the error reaches the required accuracy, the importance sampling variants are comparable or better than their coresponding uniform sampling variants.

3 Sum-of-non-convex functions

where Di,D_{i}, i∈[n]i\in[n] are diagonal matrices satisfying D:=D1+⋯+Dn=0D:=D_{1}+\cdots+D_{n}=0. In particular, to guarantee that D=0D=0, we randomly select half of the matrices and assign their jj-th diagonal value (Di)jj(D_{i})_{jj} equal to 1111; for the other half we assign (Di)jj(D_{i})_{jj} to be −11-11. We repeat that for all diagonal values. Note that under this construction, each fif_{i} is a non-convex function. Once again, in the first plot we observe that while both are equally fast in the beginning, the decreasing stepsize variant is better at reaching higher accuracy than the fixed stepsize variant. In the second plot we see, as expected, that all four minibatch versions of SGD outperform single element SGD. However, while the τ\tau-nice and τ\tau-independent samplings with τ=n/5\tau=n/5 lead to a slight improvement only, the theoretically optimal choice τ=τ∗\tau=\tau^{*} leads to a vast improvement.

Acknowledgements

RMG acknowledges the support by a public grant as part of the Investissement d’avenir project, reference ANR-11-LABX-0056-LMH, LabEx LMH, in a joint call with Gaspard Monge Program for optimization, operations research and their interactions with data sciences.

References

Appendix A Elementary Results

In this section we collect some elementary results; some of them we use repeatedly.

Lipschitz continuity of the gradient implies that

Now plugging h=−1Lϕ∇ϕ(x)h=-\frac{1}{L_{\phi}}\nabla\phi(x) into the above inequality, we get 12Lϕ∥∇ϕ(x)∥2≤ϕ(x)−ϕ(x+h)≤ϕ(x)−ϕ(x∗)\frac{1}{2L_{\phi}}\|\nabla\phi(x)\|^{2}\leq\phi(x)-\phi(x+h)\leq\phi(x)-\phi(x^{*}). It remains to note that ∇ϕ(x∗)=0\nabla\phi(x^{*})=0. ∎

In this section we summarize some elementary results which we use often in our proofs. We do not claim novelty; we but we include them for completeness and clarity.

Taking logarithms and rearranging (47) gives

Now using that log⁡(1ρ)≥1−ρ,\log\left(\frac{1}{\rho}\right)\geq 1-\rho, for 0<ρ≤10<\rho\leq 1 gives (46). ∎

To analyse the iteration complexity, let ϵ>0\epsilon>0 and choosing the stepsize so that 2γσ2μ≤12ϵ,\frac{2\gamma\sigma^{2}}{\mu}\leq\frac{1}{2}\epsilon, gives (11). Next we choose kk so that

Taking logarithms and re-arranging the above gives

Now using that log⁡(1ρ)≥1−ρ,\log\left(\frac{1}{\rho}\right)\geq 1-\rho, for 0<ρ≤10<\rho\leq 1 gives

Appendix B Proof of Lemma 2.4

The first inequality follows from the estimate ∥a+b∥2≤2∥a∥2+2∥b∥2\|a+b\|^{2}\leq 2\|a\|^{2}+2\|b\|^{2}, and the second inequality follows from (7).

Appendix C Proof of Theorem 3.2

Let γk:=2k+1(k+1)2μ\gamma_{k}:=\frac{2k+1}{(k+1)^{2}\mu} and let k∗k^{*} be an integer that satisfies γk∗≤12L.\gamma_{k^{*}}\leq\frac{1}{2{\cal L}}. In particular this holds for

Note that γk\gamma_{k} is decreasing in kk and consequently γk≤12L\gamma_{k}\leq\frac{1}{2{\cal L}} for all k≥k∗.k\geq k^{*}. This in turn guarantees that (13) holds for all k≥k∗k\geq k^{*} with γk\gamma_{k} in place of γ\gamma, that is

Multiplying both sides by (k+1)2(k+1)^{2} we obtain

where the second inequality holds because 2k+1k+1<2\frac{2k+1}{k+1}<2. Rearranging and summing from t=k∗…kt=k^{*}\ldots k we obtain:

For k≤k∗k\leq k^{*} we have that (13) holds, which combined with (53), gives

Choosing k∗k^{*} that minimizes the second line of the above gives k∗=4⌈K⌉k^{*}=4\lceil\mathcal{K}\rceil, which when inserted into (54) becomes

where we have used that (1−12x)4x≤e−2\left(1-\frac{1}{2x}\right)^{4x}\leq e^{-2} for all x≥1.x\geq 1.

Appendix D Proof of Theorem 3.6

Since vi=vi(S)=1(i∈S)1piv_{i}=v_{i}(S)=\mathbf{1}_{(i\in S)}\frac{1}{p_{i}}. and since fif_{i} is Mi{\bf M}_{i}-smooth, the function

We also define the following smoothness related quantities

Let y=x∗y=x^{*} and notice that ∇f(x∗)=0\nabla f(x^{*})=0, which gives (19). We prove (20) in the following slightly more comprehensive Lemma E.1. ∎

Appendix E Bounds on the Expected Smoothness Constant ℒℒ{\cal L}

Below we establish some lower and upper bounds on the expected smoothness constant L=Lmax⁡{\cal L}={\cal L}_{\max}. These bounds were referred to in the main paper in Section 2.3. We also make use of notation introduced in Section 3.3.

Assume that there exists τ∈[n]\tau\in[n] such that ∣S∣=τ|S|=\tau with probability 1. Let

Define MS:=1n∑i∈SMipi{\bf M}_{S}:=\frac{1}{n}\sum_{i\in S}\frac{{\bf M}_{i}}{p_{i}} and note that ff is 1n∑i∈[n]Mi\frac{1}{n}\sum_{i\in[n]}{\bf M}_{i}–smooth. Furthermore

We will now establish the inequalities in (61) starting from left to the right.

(Part III Lmax⁡≤Lmax⁡{\cal L}_{\max}\leq L_{\max}). Finally, since

Consequently taking the maximum over i∈[n]i\in[n] in the above gives Lmax⁡≤Lmax⁡.{\cal L}_{\max}\leq L_{\max}. ∎

Appendix F Proof of Proposition 3.7

First note that by combining (19) and (D) we have that

(i) By straight forward calculation from (63) and using that each set CC is a singleton.

(ii) For every partition sampling we have that pi=pCp_{i}=p_{C} if i∈Ci\in C, hence

Appendix G Proof of Proposition 3.8

First, since fif_{i} is LiL_{i}-smooth with Li=λmax⁡(Mi)L_{i}=\lambda_{\max}({\bf M}_{i}) and convex, it follows from equation (2.1.7) in Theorem 2.1.5 in Nesterov (2013) that

Now consider the case where Pij/(pipj)=c2{\bf P}_{ij}/(p_{i}p_{j})=c_{2} for i≠j.i\neq j. Recalling that Pii=pi{\bf P}_{ii}=p_{i} we have from the above that

Substituting y=x∗y=x^{*} and comparing the above to the definition of expected smoothness (7) we have that

(i) For independent sampling, we have that Pij=pipj{\bf P}_{ij}=p_{i}p_{j} for i≠ji\neq j, consequently c2=1.c_{2}=1. Thus (66) gives (23).

(ii) For τ\tau-nice sampling, we have that Pij=τ(τ−1)n(n−1){\bf P}_{ij}=\frac{\tau(\tau-1)}{n(n-1)} for j≠ij\neq i and Pii=pi=τn{\bf P}_{ii}=p_{i}=\frac{\tau}{n}, hence c2=n(τ−1)τ(n−1)c_{2}=\frac{n(\tau-1)}{\tau(n-1)} and (66) gives (24). ∎

Appendix H Proof of Theorem 3.9

Appendix I Proof of Proposition 3.10

(ii) For independent sampling SS, Pij=pipj{\bf P}_{ij}=p_{i}p_{j} for i≠ji\neq j, hence,

(iii) For τ\tau-nice sampling SS, if τ=1\tau=1, it is obvious. If τ≥1\tau\geq 1, then Pij=Cn−2τ−2Cnτ{\bf P}_{ij}=\frac{C_{n-2}^{\tau-2}}{C_{n}^{\tau}} for i≠ji\neq j, and pi=τnp_{i}=\frac{\tau}{n} for all ii. Hence,

(iv) For partition sampling, Pij=pC{\bf P}_{ij}=p_{C} if i,j∈Ci,j\in C, and Pij=0{\bf P}_{ij}=0 otherwise. Hence,

Appendix J Importance sampling

From (21) it is easy to see that the probabilities that minimize Lmax⁡{\cal L}_{\max} are piL=Li/∑j∈[n]Lj,p_{i}^{\cal L}=\left.L_{i}\right/\sum_{j\in[n]}L_{j}, for all ii, and consequently Lmax⁡=L‾{\cal L}_{\max}=\overline{L}. On the other hand the probabilities that minimize (26) are given by piσ2=∥hi∥/∑j∈[n]∥hj∥,p_{i}^{\sigma^{2}}=\left.\|h_{i}\|\right/\sum_{j\in[n]}\|h_{j}\|, for all ii, with σ2=(∑i∈[n]∥hi∥/n)2:=σopt2\sigma^{2}=(\sum_{i\in[n]}\|h_{i}\|/n)^{2}:=\sigma_{opt}^{2}.

From piLp_{i}^{\cal L} and piσ2p_{i}^{\sigma^{2}}, we construct interpolated probabilities pip_{i} as follows:

where α∈(0,1)\alpha\in(0,1). Then 0<pi<10<p_{i}<1 and from (21) we have

Similarly, from (26) we have that σ2≤11−ασopt2\sigma^{2}\leq\frac{1}{1-\alpha}\sigma^{2}_{opt}. Now by letting pi=pi(α)p_{i}=p_{i}(\alpha), from (30) in Theorem 3.1, we get an upper bound of the right hand side of (12):

By minimizing this bound in α\alpha we can get

where the right hand side comes by setting α=1/2\alpha=1/2. Notice that the minimum of the iteration complexity in (12) is not less than max⁡{2L‾μ,4σopt2ϵμ2}\max\left\{\frac{2\overline{L}}{\mu},\frac{4\sigma^{2}_{opt}}{\epsilon\mu^{2}}\right\}. Hence, the iteration complexity of this importance sampling(left hand side of (70)) is at most two times larger than the minimum of the iteration complexity in (12) over pip_{i}.

J.2 Independent sampling

For the independent sampling SS, in this section we will use the following upper bound on L{\cal L} given by

which follows immediatly from (23) by using that L≤1n∑i=1nLi:=L‾.L\leq\frac{1}{n}\sum_{i=1}^{n}L_{i}:=\overline{L}.

Minimizing the upper bound of Lmax⁡{\cal L}_{\max} in (71) boils down to minimizing max⁡i∈[n](1pi−1)Li\max_{i\in[n]}(\frac{1}{p_{i}}-1)L_{i}, which is not easy generally. Instead, as a proxy we obtain the probabilities pip_{i} by solving

Let qi=Li∑j∈[n]Lj⋅τq_{i}=\frac{L_{i}}{\sum_{j\in[n]}L_{j}}\cdot\tau for all ii, and T={i∣qi>1}T=\{i|q_{i}>1\}. If T=∅T=\emptyset, it is easy to see pi=piL(τ)=qip_{i}=p_{i}^{\cal L}(\tau)=q_{i} solves (72). Otherwise, in order to solve (72), we can choose pi=piL(τ)=1p_{i}=p_{i}^{\cal L}(\tau)=1 for i∈Ti\in T, and qi≤pi=piL(τ)≤1q_{i}\leq p_{i}=p_{i}^{\cal L}(\tau)\leq 1 for i∉Ti\notin T such that ∑i∈[n]piL(τ)=τ\sum_{i\in[n]}p_{i}^{\cal L}(\tau)=\tau. By letting pi=piL(τ)p_{i}=p_{i}^{\cal L}(\tau), we have that (72) becomes

For σ2\sigma^{2}, from (27), we need to solve

Let qi=∥hi∥∑j∈[n]∥hj∥⋅τq_{i}=\frac{\|h_{i}\|}{\sum_{j\in[n]}\|h_{j}\|}\cdot\tau for all ii, and let T={i∣qi>1}T=\{i|q_{i}>1\}. If T=∅T=\emptyset, it is easy to see that pi=piσ2(τ)=qip_{i}=p_{i}^{\sigma^{2}}(\tau)=q_{i} solve (74). Otherwise, it is a little complicated to find the optimal solution. For simplicity, if T≠∅T\neq\emptyset, we choose pi=piσ2(τ)=1p_{i}=p_{i}^{\sigma^{2}}(\tau)=1 for i∈Ti\in T, and qi≤pi=piσ2(τ)≤1q_{i}\leq p_{i}=p_{i}^{\sigma^{2}}(\tau)\leq 1 for i∉Ti\notin T such that ∑i∈[n]piσ2(τ)=τ\sum_{i\in[n]}p_{i}^{\sigma^{2}}(\tau)=\tau. By letting pi=piσ2(τ)p_{i}=p_{i}^{\sigma^{2}}(\tau), from (27), we have

Importance sampling.

Since by (73) we have that Lmax⁡≤(1+1τ)L‾{\cal L}_{\max}\leq\left(1+\frac{1}{\tau}\right)\overline{L} and σ=σopt2(τ)\sigma=\sigma^{2}_{opt}(\tau) are obtained by using the upper bounds in (71) and (27), and the upper bounds are nonincreasing as pip_{i} increases, we get the following property.

If pi≥piL(τ)p_{i}\geq p_{i}^{\cal L}(\tau) for all ii, then Lmax⁡≤(1+1τ)L‾{\cal L}_{\max}\leq(1+\frac{1}{\tau})\overline{L}, and if pi≥piσ2(τ)p_{i}\geq p_{i}^{\sigma^{2}}(\tau), then σ2≤σopt2(τ)\sigma^{2}\leq\sigma^{2}_{opt}(\tau).

From Proposition J.1, we can get the following result.

For 0<α<10<\alpha<1, let pi(α)p_{i}(\alpha) satisfy

If pi=pi(α)p_{i}=p_{i}(\alpha) where pi(α)p_{i}(\alpha) satisfies (75), then we have

First , we claim that pi(α)p_{i}(\alpha) can be constructed to satisfy (75). Since 0<piL(α)≤10<p_{i}^{{\cal L}}(\alpha)\leq 1 and 0<piσ2((1−α)τ)≤10<p_{i}^{\sigma^{2}}((1-\alpha)\tau)\leq 1, we know

From (75), we have pi=pi(α)≥piL(ατ)p_{i}=p_{i}(\alpha)\geq p_{i}^{{\cal L}}(\alpha\tau). Then by Proposition J.1, we have

We also have pi(α)≥piσ2((1−α)τ)p_{i}(\alpha)\geq p_{i}^{\sigma^{2}}((1-\alpha)\tau), hence, by Proposition J.1, we get

From (12) in Theorem 3.1, by letting pi=pi(α)p_{i}=p_{i}(\alpha) in Proposition J.2, we get an upper bound of the right hand side of (12):

where a=2(∑i∈[n]∥hi∥n)2/(ϵμL‾)a=2(\frac{\sum_{i\in[n]}\|h_{i}\|}{n})^{2}/(\epsilon\mu\overline{L}). So suboptimal probabilities

where α\alpha is given in Equation (76).

Partially biased sampling.

In practice, we do not know ∥hi∥\|h_{i}\| generally. But we can use piL(τ)p_{i}^{{\cal L}}(\tau) and the uniform probability τn\frac{\tau}{n} to construct a new probability just as that in Proposition J.2. More specific, we have the following result.

The proof for Lmax⁡{\cal L}_{\max} is the same as Proposition J.2. For σ2\sigma^{2}, from (27), since pi≥τ/2np_{i}\geq\tau/2n, we have

This sampling is very nice in the sense that it can maintain Lmax⁡{\cal L}_{\max} at least close to L‾\overline{L}, and meanwhile, can acheive nearly linear speedup in σ2\sigma^{2} by increasing τ\tau. We can compare the upper bounds of Lmax⁡{\cal L}_{\max} and σ2\sigma^{2} for this sampling, τ\tau-nice sampling, and τ\tau-uniform independent sampling when 1<τ=O(1)1<\tau={\cal O}(1) in the following table.

From Table 1, compared to τ\tau-nice sampling and τ\tau-uniform independent sampling, the iteration complexity of this τ\tau-partially biased independent sampling is at most two times larger, but could be about 2τn\frac{2\tau}{n} smaller in some extremely case where Lmax⁡≈nLˉL_{\max}\approx n{\bar{L}} and 2L/μ2{\cal L}/\mu dominates in (12).

Appendix K Additional Experiments

Here we evaluate the choice of the switching moment from a constant to a decreasing step size according to (14) from Theorem 3.2. We are using synthetic data that was generated in the same way as it had been in the Section 6 for the ridge regression problem (n=1000,d=100)(n=1000,d=100). In particular we evaluate 4 different cases: (i) the theoretical moment of regime switch at moment kk as predicted from the Theorem, (ii) early switch at 0.3×k0.3\times k, (iii) late switch at 0.7×k0.7\times k and (iv) the optimal kk for switch, where the optimal kk is obtained using one-dimensional numerical minimization of (54) as a function of k∗k^{*}.

According to Figure 4, when x0x^{0} is close to x∗x^{*}, the moment of regime switch does not play a significant role in minimizing the number of iteration except for a very early switch, which actually also leads to almost the same situation in the long run. The case when x0x^{0} is far from x∗x^{*} shows that preliminary one-dimensional optimization makes sense and allows to reduce the error at least during the early iterations.

K.2 More on minibatches

Figure 5 reports on the same experiment as that described in Section 6.2 (Figure 2) in the main body of the paper, but on ridge regression instead of logistic regression, and using different data sets. Our findings are similar, and corroborate the conclusions made in Section 6.2.

K.3 Stepsize as a function of the minibatch size

In our last experiment we calculate the stepsize γ\gamma as a function of the minibatch size τ\tau for τ\tau-nice sampling using equation (37). Figure 6 depicts three plots, for three synthetic data sets of sizes (n,d)∈{(50,5),(100,10),(500,50)}(n,d)\in\{(50,5),(100,10),(500,50)\}. We consider regularized ridge regression problems with λ=1/n\lambda=1/n. Note that the stepsize is an increasing function of τ\tau.