Exponential Convergence Time of Gradient Descent for One-Dimensional Deep Linear Neural Networks
Ohad Shamir
Introduction
One of the biggest open problems in theoretical machine learning is to explain why deep artificial neural networks can be efficiently trained in practice, using simple gradient-based methods. Such training requires optimizing complex, highly non-convex objective functions, which seem intractable from a worst-case viewpoint. Over the past few years, much research has been devoted to this question, but it remains largely unanswered.
Trying to understand simpler versions of this question, significant attention has been devoted to linear neural networks, which are predictors mathematically defined as , with being a set of parameter matrices, and being the depth parameter (e.g. Saxe et al. 2013; Kawaguchi 2016; Hardt and Ma 2016; Lu and Kawaguchi 2017; Bartlett et al. 2018; Laurent and Brecht 2018). The optimization problem associated with training such networks can be formulated as
for some matrix-valued function . Although much simpler than general feedforward neural networks (which involve additional non-linear functions), it is widely believed that Eq. (1) captures important aspects of neural network optimization problems. Moreover, Eq. (1) has a simple algebraic structure, which makes it more amenable to analysis. In particular, it is known that when is convex and differentiable, Eq. (1) has no local minima except global ones (see Laurent and Brecht 2018 and references therein). In other words, if an optimization algorithm converges to some local minimum, then it must converge to a global minimum.
In this paper, we consider a simpler special case of Eq. (1), where the matrices are all scalars:
Before continuing, we emphasize that our results do not imply that gradient-based methods cannot learn deep linear networks in general. What they do imply is that one would need to make additional assumptions or algorithmic modifications to circumvent these negative results: For example, explicitly using the fact that the matrix sizes are larger than – something which is not clear how to do with current analyses – or having a fine-grained dependency on the variance of the random initialization, as further discussed in Sec. 4. Alternatively, our results might be circumvented using other gradient-based algorithms (for example, by adding random noise to the gradient updates or using adaptive step sizes), or other initialization strategies. However, that would not explain why plain gradient descent with standard random initializations is often practically effective on these problems. Overall, we believe our results point to a potential obstacle in understanding the convergence of gradient-based methods for linear networks: At the very least, one would have to rule out one-dimensional layers, or consider algorithms other than plain gradient descent with standard initializations, in order to establish polynomial-time convergence guarantees for deep linear networks.
Finally, we note that our results provide a possibly interesting contrast to the recent work of Arora et al. 2018b, which suggests that increasing depth can sometimes accelerate the optimization process. Here we show that at least in some cases, the opposite occurs: Adding depth can quickly turn a trivial optimization problem into an intractable one for gradient descent.
Preliminaries
Gradient Descent. We consider the standard gradient descent method for unconstrained optimization of functions in Euclidean space, which given an initialization point , performs repeated iterations of the form for (where is the gradient, and is a step size parameter). For objectives as in Eq. (2), we have , and gradient descent takes the form
Random Initialization. One of the most common initialization methods for neural networks is Xavier initialization (Glorot and Bengio 2010), which in the setting of Eq. (1) corresponds to choosing each entry of each matrix independently from a zero-mean distribution with variance (usually uniform or Gaussian). This ensures that the variance of the network outputs (with respect to the initialization) is constant irrespective of the network size. Motivated by residual networks, Hardt and Ma 2016 and Bartlett et al. 2018 consider initializing each independently at , possibly with some random perturbation. In this paper we denote such an initialization scheme as a near-identity initialization. Since we focus here on the case as in Eq. (2), Xavier initialization corresponds to choosing each independently from a zero-mean, unit-variance distribution, and near-identity initialization corresponds to choosing each close to .
Exponential Convergence Time for Gradient Descent
For our negative results, we impose the following mild conditions on the function in Eq. (2):
Here, we assume that is fixed, and our goal is to study the convergence time of gradient descent on Eq. (2) as a function of the depth . Some simple examples satisfying Assumption 1 in the context of machine learning include and (e.g., squared loss and logistic loss with respect to the input/output pair , respectively). We note that this non-symmetry with respect to positive/negative values is completely arbitrary, and one can prove similar results if their roles are reversed.
We begin with the case of Xavier initialization, where we initialize all coordinates of in Eq. (2) independently from a zero-mean, unit variance distribution. We will consider any distribution which satisfies the following:
are drawn i.i.d. from a zero-mean, unit variance distribution such that
for all
where are absolute constants independent of .
The first part of the assumption is satisfied for any distribution with bounded density. As to the second part, the following lemma shows that it is satisfied for uniform and Gaussian distributions (with an explicit ), and in fact for any non-trivial distribution (with a distribution-dependent – see also footnote 2):
With such an initialization, we now show that gradient descent is overwhelmingly likely to take at least exponential time to converge:
The following holds for some positive constants independent of : Under Assumptions 1 and 2, if gradient descent is ran with any step size , then with probability at least over the initialization, the number of iterations required to reach suboptimality less than is at least .
In the above, hides dependencies on the absolute constants in the theorem statement and the assumptions. The proof (as well as all other major proofs in this paper) is presented in Sec. 5.
The intuition behind the theorem is quite simple: Under our assumptions, it is easy to show that the product of any coordinates from is overwhelmingly likely to be exponentially small in . Since the derivative of our objective w.r.t. any has the form , it follows that the gradient is exponentially small in . Moreover, we show that the gradient is exponentially small at any point within a bounded distance from the initialization (which is the main technical challenge of the proof, since the gradient is by no means Lipschitz). As a result, gradient descent will only make exponentially small steps. Assuming we start from a point bounded away from a global minimum, it follows that the number of required iterations must be exponentially large in .
We note that the observation that Xavier initialization leads to highly skewed values in deep enough networks is not new (see Saxe et al. 2013; Pennington et al. 2017), and has motivated alternative initializations such as orthogonal initialization It is interesting to note that in our setting, orthogonal initialization amounts to choosing each in , which can easily cause non-convergence, e.g. for when and small enough step sizes. Our contribution here is to rigorously analyze how this affects the optimization process for our setting.
2 Near-Identity Initialization
We now turn to consider initializations where each is initialized close to . Here, it will be convenient to make deterministic rather than stochastic assumptions on the initialization point (which are satisfied with high probability for reasonable distributions):
For some absolute constants independent of , gradient descent is initialized at a point which satisfies and .
To justify this assumption, note that if are chosen i.i.d. and not in the range of for some , then their product is likely to explode or vanish with .
The following holds for some positive constants independent of : Under Assumptions 1 and 3, if gradient descent is ran with any positive step size , then the number of iterations required to reach suboptimality less than is at least .
As before, hides dependencies on the absolute constants in the theorem statement, as well as those in the assumptions.
The formal proof appears in Sec. 5. To help explain its intuition, we provide in Figure 1 the actual evolution of for a typical run of gradient descent, when and we initialize all coordinates reasonably close to . Recall that for any , the gradient descent updates take the form
where . Thus, initially, all parameters decrease with , as to be expected. However, as their value fall to around or below , their product decreases rapidly to . Since the gradient of each scales as , the magnitude of the gradients becomes very small, and the algorithm makes only slow progress. Eventually, one of the parameters becomes negative, in which case all other parameters start increasing, and the algorithm converges. However, by a careful analysis, the length of the slow middle phase can be shown to be exponential in the depth / number of parameters .
3 A Positive Result
We will use the following assumptions on our objective and parameters:
The following hold for some absolute positive constants independent of :
The initialization satisfies the following:
and
The assumptions and ensure that the objective satisfies the conditions of our negative results, for both Xavier and near-identity initializations (the other cases can be studied using similar techniques).
Multi-Dimensional Networks
So far, we showed that for one-dimensional linear neural networks, gradient descent can easily require exponentially many iterations (in the depth of the network) to converge. However, these results are specific to the case where the parameter matrix of each layer is one-dimensional, and do not necessarily extend to higher dimensions. A possibly interesting exception is when , and both and the initialization are diagonal matrices. In that case, it is easy to show that the matrices produced by gradient descent remain diagonal, and the objective can be rewritten as a sum of independent one-dimensional problems for which our results would apply. However, this reasoning fails for non-diagonal initializations and target matrices .
In this section, we study experimentally whether our theoretical results for one-dimensional networks might also extend to multi-dimensional ones. In particular, we consider the multi-dimensional generalization of the objective function studied earlier:
where are square matrices (for ), ( being the identity matrix), and is the Frobenius norm. We ran gradient descent on this objective using three initialization strategies:
Xavier initialization: Each entry of each matrix was initialized independently from a zero-mean Gaussian with variance .
Near-Identity initialization with smaller variance: Each was initialized as above, except that the variance of each entry in the matrix was .
For each random initialization strategy, and for depth parameter , we ran 50 trials of gradient descent, with a step size Our results did not seem to change significantly by taking other bounded step sizes. of , until either one of the following two stopping conditions occured:
The objective value dropped below (or equivalently, , a rather mild requirement).
The number of iterations exceeded iterations, in which case the algorithm was deemed to have failed to converge (note that from a practical viewpoint, one billion iterations is exceedingly large considering our problem size).
In Figure 2, we plot the mean and standard deviation for the logarithm of the number of iterations required to make the objective value less than (among the trials which converged). We also point out the percentage of trials which did not converge, if any.
The figure strongly suggests that using both Xavier initialization and near-identity initialization with small variance, the required runtime scales exponentially with the depth (recall that the -axis is in log scale). This indicates that the phenomenon of exponential scaling with depth is not just an artifact of one-dimensional networks, and can also occur in multi-dimensional networks, even with reasonable random initializations. On the flip side, when performing near-identity initialization with a large enough variance, we did not observe such an exponential scaling (as evidenced in the middle plot in the figure). Moreover, based on some additional experiments with other objective functions, it appears that although gradient descent can sometime require exponential time to converge, this phenomenon is not particularly common. A possible explanation to this is that in one dimension, had to change sign, and hence pass through zero (see Figure 1). This brought the iterates to a “flat” region with exponentially small gradients. In contrast, in multiple dimensions, to continuously change from a matrix to some other matrix, it is always possible to go “around” any particular point. Our experiments suggest that gradient descent indeed avoids problematic flat regions in many cases, but not always. Overall, it seems quite possible that for multi-dimensional networks, the exponential runtime dependence on the depth can be avoided under reasonable assumptions – however, some such assumptions would be necessary, and would need to exclude either objectives of the type we studied here, or some of the initializations. For example, such an analysis might need to explicitly separate between one-dimensional and multi-dimensional networks, or between near-identity initialization with variance and with variance (which are both polynomially large in ), and how to do so with existing analyses is currently unclear.
Proofs
The proof is based on the following two lemmas:
For any fixed , by Markov’s inequality and the i.i.d. assumption,
Taking a union bound over all , the result follows. ∎
We claim that it is enough to prove the following:
Indeed, this would imply that for any satisfying the conditions above, and any s.t. , we must have , and therefore , as well as by definition of , as required.
To prove Eq. (3), we first state and prove the following auxiliary result:
This statement holds by the following calculation:
where is due to the fact that is -Lipschitz in , and the assumption that .
Change the sign of every and to be positive
For any such that , change to equal .
Drop a coordinate which maximizes .
It is easy to verify that the resulting vectors satisfy the conditions of Eq. (4), and . Therefore, by Eq. (4), as required. ∎
With these two lemmas in hand, we turn to prove the theorem. By Lemma 2 and Assumption 2, we have
for some fixed constants and any large enough . Moreover, again by Assumption 2, it holds for any that , so by a union bound,
Finally, by Assumption 2, Markov’s inequality and a union bound,
Combining the last three displayed equations with a union bound, and applying Lemma 3 (with , , and ), we get the following: With probability at least over the choice of ,
.
For any at a distance at most from , we have
Since the gradient descent updates are of the form , and we can assume by the theorem’s conditions, the number of iterations required to get to a distance larger than from is at least
which is at least iterations.
As long as we are at a distance smaller than the above, . In particular, for large enough , so by Assumption 1 and definition of , we have that is lower bounded by a constant independent of .
Overall, we get that with probability at least , we initialize at some region in which all points are at least suboptimal, and at least iterations are required to escape it. This immediately implies our theorem.
2 Proof of Thm. 2
We begin with the following auxiliary lemma, and then turn to analyze the dynamics of gradient descent in our setting.
For any positive scalars such that ,
Taking the -th root and switching sides, the inequality in the lemma is equivalent to proving
Letting , and for all , the above is equivalent to proving that
namely that the sum of the geometric means of two positive sequences and is at most the geometric mean of their sum . This follows from the superadditivity of the geometric mean (see Steele 2004) ∎
If and for some positive constants , then for any ,
where is some constant dependent only on and the function .
By assumption, and . Therefore, by our assumptions on , the displayed equation above implies that
for some constant dependent on and as required. ∎
Suppose that at some iteration , for some constant independent of , it holds that and for some . Then after at most iterations, if for all , then
Each as well as monotonically decrease in
For all ,
.
In the above, hides constants dependent only on and the function .
If , we can pick , and the lemma trivially holds. Otherwise, let be the smallest (positive) index such that (if no such index exists, take , although the arguments below imply that must be finite). Since we assume for all are positive, and is monotonically increasing,
so monotonically decreases in . Moreover, these are all positive numbers by assumption, so monotonically decreases in as well. This shows the first part of the lemma.
As to the second part, the displayed equation above, the fact that and decrease in , and our assumptions on imply that for any ,
where hides constants dependent only on and . As to the third part of the lemma, fix some , and repeatedly apply the displayed equation above for , to get that that (which is still by the lemma assumptions). In that case,
where follows from Lemma 4 and the fact that . The right hand side in turn is at most for any for some constant . In particular, if , then by choosing s.t. , we get that even though , which contradicts the definition of . Hence as stated in the lemma. ∎
Combining Lemma 5 and Lemma 6, we have the following:
For any constants and index , if and for all and , then for all such ,
Each as well as monotonically decrease in .
.
In the above, hides constants dependent only on and the constants in Assumptions 1 and 3.
The first two parts of the lemma follow from Lemma 6 and the fact that by Assumption 3, . As to the last part, define (where ) as the first indices such that for all , (where is taken to be as large as possible). By Lemma 6, we have the following:
For all , .
.
For all and any , we have .
Combining this with Lemma 5, it follows that for any , and any ,
Repeatedly applying the last two displayed equations, and using Assumption 3, we get that
Since (as we have by assumption), we get that as required. ∎
With Lemma 7 in hand, we can now prove the theorem. Let be the largest index such that for all (and if this holds for all ). It follows that , and therefore, by Assumption 1, is at least a constant independent of for all . Thus, to prove the theorem, it is enough to show that if , then .
By Assumption 3 and Lemma 7, we have that , , and . On the other hand, if , then . Therefore, if is large enough and is small enough, there exists some iteration such that for all . This means that . Thus, by Lemma 6 (with , from iteration till iteration , each decreases by at most at each iteration. By assumption, at iteration , there is some , so we must have as required.
3 Proof of Thm. 3
To prove the theorem, we first state and prove the following key lemma:
For any initialization and any , let denote the iterates produced by gradient descent starting from , w.r.t. the function
where . Then for any ,
We prove the lemma by induction. The base case () is immediate from the definitions and the fact that
Assuming that the induction hypothesis holds for , and recalling that , we have for any that
This establishes the inductive step for , hence proving the lemma. ∎
The lemma implies that for studying the dynamics of gradient descent starting from any initial point , we can arbitrarily change the signs of its coordinates, as long as the sign of is changed accordingly. In particular, we will assume without loss of generality that all are positive (again, as long as the sign of is fixed accordingly). The proof then proceeds as follows:
We will need the following auxiliary lemma:
For any , , .
Since for all , we have . ∎
Fix some . Suppose that , and gradient descent on is initialized at some such that , for some , and for all . Assuming step size , we have that for any .
First, we show that if the step size is small enough, then gradient descent will remain in forever. For that, it is enough to show that for any , the update produced by gradient descent is in as well. By definition of , it is easily verified that for all , so the only non-trivial condition to verify is that . To show this, we note that by Lemma 9,
Thus, to ensure that (or equivalently, ), it is enough to ensure that
By the mean value theorem and the fact that , the right hand side can be lower bounded by , so it is enough to require
Having established that gradient descent will remain in forever, we now establish that the objective has a -Lipschitz gradient on : Indeed, the Hessian of at any can be easily verified to equal
Since , it follows that magnitude of each entry in the Hessian is at most , and therefore its spectral norm (which is at most the Frobenius norm) can be upper bounded by .
The final ingredient we need is that satisfies
for any (this type of inequality is known as the Polyak-Łojasiewicz condition, which ensures linear convergence rates for gradient descent on possibly non-convex functions – see Polyak 1963; Karimi et al. 2016). This follows from , by definition, being equal to
Collecting these ingredients, we can now perform a standard analysis using the Polyak-Łojasiewicz condition: If we do a gradient step to get from to (i.e. ), and assuming , then
Applying this inequality times, we get that
Equating the bound above to the target accuracy and solving for , the result follows. ∎
3.2 The Case y<0<∏iwi(1)y<0<\prod_{i}w_{i}(1)
We first state the following auxiliary lemma, which establishes that the gaps between coordinates are monotonically increasing under suitable assumptions.
Fix some coordinate indices and iteration , and suppose that , , and . Then .
Dropping the index to simplify notation, we have by definition that equals
Since and for all , the above is at least as required. ∎
There exists a unique , and .
, , and .
It is important to note that the constants hidden in the notation do not depend on (although they may depend on ).
By Lemma 11 and the theorem assumptions, the following holds for all iterations where : There exists a unique , remains the unique smallest value among , and its distance from any other coordinate (which was initially ) is monotonically increasing in . In particular, for any , . As a result, recalling that , we have for all that
It remains to show that , as well as the second bullet in the lemma. To that end, we note that up till iteration , for any , both and are monotonically decreasing in , and moreover, (since and we assume ). Thus, by Assumption 4,
Using this inequality, we have for any
which is at least if for some sufficiently large constant . Finally, since for any is positive and monotonically decreasing up to iteration , we have and by Assumption 4. ∎
and .
By Lemma 12, we have , as well as (where is arbitrary). This implies that for sufficiently small , . By definition of the gradient descent update, it follows that and for all , , which implies that remains the unique coordinate with smallest value as we move from iteration to iteration , as well as .
Finally, to prove , we have by definition that for any ,
Using the fact that as shown earlier, and noting that by Lemma 12, and , it follows from the displayed equation above that . Therefore,
Since (where the does not depend on ), then by picking for a sufficiently large , the above is at most , where we used Lemma 12 and where is arbitrary. ∎
3.3 Putting Everything Together
As discussed at the beginning of the proof, we can assume w.l.o.g. that are all positive (and in fact, by our assumptions), and only consider the cases and .