Gradient descent aligns the layers of deep linear networks
Ziwei Ji, Matus Telgarsky
Introduction
Efforts to explain the effectiveness of gradient descent in deep learning have uncovered an exciting possibility: it not only finds solutions with low error, but also biases the search for low complexity solutions which generalize well (Zhang et al., 2017; Bartlett et al., 2017; Soudry et al., 2017; Gunasekar et al., 2018).
This paper analyzes the implicit regularization of gradient descent and gradient flow on deep linear networks and linearly separable data. For strictly decreasing losses, the optimum is at infinity, and we establish various alignment phenomena:
For each weight matrix , the corresponding normalized weight matrix asymptotically equals its rank- approximation , where the Frobenius norm satisfies . In other words, , and asymptotically only the rank- approximation of contributes to the final predictor, a form of implicit regularization.
Adjacent rank- weight matrix approximations are aligned: .
Simultaneously, this work proves that the risk is globally optimized: it asymptotes to 0. Alignment and risk convergence are proved simultaneously; the phenomena are coupled within the proofs.
Since the layers align, they can be viewed as a minimum norm solution: they do not “waste norm” on components which are killed off when the layers are multiplied together. Said another way, given data , the normalized matrices asymptotically solve a maximum margin problem which demands all weight matrices be small, not merely their product:
The paper is organized as follows. This introduction continues with related work, notation, and assumptions in Sections 1.1 and 1.2. The analysis of gradient flow is in Section 2, and gradient descent is analyzed in Section 3. The paper closes with future directions in Section 4; a particular highlight is a preliminary experiment on CIFAR-10 which establishes empirically that a form of the alignment phenomenon occurs on the standard nonlinear network AlexNet.
𝑖1v_{i+1} of the subsequent layer is aligned with this , which in these plots (with principal component axes) corresponds to following a horizontal line. 1.1 Related work On the implicit regularization of gradient descent, Soudry et al. (2017) show that for linear predictors and linearly separable data, the gradient descent iterates converge to the same direction as the maximum margin solution. Ji and Telgarsky (2018) further characterize such an implicit bias for general nonseparable data. Gunasekar et al. (2018) consider gradient descent on fully connected linear networks and linear convolutional networks. In particular, for the exponential loss, assuming the risk is minimized to and the gradients converge in direction, they show that the whole network converges in direction to the maximum margin solution. These two assumptions are on the gradient descent process itself, and specifically the second one might be hard to interpret and justify. Compared with Gunasekar et al. (2018), this paper proves that the risk converges to and the weight matrices align; moreover the proof here proves the properties simultaneously, rather than assuming one and deriving the other. Lastly, Arora et al. (2018) show for deep linear networks (and later Du et al. (2018) for ReLU networks) that gradient flow does not change the difference between squared Frobenius norms of any two layers. We use a few of these tools in our proofs; please see Sections 2 and 3 for details.
For a smooth (nonconvex) function, Lee et al. (2016) show that any strict saddle can be avoided almost surely with small step sizes. If there are only countably many saddle points and they are all strict, and if gradient descent iterates converge, then this implies (almost surely) they converge to a local minimum. In the present work, since there is no finite local minimum, gradient descent will go to infinity and never converge, and thus these results of Lee et al. (2016) do not show that the risk converges to .
There has been a rich literature on linear networks. Saxe et al. (2013) analyze the learning dynamics of deep linear networks, showing that they exhibit some learning patterns similar to nonlinear networks, such as a long plateau followed by a rapid risk drop. Arora et al. (2018) show that depth can help accelerate optimization. On the landscape properties of deep linear networks, Lu and Kawaguchi (2017); Laurent and von Brecht (2017) show that under various structural assumptions, all local optima are global. Zhou and Liang (2018) give a necessary and sufficient characterization of critical points for deep linear networks.
2 Notation, setting, and assumptions
where is the step size at time .
We assume that the initialization of the network is not a critical point and induces a risk no larger than the risk of the trivial linear predictor .
It is natural to require that the initialization is not a critical point, since otherwise gradient flow/descent will never make a progress. The requirement can be easily satisfied, for example, by making and . On the other hand, if , gradient flow/descent may never minimize the risk to . Proofs of those claims are given in Appendix A.
Results for gradient flow
One key property of gradient flow is that it never increases the risk:
Under Sections 1.2 and 1.2, gradient flow iterates satisfy the following properties:
For any , .
For any , letting denote the first left and right singular vectors of ,
Moreover, for any , . As a result,
The first lemma shows that for any , the time spent by gradient flow in is finite.
Under Section 1.2 and 1.2, for any , there exists a constant , such that for any and any , . As a result, gradient flow spends a finite amount of time in for any , and is unbounded.
To proceed, we need the following properties of linear networks from prior work (Arora et al., 2018; Du et al., 2018). For any time and any ,
Taking the trace on both sides of eq. 2.3, we have
In other words, the difference between the squares of Frobenius norms of any two layers remains a constant. Together with Section 2.1, it implies that all are unbounded.
For , let , , and denote the first singular value (the -norm), the first left singular vector, and the first right singular vector of , respectively. Furthermore, define
which depends only on the initialization. If for any , , then .
The gradient flow iterates satisfy the following properties:
For any , .
For any , \langle v_{k+1},u_{k}\rangle^{2}\geq 1-\nicefrac{{\mathinner{\bigl{(}D+\|W_{k+1}(0)\|_{2}^{2}+\|W_{k}(0)\|_{2}^{2}\bigr{)}}}}{{\|W_{k+1}\|_{2}^{2}}}.
The proof is based on eq. 2.3 and eq. 2.4. If , then eq. 2.3 gives that and have the same singular values, and ’s right singular vectors and ’s left singular vectors are the same. If it is true for any two adjacent layers, since is a row vector, all layers have rank . With general initialization, we have similar results when is large enough so that the initialization is negligible. Careful calculations give the exact results in Section 2.1.
2 Convergence to the maximum margin solution
To get such a strong convergence, we need one more assumption on the data set. Recall that denotes the maximum margin, and denotes the unique maximum margin predictor which attains this margin . Those data points for which are called support vectors.
With Section 2.2, we can state the main theorem.
Before summarizing the proof, we can simplify both theorems into the following minimum norm property mentioned in the introduction.
Theorem 2.5 relies on two structural lemmas. The first one is based on a similar almost-all argument due to Soudry et al. (2017, Lemma 12). Let denote the set of indices of support vectors.
Under Section 2.2, if the data set is sampled from some density w.r.t. the Lebesgue measure, then with probability ,
With Section 2.2 and Section 2.2 in hand, we can prove Theorem 2.5. Let denote the projection of rows of onto . Notice that
Results for gradient descent
One key property of gradient flow which is used in the previous proofs is that it never increases the risk, which is not necessarily true for gradient descent. However, for smooth losses (i.e, with Lipschitz continuous derivatives), we can design some decaying step sizes, with which gradient descent never increases the risk, and basically the same results hold as in the gradient flow case. Deferred proofs are given in Appendix C.
Under Section 3, the risk is also a smooth function of , if all layers are bounded.
Smoothness ensures that for any , (see Bubeck et al. (2015) Lemma 3.4). In particular, if we choose some and set a constant step size , then as long as and are both in ,
In other words, the risk does not increase at this step. However, similar to gradient flow, the gradient descent iterate will eventually escape , which may increase the risk.
Under Section 1.2, 1.2 and 3, suppose gradient descent is run with a constant step size . Then there exists a time when , in other words, .
Fortunately, this issue can be handled by adaptively increasing and correspondingly decreasing the step sizes, formalized in the following assumption.
The step size , where satisfies , and if , .
Section 3 can be satisfied by a line search, which ensures that the gradient descent update is not too aggressive and the boundary is increased properly.
With the additional Sections 3 and 3, exactly the same theorems can be proved for gradient descent. We restate them briefly here.
Under Section 1.2, 1.2, 3, and 3, gradient descent satisfies
.
For any , .
Proofs of Theorem 3.2 and 3.3 are given in Appendix C, and are basically the same as the gradient flow proofs. The key difference is that an error of will be introduced in many parts of the proof. However, it is bounded in light of eq. 3.1:
Since all weight matrices go to infinity, such a bounded error does not matter asymptotically, and thus proofs still go through.
Summary and future directions
This paper rigorously proves that, for deep linear networks on linearly separable data, gradient flow and gradient descent minimize the risk to , align adjacent weight matrices, and align the first right singular vector of the first layer to the maximum margin solution determined by the data. There are many potential future directions; a few are as follows.
This paper only proves asymptotic convergence, moreover for adaptive step sizes depending on the current weight matrix norms. A refined analysis with rates for practical step sizes (e.g., constant step sizes) would allow the algorithm to be compared to other methods which also globally optimize this objective, would suggest ways to improve step sizes and initialization, and ideally even exhibit a sensitivity to the network architecture and suggest how it could be improved.
Nonseparable data and nonlinear networks.
Real-world data is generally not linearly separable, but nonlinear deep networks can reliably decrease the risk to 0, even with random labels (Zhang et al., 2017). This seems to suggest that a nonlinear notion of separability is at play; is there some way to adapt the present analysis?
The present analysis is crucially tied to the alignment of weight matrices: alignment and risk are analyzed simultaneously. Motivated by this, consider a preliminary experiment, presented in Figure 3, where stochastic gradient descent was used to minimize the risk of a standard AlexNet on CIFAR-10 (Krizhevsky et al., 2012; Krizhevsky and Hinton, 2009).
Even though there are ReLUs, max-pooling layers, and convolutional layers, the alignment phenomenon is occurring in a reduced form on the dense layers (the last three layers of the network). Specifically, despite these weight matrices having shape , , and the key alignment ratios are much larger than their respective lower bounds . Two initializations were tried: default PyTorch initialization, and a Gaussian initialization forcing all initial Frobenius norms to be just , which is suggested by the norm preservation property in the analysis and removes noise in the weights.
Acknowledgements
The authors are grateful for support from the NSF under grant IIS-1750051. This grant allowed them to focus on research, and when combined with an NVIDIA GPU grant, led to the creation of their beloved GPU machine DutchCrunch.
References
Appendix A Regarding Section 1.2
Suppose while . First of all, and thus . Moreover,
On the other hand, if , gradient flow/descent may never minimize the risk to . For example, suppose the network has two layers, and both the input and output have dimension ; the network just computes the dot product of two vectors and . Consider minimizing . If , then . It is easy to verify that for any , , and .
Appendix B Omitted proofs from Section 2
Fix an arbitrary . If the claim is not true, then for any , there exists some such that for all while , which means
On the other hand, by Section 1.2, at . This implies that , and for any , , which is a contradiction.
Since the risk is always positive, we have
which implies gradient flow only spends a finite amount of time in . This directly implies that is unbounded. ∎
The first claim is true for since is a row vector. For any , recall that Arora et al. (2018); Du et al. (2018) give the following relation:
Let . By eq. B.1 and the definition of singular vectors and singular values, we have
Moreover, by taking the trace on both sides of eq. B.1, we have
Summing eq. B.2 and eq. B.3 from to , we get
Next we prove that singular vectors get aligned. Consider . On one hand, similar to eq. B.2, we can get that
On the other hand, it follows from the definition of singular vectors and eq. B.4 that
Combining eq. B.7 and eq. B.8, we finally get
Regarding the last claim, first recall that since the difference between the squares of Frobenius norms of any two layers is a constant, implies for any . We further have the following.
Since , for any , and .
Since , .
Similar to the proof of Section 2.1, we can show that if ,
In other words, there exists some , such that when , .
Section 2.1 shows that gradient flow spends a finite amount of time in for any . Since the difference between the squares of Frobenius norms of any two layers is a constant, gradient flow also spends a finite amount of time in . Now we have
which is a contradiction. Therefore . This further implies , since has no finite optimum. Finally, invoking Section 2.1 proves the final claim of Theorem 2.2. ∎
Soudry et al. (2017) Lemma 12 proves that, with probability , there are at most support vectors, and moreover, the -th support vector has a positive dual variable , such that .
Suppose there exists some , such that . Since
we actually have for all . This is impossible under Section 2.2, since the support vectors span the whole space. ∎
The first part can be lower bounded as below (recall that )
To bound the second part, first notice that since we assume , for any ,
The reason is that every data point has margin at least , and thus for some . Using eq. B.11, we can bound the second part of eq. B.9.
On the third line eq. B.11 is applied. The fourth line applies the property that when .
Combining eq. B.9, eq. B.10 and eq. B.12, we get
As long as , .
The second part of eq. B.13 can be bounded again by eq. B.12. To bound the first part of eq. B.13, first notice that (recall )
Using eq. B.14, and recall that , we can bound the first part of eq. B.13 as below.
Combining eq. B.13, eq. B.15 and eq. B.12, we get
As long as , . ∎
Let . We have , where is the second singular value of and is the constant introduced in Section 2.1. Then
Fix an arbitrary . By Theorem 2.2, we can find some large enough such that for any :
and thus . An application of Theorem 2.2 gives the other part of Theorem 2.5. ∎
On the other hand, if matrices are feasible, then
Appendix C Omitted proofs from Section 3
Given , we need to show that for some .
where the last inequality follows from a similar one-by-one replacement procedure as in eq. C.1. Combining eq. C.2 and eq. C.3, we get for ,
The same procedure can be done for other layers, and together
Recall that if and ,
Suppose for all . By Section 1.2 and eq. C.4,
By eq. C.4, gradient descent never increases the risk, and thus for all , . In exactly the same way as in the proof of Section 2.1, one can show that there exists some constant , so that for all . Invoking eq. C.4 again, we will get
which is a contradiction. Therefore must go out of at some time. ∎
Next we prove Theorem 3.2 and 3.3. The proofs depend on several lemmas which are similar to the gradient flow ones. The following Appendix C is similar to Section 2.1.
Under Section 1.2, 1.2, 3, and 3, gradient descent ensures that
is unbounded.
For any , .
By Section 3, we always have that . Since , we have for any ,
Moreover, Section 3 shows that . Since as long as , is unbounded.
It then follows that for any , by Cauchy-Schwarz,
we have .
Since under Sections 3 and 3 gradient descent never increases the risk, it can be shown in exactly the same as in the proof of Section 2.1 that, for , for some constant . Invoking eq. C.4 again, we get that . ∎
The next lemma is an analogy to Section 2.1.
Under Section 1.2 and 3, the gradient descent iterates satisfy the following properties:
For any , .
For any , .
For gradient descent iterates, summing eq. C.6 from to , we get
Still let , and denote the first singular value, left singular vector and right singular vector of . We can then proceed basically in the same way as in the proof of Section 2.1. For example, eq. B.2 becomes
Summing eq. C.9 and eq. C.10 from to , and invoke eq. C.8, we get
To prove singular vectors get aligned, we can still proceed in nearly the same way as in the proof of Section 2.1. appendix B becomes
The final claim of Appendix C can be proved in exactly the same way as Section 2.1. ∎
Summing eq. C.10, we know that for any two different layers ,
In other words, the difference between the squares of Frobenius norms of any two layers is still bounded.
which is a contradiction. Therefore , and since it has no finite optimum, . The other results follow from Appendix C. ∎
The proof then goes in almost the same way as the proof of Theorem 2.5. For any , we can find some large enough time , such that for any ,
.
Suppose at some time , . As long as this still holds, in light of bullet (1) above, eq. C.16 and eq. C.17, will increase by at most . On the other hand, , and thus there exists some such that .
Let denote the smallest time after such that (if it exists). Recall that for any , and for any , we have
After , will increase by at most , and thus will increase by at most . Therefore, for any , as long as , we have
since after . In other words,
and thus .
The proof is analogous to that of Section 2.2, except using Theorem 3.3 in place of Theorem 2.5. ∎