Analyzing Sharpness along GD Trajectory: Progressive Sharpening and Edge of Stability
Zhouzi Li, Zixuan Wang, Jian Li
Introduction
Deep learning has achieved great success in a variety of machine learning applications, and gradient-based algorithms are the prevailing optimization methods for training deep neural networks. However, mathematically understanding the behavior of the optimization methods for deep learning is highly challenging, due to non-convexity, over-parameterization, and complicated architectures. In particular, some recent empirical findings in deep networks contradict the traditional understandings of gradient methods. For example, Wu et al. observed that the solution found by gradient descent has sharpness approximately equal to instead of just being smaller than . Also, Jastrzebski et al. observed that there is a break-even point in the SGD trajectory, and after this point, there is a regularization effect on the loss curvature.
One recent well-known example is the phenomenon called “Edge of Stability" (EOS) (Cohen et al. ). Based on the classical optimization theory, the learning rate of gradient-based method should be smaller than so that the loss can decrease, where is the largest eigenvalue of the Hessian of the objective, also called “sharpness” in the literature. Otherwise, the loss diverges (even for simple quadratic functions). However, the empirical findings in Cohen et al. show that under various network settings, the EOS phenomena typically occurs along the gradient descent trajectory: (1) the sharpness first increases until it reaches (called “progressive sharpening”) (2) the sharpness starts hovering around (the EOS regime) and (3) the loss non-monotonically decreases without diverging.
Although (1) seems to be consistent with the traditional beliefs about optimization, a rigorous mathematical explanation for it is still open. Moreover, phenomena (2) and (3) are more mysterious because they violate the “rule” in traditional optimization theory, yet the training loss does not completely diverge. Instead, the loss may oscillate but still decrease in the long run, while the sharpness seems to be restrained from further increasing.
In this paper, we aim to provide a theoretical and empirical explanation for the mystery of EOS. Towards the goal, we focus on the dynamics of these key quantities when EOS happens and attempt to find out the main driving force to explain these phenomena along the gradient descent trajectory from both theoretical and empirical perspectives.
Our contributions can be summarized as follows.
(Section 3.1) We analyze the typical sharpness behavior along the gradient descent trajectory when EOS happens, and propose a four-phase division of GD trajectory, based on the dynamics of some key quantities such as the loss and the sharpness, for further understanding this phenomenon.
(Section 3.2) We empirically identify the weight norm of the output layer as an effective indicator of the sharpness dynamics. We show that analyzing the dynamics of this surrogate can qualitatively explain the dynamics of sharpness. By assuming this relation, together with some additional simplifying assumptions and approximations, we can explain the dynamics of the sharpness, the loss, and the output layer norm in each phase of EOS (Section 3.3). In this context, we also offers an interesting explanation for the non-monotonic loss decrement (also observed in Cohen et al. , Xing et al. ) (Section 3.4).
(Section 4) Following similar ideas, we provide a more rigorous proof for the progressive sharpening and EOS phenomena in a two-layer fully-connected linear neural network setting based on certain assumptions. The assumptions made here are either weaker or arguably less restrictive.
2 Related work
The structure of Hessian The Hessian matrix carries the second order information of the loss landscape. Several prior works have empirically found that the spectrum of Hessian has several “outliers” and a continuous “bulk” (Sagun et al. , Papyan ). Typically, each outlier corresponds to one class in multi-class classification. As we consider the binary classification setting, there is typically one outlier (i.e., the largest eigenvalue) that is much larger than other eigenvalues. It is consistent with our Assumption 4.1. The Gauss-Newton decomposition of the Hessian was used in several prior works (Martens , Bottou et al. , Papyan ). Papyan empirically showed that the outliers of Hessian can be attributed to a “G component”, which is also known as Fisher Information Matrix (FIM) in Karakida et al. . Also, Wu et al. analyzed the leading Hessian eigenspace by approximating the Hessian with Kronecker factorization and theoretically proved the outliers structure under some random setting assumption.
Neural Tangent Kernel A recent line of work studied the learning of over-parameterized neural networks in the so-called. “neural tangent kernel (NTK) regime or the lazy training regime (Jacot et al. , Lee et al. , Du et al. , Arora et al. , Chizat et al. ). A main result in this regime is that if the neural network is wide enough, gradient flow can find the global optimal empirical minimizer very close to the initialization. Moreover, the Hessian does not change much in the NTK regime. Our findings go beyond NTK setting to analyze the change of sharpness.
Edge of Stability regime The Edge of Stability phenomena was first formalized by Cohen et al. . Similar phenomena were also identified in Jastrzebski et al. as the existence of the “break-even” point on SGD trajectory after which loss curvature gets regularized. Xing et al. observed that gradient descent eventually enters a regime where the iterates oscillate on the leading curvature direction and the loss drops non-monotonically. Recently Ahn et al. studied the non-monotonic decreasing behavior of GD which they called unstable convergence, and discussed the possible causes of this phenomenon. Ma et al. proposed a special subquadratic landscape property and proved that EOS occurs based on this assumption. Arora et al. studied the implicit bias on the sharpness of deterministic gradient descent in the EOS regime. They proved in some specific settings with a varying learning rate (called normalized GD) or with a modified loss , gradient descent enters EOS and further reduces sharpness. They mainly focus on the analysis near the manifold of minimum loss, but our analysis also applies to the early stage of the training when the loss is not close to the minimum. In particular, our analysis provides an explanation of non-monotonic loss decrease that cannot be explained by their theory. Another difference is that they consider (for constant learning rate) where is a fairly general MSE loss independent of any neural network structure, while our analysis is strongly tied with the MSE loss of a neural network. Very recently, Lyu et al. explained how GD enters EOS for normalized loss (e.g., neural networks with normalization layers), and analyzed the sharpness reduction effect along the training trajectory. The notion of sharpness in their work is somewhat different due to normalization. In particular, they consider the so-called spherical sharpness, that is the sharpness of the normalized weight vector. They also mainly studied the regime where the parameter is close to the manifold of minimum loss as in and proved that GD approximately tracks a continuous sharpness-reduction flow. Lewkowycz et al. proposed a similar regime called “catapult phase” where loss does not diverge even if the largest Hessian eigenvalue is larger than . Our work mainly considers training in this regime and assumes that the training is not in the “divergent phase” in Lewkowycz et al. . Compared with Lewkowycz et al. , we provide a more detailed analysis in more general settings along gradient descent trajectory.
Preliminaries
Hessian, Fisher information matrix and NTK: In this part, we apply previous works to show that the largest eigenvalue of Hessian is almost the same as the largest eigenvalue of NTK. We use the latter as the definition of the sharpness in this paper. Further details can be found in Appendix F.
In this paper, we use to denote the parameter at iteration (or time ) and the sharpness at time as . We similarly define .
Here we show the gradient flow dynamics of the residual vector :
A Four-phase Analysis of GD Dynamics
In this section, we study the dynamics of gradient descent and the change of sharpness along the optimization trajectory. We divide the whole training process into four phases, occurring repeatedly in the EOS regime. In Section 3.1, we introduce the four phases. In Section 3.2, we show empirically that the change of the norm of the output layer weight vector almost coincides with the change of the sharpness. In Section 3.3, using this observation, we attempt to explain the dynamics of each phase and provide a mathematical explanation for the changes in the sharpness. In Section 3.4, we explain why the loss decreases but non-monotonically. We admit that a completely rigorous theoretical explanation is still beyond our reach and much of our argument is based on various simplifying assumptions and is somewhat heuristic at some points. Due to space limits, we defer all the proofs in this section to Appendix E.1.
To further understand the properties along the trajectory when EOS happens, we study the behaviors of the loss and the sharpness during the training process. As illustrated in Figure 1, we train a shallow neural network by gradient descent on a subset of 1,000 samples from CIFAR-10 (Krizhevsky et al. ), using the MSE loss as the objective. Notice that the sharpness keeps increasing while the loss decreases until the sharpness reaches . Then the sharpness begins to oscillate around while the loss decreases non-monotonically. This is a typical sharpness behavior in the EOS regime, and consistent with the experiments in .
We divide the training process into four phases according to the evolution of the loss, the sharpness, and their correlation, as shown in Figure 1. The four phases happen cyclically along the training trajectory. We first briefly describe the properties of each phase and explain the dynamics in more detail in Section 3.3.
Phase I: Sharpness . In this stage, all the eigenvalues of Gram matrix are below the threshold . In particular, using standard initialization, the training typically starts from this phase, and during this phase the loss keeps decreasing and the sharpness keeps growing along the trajectory. This initial phase is called progressive sharpening (PS) in prior work Cohen et al. . Empirically, the behavior of GD trajectory (as well as the loss and the sharpness) is very similar to that of gradient flow, until the sharpness reaches (this phenomena is also observed in Cohen et al. . See Figure 5 or Appendix J.1 in their paper). We note that GD may come back to this phase from Phase IV later.
Phase II: Sharpness . In this phase, the sharpness exceeds and may keep increasing. We will show shortly that the fact that causes (where the first eigenvector of ) to increase exponentially (Lemma 3.2). This would quickly lead to exceed in a few iterations, which leads the sharpness to start decreasing by Proposition 3.1, hence the training process enters Phase III.
Phase III: Sharpness yet begins to gradually drop. Before drops below , Lemma 3.2 still holds, so keeps increasing. Proposition 3.1 still holds and thus the sharpness keeps decreasing until it is below , at which point we enter Phase IV. A distinctive feature of this phase is that the loss may increase due to the exponential increase of .
Phase IV: Sharpness . When the sharpness is below , begins to decrease quickly, leading the loss to decrease quickly. At the same time, the sharpness keeps oscillating and gradually decreasing for some iterations. This lasts until the loss decrease to a level that is around its value right before Phase III. The sharpness is still below and our training process gets back to Phase I.
2 The Norm of the Output Layer Weight
It is difficult to rigorously analyze the dynamics of the sharpness . In this subsection, we make an interesting observation, that the change of the norm of the output layer of the network (usually a fully-connected linear layer) is consistent with the change of the sharpness most of the time.
Note that can be decomposed as follows:
where the entry of is
In this expression, intuitively should be positively related to . We empirically observe that the part has a much smaller spectral norm compared to the whole Gram matrix (see Figure 3(a) and Appendix D), which means dominates . Therefore, should be positively correlated with .
The benefit of analyzing is that the gradient flow of enjoys the following clean formula:
In this work, we do experiments on two-layer linear networks, fully connected deep neural networks, and Resnet18, and all of them have such output layer structures. From Figure 3(a), we can observe that the output layer norm and the sharpness change in the same direction most of the time along the gradient descent trajectory, i.e., they both increase or decrease at the same time. We note that they may change in different directions very occasionally around the time when changes its sign (see the experiments in Figure 2).
3 Detailed Analysis of Each Phase
In this section, we explain the dynamics of each phase in more detail. For clarity, we first list the assumptions we need in this section. For different phases, we may need some different assumptions to simplify the arguments. Most of the assumptions are consistent with the experiments or the findings in the literature. Some of them are somewhat stronger, and we also discuss how to relax them.
It is the key observation that we have discussed in Section 3.2. The following are two assumptions about the gradient descent trajectory. The first one assumes that and are updated according their first order approximations. Empirical justification of this approximation can be found in Appendix D.1.3.
Assumption 3.3 holds empirically, especially in the progressive sharpening phase (see Figure 5 or Appendix J.1 in Cohen et al. ) when the networks are continuously differentiable. We include these experimental details in Appendix D. See also (Theorems 4.3 and 4.5) in Arora et al. for further theoretical justification. We need this assumption for the proof in the progressive sharpening phase.
Then we state an assumption on the upper bound of the sharpness to restrict the regime we discuss:
(Sharpness upper bound) If the training does not diverge, there exists some constant , such that for all .
This assumption states that there is an upper bound of the sharpness throughout the optimization process. Actually, in Lewkowycz et al. , they proved that is an upper bound of the sharpness in a two-layer linear network with one datapoint, otherwise the training process (loss) would diverge. They empirically found that similar upper bounds exist also for nonlinear activations, albeit with somewhat larger constant . In the work, We focus on the case when the loss does not diverge and hence we make Assumption 3.4.
The main set of assumptions we need is about the change of ’s eigendirections.
Denote to be the set of eigenvectors of . We have three levels of assumptions on ’s eigenspace.
(fixed eigendirections) the set is fixed throughout the phase under consideration;
(principal directions moves slowly) at all time , there is a small constant such that .
Clearly, these three assumptions are increasingly weaker from (i) to (iii). Assumption 3.5 (i) on the eigenvectors is somewhat strong, and the eigenvectors corresponding to small eigenvalues may change notably in our experiments. We use it to illustrate a basic proof idea of the progressive sharpening phase, but later we relax this assumption to Assumption 3.5 (ii).
Moreover, for the proof in Phase II and III, Assumption 3.5 (iii), which only assume that the main direction changes slightly, is sufficient for our proof. Actually, we note that (the eigenvector corresponding to the largest eigenvalue) changes slowly and the inner product of its initial direction and its direction at the end of the phase is also large (see Appendix D for the empirical verification).
For the proof in Phase II, we need another small technical assumption:
Assume for some for some at the beginning of this phase. Here is defined in Assumption 3.5 (iii).
Assumption 3.6 says that has a non-negligible component in the direction of . Since is a small constant, this is not a strong assumption as some small perturbation (due to discrete updates) would make the assumption hold for some .
3.2 Detailed Analysis
In each phase, we attempt to explain the main driving force of the change of the sharpness and the loss.
Phase I: In this phase, we show that under certain assumptions (detailed shortly) on the spectral properties of (see Lemma 3.1 below). By Assumption 3.2, we have , implying that the sharpness also increases based on Assumption 3.1. This phase stops if grows larger than .
We assume the output vector is initialized to be small (this is true if we use very small initial weights). For simplicity, we assume in the following argument.
For all in Phase I, under Assumption 3.5 (i) and 3.3, it holds that .
From this lemma, keeps increasing by Assumption 3.2; hence the sharpness keeps increasing by Assumption 3.1 until it reaches or the loss converges to 0. In the former case, the training process enters Phase II, while the latter case is also possible when is very small (e.g., even the largest possible sharpness value is less than ). We admit that Assumption 3.5 (i) is somewhat strong. In fact, the assumption can be relaxed significantly to Assumption 3.5 (ii). We show in Appendix E.2 that under Assumption 3.5 (ii) and Assumption 3.3, we can still guarantee . Moreover, we provide a dynamical system view of the dynamics of in that Appendix.
Phase II: When the training process just enters Phase II, the sharpness keeps increasing. We show shortly that starts to increase geometrically, and this causes the sharpness to stop increasing at some point, thus entering Phase III.
In this phase, we adopt a weaker assumption on the sharpness direction : Assumption 3.5 (iii). This assumption holds in our experiments (See Figure 17). Also, Assumption 3.6 is necessary.
Suppose Assumption 3.5 (iii) and 3.6 hold during this phase (with constants and ). If and , then increases geometrically with factor for in this phase.
Since increases geometrically, will exceed eventually. Next, the following proposition states that when this happens, . Consequently, decreases by Assumption 3.2, leading to the decrement of the sharpness based on our Assumption 3.1.
If , then .
Phase III: The sharpness is still larger than , but it starts decreasing. Meanwhile, the loss continues to increase rapidly due to Lemma 3.2. Eventually, the sharpness will fall below and then the training process enters phase IV.
By Lemma 3.2, if the sharpness stays above , then we can have an arbitrarily large loss. According to Proposition 3.1, if the loss is large enough, the sharpness keeps decreasing.
Now we show that if the sharpness stays above , will decrease by a significant amount. This partially explains that the sharpness should also decrease significantly until it drops below (instead of decreasingly converging to a value above without ever entering the next phase).
Under Assumption 3.2, if , then .
From the above argument, we can see that if is larger than , then does not decrease in Phase III, and according to Proposition 3.2, decreases significantly, implying the sharpness drops below eventually.
Remark: The fact that the sharpness can provably drop below in this phase can be proved more rigorously in Section 4 for the two-layer linear setting. See Theorem 2.
Phase IV: First, since the training process has just left phase III, is still positive and large, hence keeps decreasing and the sharpness decreases as well. Since the sharpness stays below , the loss decreases due to the following descent lemma (with replaced by ).
Next we argue that will become negative eventually, which indicates that and hence the sharpness will grow again. Since the sharpness is below , decreases geometrically due to Lemma 3.3 (replacing with ).
In fact, can be decomposed into the -component and the remaining part defined as . Then we have
As shown in the next subsection, almost follows a similar gradient descent trajectory (Lemma 3.5). More precisely, is defined as (Lemma 3.4). While ’s dynamics is , follows a similar dynamics , where . Note that has eigenvalues smaller than for any time (by Assumption 3.7), hence with an assumption similar to Assumption 3.5 (i) (or a similar version of our relaxed assumption in Appendix E.2 for ), we can prove that for any time (See Appendix E.1 for the rigorous proof).
Since , the second term in the decomposition (4) is always negative and the first term ( direction term) is decreasing geometrically. Therefore, there are only two possible cases. The first possibility is that the first term decreases to a small value near 0 and the second term remains largely negative. Then their sum will be negative, which is , thus implying the training enters Phase I. The second possibility is that when the first term decreases to a small value near 0, the second term is also a small negative value. In this case both and are small, implying the loss is almost 0, which is indeed the end of the training.
4 Explaining Non-monotonic Loss Decrement
In this subsection, we attempt to explain the non-monotonic decrement of the loss during the entire GD trajectory. See Figure 3(b). As defined in the last section, we decompose into the -component and the remaining part . Below, we prove that is not affected much by the exponential growth of the loss (Proposition 3.5) in Phase II and III, and almost follows a converging trajectory (which is defined as later in this section).
The arguments in this subsection need Assumption 3.4 and Assumption 3.5 (iii), both very consistent with the experiments. We need an additional assumption on the spectrum of .
All ’s eigenvalues except are smaller than for all .
Recall that the largest eigenvalue is at most by Assumption 3.4. Empirically, the largest eigenvalue is an outlier in the spectrum, i.e., it is much larger than the other eigenvalues. Hence, we make Assumption 3.7 which states that all other eigenvalues are at most , which is consistent with our experiments. See Figure 3(b). Similar fact is also mentioned in .
First, we let be an upper bound of , i.e., for all , . In the two-layer linear network case, we can have an explicit form of . (see Lemma C.9 in Appendix C.) Recall that in Assumption 3.4, is the upper bound of .
Suppose Assumption 3.5 (iii) holds. satisfies the following:
Define an auxiliary sequence by , and . If Assumption 3.4, Assumption 3.5 (iii), Assumption 3.7 hold, and for any time there exists a quantity , such that the smallest eigenvalue of , i.e. , then there exists a constant such that .
Now, in light of Lemma 3.2 and Lemma 3.5, we arrive at an interesting explanation of the phenomena of non-monotonic decrease of the loss. Basically, can be decomposed into the -component and the remaining part . The -component may increase geometrically during the EOS (Lemma 3.2), but the behavior of the remaining part is close to , which follows the simple updating rule , so Lemma 3.3 implies that the part almost keeps decreasing during the entire trajectory (here Lemma 3.3 applies with replaced by , noticing that the eigenvalues except the first are well below ). Hence, the non-monotonicity of the loss is mainly due to the -component of , and the rest part is optimized in the classical regime (step size well below 2/(the operator norm)) and hence steadily decreases. See Figure 3(b).
A Theoretical Analysis for 2-Layer Linear NN
In this section, we aim to provide a more rigorous explanation of the EOS phenomenon in two-layer linear networks. The proof ideas follow similar high-level intuition as the proofs in Section 3.3. In particular, we can remove or replace the assumptions in Section 3.3 with arguably weaker assumptions. Due to space limit, we state our main theoretical results and elaborate their relation with the proofs in Section 3.3. The detailed settings and proof are more tedious and can be found in Appendix C.
Dataset: For simplicity, we assume for all , and . We assume has rank , and we decompose and according to the orthonormal basis , the eigenvectors of : where is the eigenvector corresponding to the -th largest eigenvalue of . is the projection of onto the direction . Here we suppose and the global minimum exists.
Update rule: We write explicitly the GD dynamics of : , where is the Gram matrix combined with second order terms.
2 Main Theorem and The Proof Sketch
There exists some constant , s.t. for all , . Moreover,
There exists such that .
The first assumption is about the eigenvalue spectrum of . It guarantees the gap between two adjacent eigenvalues is not very large, and there is a gap between the largest and the second largest eigenvalue. Note the second part of the assumption is a relaxed version of Assumption 3.7. In our CIFAR-10 1k-subset with samples’ mean subtracted, (See Figure 19). The second assumes that all component are not too small.
Suppose Assumption 4.1, Assumption 4.2 hold, the smallest nonzero eigenvalue and . Then for any , if , and , we have the progressive sharpening property: for where is the time when or for the first time.
In the proof of this theorem, we show that the Gram matrix , which serves as a justification of Assumption 3.5 we made in Section 3.3. That shows all approximately share the same set of eigenvectors as . In our proof, we also prove more rigorously that is an indicator of the sharpness in this simpler setting.
There exists some constant , such that
This assumption is based on Theorem 1. In Theorem 1, we state that in the progressive sharpening phase, has an upper bound of . Now in the EOS phase, we assume that grows larger by at most a constant factor. Further discussions refer to Appendix D.2.2.
There exists some constant , such that
This assumption is consistent with Assumption 3.4, which assumes an upper bound of the sharpness.
There exist some constant such that for some at the beginning of phase II.
This assumption is in the same spirit of Assumption 3.6 with the only change of the bound in terms of and . Now, we are ready to state our theorem in this stage.
Denote the smallest nonzero eigenvalue as and the largest eigenvalue as . Under Assumption 4.3, 4.4, 4.5, and in Assumption 4.1, there exist constants such that if , then
There exists which depends on such that if for some , there must exist some such that .
If , then there is a constant (depending on ) such that .
Define , and . It holds that .
We can conclude the following from Theorem 2: (1) The first statement of the theorem states that if the progressive sharpening phase causes the sharpness to grow over , then the sharpness eventually goes below . This illustrates the regularization effect of gradient descent on the sharpness (this is consistent with the analysis of Phase III in Section 3.3). (2) The second states that geometrically increases in Phase II and III. Note that we proved a similar Lemma 3.2 for Phase II in the more general setting in Section 3.3. (3) The third conclusion gives an upper bound for the distance between ’s trajectory and ’s. This bound helps illustrate why ’s trajectory is similar with in Phase IV of Section 3.3.
Discussions and Open Problems
In this section, we discuss the limitation of our theory and some related findings. First, our argument crucially relies on the assumption that changes in the same direction as does most of the time. Here, we elaborate more on this point. Seeing from a longer time scale, and the sharpness may have very different overall trends (See Figure (c) in 2), i.e., the sharpness oscillates around but increases. Moreover, the sharpness may oscillate more frequently than , while the low-frequency trends seem to match well (See the late training phases in Figure (b) in 2). Currently, our theory cannot explain the high-frequency oscillation of the sharpness in Figure (b).
While we still believe the change of is a major driving force of the change of the sharpness, other factors (such as other layers) must be taken into consideration for a complete understanding and explanation of the sharpness dynamics. We also carry out some experiments that reveal some interesting relation between the inner layers and the sharpness, which is not yet reflected in our theory. Due to space limit, we defer it to Appendix D.3.
We conclude with some open problems. It would be very interesting to remove some of our assumptions or replace them (especially those related to the spectrum of ) by weaker or more natural assumptions on the data or architectures, or make some of the heuristic argument more rigorous (e.g., first order approximation of the dynamics (3)). Extending our results in Section 4 to deeper neural networks with nonlinear activation function is an intriguing and challenging open problem.
References
Appendix A Experimental Setup
We provide detailed experimental setup in this section.
Under GPU memory constraints when computing Gram matrix of our models, we limit the size of dataset we use. The dataset is a 1,000-sample subset from CIFAR-10 (Krizhevsky et al. ) (https://www.cs.toronto.edu/~kriz/cifar.html). To make it a binary dataset, we constructed it by selecting the first 500 samples of class 0 and 1, respectively.Cohen et al. selects the first 5,000 examples from CIFAR-10. Our subset is smaller because of the computation limitation when calculating the Gram matrix. Experiments show that the properties along GD trajectory (e.g. the loss, the sharpness) is similar on both datasets. Then we label the samples by . In the experiments in Appendix B and D, we fix the objective as training on the 1000-example subset of CIFAR-10.
A.2 Network Architecture
In general settings, we experiment with three architectures from simple models to more complicated models: one-hidden-layer linear neural network, four-hidden-layer fully-connected network, convolutional network and a ResNet18 (He et al. ) model. The initialization of each layer follows the default initialization of PyTorch (Paszke et al. ).
Linear Network We first use a simple two-layer linear neural network. The hidden layer has 200 neurons. We empirically show that even a simple linear network can enter the EOS regime.
Fully-connected Network We conduct further experiments on several different fully-connected networks with 4 hidden layers with various activation functions. We consider tanh, ReLU, ELU activations. For example, the structure of a fully-connected tanh network is shown in Table 2.
Convolutional Network We also conduct experiments on several different convolutional networks with two convolutional layers and two max-pooling layers. Like the fully-connected network experiments, we consider tanh, ReLU and ELU activations. For example, the structure of a convolutional tanh network is shown in Table 3.
ResNet18 We also conduct experiment on the ResNet18 architecture proposed by He et al. . We use the default architecture implemented in PyTorch (Paszke et al. ). When calculating the sharpness, we use the numerical methods in the package (Golmant et al. ) to calculate the top eigenvalue of the Hessian matrix.
Appendix B Further Experiments and Discussions
In this appendix, we use the 1000-sized subset of CIFAR-10 introduced in Appendix A to conduct further experiments on various architectures. We verify our main observation about the correlation between the sharpness and the weight norm of the output layer (A-norm) of the neural network through the following experiments.
We consider simple linear networks, fully-connected networks, convolutional networks in this appendix. For nonlinear networks, we choose tanh, ReLU, ELU as activation functions. We train the networks with MSE loss. Here we exclude ResNet18 experiment since it is not feasible to compute the Gram matrix or the leading Gram matrix eigenvector due to GPU memory limitation. The sharpness and A-norm correlation of ResNet18 are included in Figure 2 in Section 3.2.
Here we run full-batch gradient descent with a selected step size such that the sharpness at initialization is smaller than .
We first verify our four-phase division of EOS phenomena in a simple linear network. This experiment shows that even linear networks can also enter EOS regime and the four-phase division of the gradient descent trajectory is quite apparent in this setting. The following Figure 4 illustrates the positive correlation between the sharpness and the A-norm, and the relationship between the loss and along the trajectory.
B.1.2 Fully-connected networks
We train three 5-layer fully-connected networks with different activation functions: tanh, ReLU, and ELU activations. In Figure 5, 6, and 7, we verify that in these fully-connected networks, the sharpness is positively correlated to the dynamics output layer norm (A-norm) most of the time in the progressive sharpening stage and the first few oscillations.
Note that anomaly points appear much more frequently after a few oscillations. Meanwhile, the sharpness oscillates more frequently around in every few iterations. We further discuss the phenomenon in Appendix B.2, in which we elaborate the complicated relationship of the sharpness, A-norm and parameters of other layers.
B.1.3 Convolutional Networks
We train three convolutional networks with different activation functions: ReLU, tanh, and ELU activations. In Figure 8, 9, and 10, we verify that in convolutional networks, the positive correlation between the sharpness and the output layer norm (A norm) is still correct in the training process. In the first few oscillations of the sharpness, the four-phase division is also valid. On the other hand, we notice that the same anomaly appears in this convolutional setting as in the fully-connected examples. We defer the discussion to Section B.2.
B.1.4 Gaussian Data on Linear Networks
In this section, we train two-layer fully-connected linear networks with datapoints sampled from Gaussian distribution and different label vectors.
In Figure 11, we verify that even with simple two-layer linear network and Gaussian data, progressive sharpening and EOS can still be observed. However, because Gaussian data is easy for the network to learn, the convergence is so fast that within tens of epochs the training loss converges to zero. In this case, the EOS phenomenon is not quite typical.
In Figure 12(a), the label is uniformly sampled from . Comparing the experimental results with those obtained using the same network trained with 500 CIFAR-10 data points, we find out that both have a similar degree of progressive sharpening. In Figure 12(b) and Figure 12(c), we let the label be and respectively. The result shows that when the label vector is aligned with the top eigenvector , the degree of progressive sharpening is relatively small, and when the label vector is aligned with a bottom eigenvector, the degree of progressive sharpening is relatively large.
This phenomenon is consistent with our intuition. Empirically we found that a dataset that is easier to learn leads to faster convergence rate, which then leads to a smaller degree of progressive sharpening. For example, training standard Gaussian distributed dataset converges faster than that with CIFAR-10 dataset, hence the degree of progressive sharpening of the former is much smaller; as another example (Figure 12(b) and Figure 12(c)), if the label vector is aligned with the top eigenvector, the convergence in the first phase (the PS phase) is faster, which leads to a shorter first phase and thus a smaller degree of progressive sharpening compared to the other case.
B.2 Further Discussions on the Relation between A-norm and Sharpness
In our paper, we use the observation that shares the same trend as the sharpness to explain the dynamics of the sharpness. However, as shown in the experiments in this section (see Figure 5, 6, 7, 8, 9, 10), anomaly points exist during the training process. Here we briefly discussion these anomaly points further. We divide them into three kinds.
At the time that changes its trend: This kind of anomaly points appear when changes its trend. When changes its trend, its changing rate (or differential, the term) changes its sign, hence the changing rate’s absolute value is small. Now because the dynamics of the sharpness is effected by both and the inner layers, when changing rate of is small, the inner layers may play a larger role in the direction of sharpness, which may cause the anomaly.
When the sharpness oscillates more frequently: We notice that in some cases, and the sharpness have very similar overall trend, but the sharpness oscillates more frequently but the magnitude is small (i.e., the sharpness curve has higher frequency oscillations. See Figure 6 or Figure 10). In this case, while we believe the change of is a major driving force of the change of the sharpness, other layers must be taken into consideration for understanding such small and frequent oscillations of sharpness.
In late training phases: We notice that in the late training phases in most settings, sharpness oscillates and crosses more frequently (it changes directions in a few iterations). In this case, our four-phase division does not strictly apply. At the same time, may also change direction more frequently, resulting more anomaly points during this period of time. Hence, understanding the behavior of the late stages is beyond our current analysis and requires new insights.
Appendix C Proof for Section 4
Model: In this section, we study a two-layer neural network with linear activation, i.e.
Also, we suppose there exists some parameter , , s.t.
Note when , the matrix cannot be full rank. This condition guarantees that Gradient Descent (GD) only travels in the column space of according to Lemma E.10 at Appendix E.
Define the output vector as and the residual vector as in the training process.
(Note that they are functions of time . So we use to denote at time .)
Consider the mean square error MSE loss during the training process:
Initialization: We run GD on the loss and start from symmetric initialization for the weights, which guarantees
Sharpness: Recall the definition of the sharpness: , where is the Gram matrix (8).
Learning rate selection: We select a learning rate such that . Specially, based on our method of initialization, , hence we have
Gradient Descent Update Rule: Following GD, the training dynamics is as follows:
Write them into matrix forms and we have:
Then we have the ’s dynamics according to :
We can also show the dynamics of according to (6) and (8). See Appendix E for a proof.
(See Lemma 21) The update rule of the residual vector of :
We define some extra notations for preparation.
Remark. Here we explain the notations above and what they are for.
is the Gram matrix plus a second order term (). Since the second order term is small, we have . Also, in Section C.3 we prove is almost a linear interpolation of and , which corroborates this argument.
is the difference between and . Note that because of the initialization condition. In the following proof, we will show a small upper bound of the norm of . Hence, we can show that the eigenvectors of are approximately aligned with the eigenvectors of .
is the Gram matrix with the second order term, yet with excluded. is used for bounding the main part of (i.e., the terms without the noise , e.g. (A1),(A5)) which is defined in Theorem 3) in the proof of Theorem 3. Note that there exists some number s.t. . This is because
Hence for any eigenvector of ,
Then the dynamics of can be written as:
Update Rule of : Using the update rule of and , we can also derive the update rule of the Gram matrix (see Appendix E for the proof detail):
(See Lemma E.9) The update rule of the Gram matrix is,
C.2 Phase I and Progressive Sharpening
We suppose has rank , and we decompose and into a basis composed of orthonormal eigenvectors of .
where is the eigenvector corresponding to the -th largest eigenvalue of . is the ’s projection onto the direction . In particular, is the eigenvector corresponding to the largest eigenvalue of .
Recall that the sharpness . Here we propose an approximation of sharpness by the eigenvector :
The following corollary rationalizes this approximation. The proof is deferred to Corollary C.2 in Section C.3.
There exists some constant , s.t. for all time t and
where is the top eigenvector of .
By this corollary, we can see that the top eigenvector of is approximately , and the approximation is very close to the real sharpness . Thus, we consider as an approximation of the sharpness and analyze its dynamics.
We first show the main theorem of progressive sharpening under Assumption C.1 and C.2 below.
There exists some constant , s.t. for all , . Moreover,
There exists such that .
The first assumption is about the eigenvalue spectrum of . It guarantees the gap between two adjacent eigenvalues is not very large, and there is a gap between the largest and the second largest eigenvalue. Note the second part of the assumption is a relaxed version of Assumption 3.7. In our CIFAR-10 1k-subset with samples’ mean subtracted, (See Appendix D.2.1, Figure 19). The second assumes that all components are not too small.
Under the two assumptions, we have the following theorem:
Suppose Assumption C.1, C.2 hold. Suppose . For any , if , and , we have the following properties for where is the time when or for the first time.
(Progressive Sharpening) (Lemma C.6)
We first prove Lemma C.3, which implies that approximately converges independently in each direction of ’s non-zero eigenspace. Lemma C.3 also proves the second point . (Recall that is defined in (10).)
Then, based on the conclusion in Lemma C.3, Assumption C.1 and C.2, we prove that grows in Lemma C.4 and Lemma C.5. Specifically, here we prove a sufficient condition of .
Finally, we use the dynamics of and its dependence on dynamics to prove the sharpness grows (Lemma C.6), thus finishing the proof.
Remark 1. In the theorem, is the termination condition for this theorem. Here, is the Gram matrix plus the second order term (). Since the second order term is small, we have . Also, in Section C.3, we prove is almost a linear interpolation of and . Thus, can be seen as an approximation of the sharpness.
Remark 2. From the experiments, one can see that gradient descent is in progressive sharpening phase until the sharpness crosses the threshold . Right now, our proof only works till reaches . It would be interesting to extend our result to .
Remark 3. In this theorem, we require mild over-parameterization (, assuming , to prove the direction guarantee of the Gram matrix and the monotone increment of . Astute readers may find it similar to the NTK regime, where the parameters do not move far from the initialization. However, we stress that our analysis does not necessarily require NTK regime, and can go beyond NTK. We defer the discussion on the difference between our results and the NTK regime to Appendix C.4.
Then we break the proof of theorem into lemmas. The first lemma (Lemma C.3) proves that the Gram matrix by bounding the movement of . In this way, can approximately descend in each eigenvector of independently. Also, by proving , we justify as an indicator of the sharpness.
Along GD training trajectory, if , we have the following properties until :
and .
, where
.
We first consider the base case. For property 1, and . For property 2, with symmetric initialization, , hence , . For property 3,
The minimal eigenvalue of is . Thus all the properties hold at iteration .
Suppose for all , these properties hold. Then we consider the case in iteration .
We first show a worst-case upper bound for .
The second inequality uses property 3 in . Note in our setting, so the last equality holds. That means and
Now, we show the error is bounded. We have
Hence we have .
Then we can have the following bound by this recursion:
Here the third inequality holds because . Thus the second property holds for .
Then we consider the lower bound of .
Consider the dynamics of in (7) and sum the difference up from 0 to . Recall that we proved by (D) above.
Since , we have the lower bound .
Next, we lower bound the minimal non-zero eigenvalue (i.e. the -th largest eigenvalue since is rank ) of and .
For and , since the part is PSD, we have
From the inequality in (# ‣ C.2), and from (D) , we know
Thus (and also ) has its smallest eigenvalue larger than . Property 3 holds. To extend this conclusion, we actually have for all from the argument above.
Finally we bound . We first write down the dynamics of according to Lemma C.2.
Then we bound these three terms one by one.
Term (G1):
By symmetry, we just consider the first term
The first inequality comes from . The last three inequalities require that
Combined with its symmetric counterpart in , the sum of (A1) is smaller than .
Similarly, we have their symmetric counterpart added and get a bound of .
Similarly, we can combine its symmetric counterpart and get a bound of .
Add them up, and we can get the bound of the first part.
The last inequality is the same one as in the term (G1) bound.
Adding the three terms together and using the induction hypothesis, we have
Property 1 holds. Therefore the proof is completed. ∎
Lemma C.3 tells us that decreases along GD trajectory in some fixed directions independently depending on . After we have this GD trajectory, we can have the following Lemma C.4 about the dynamics of under the condition in Lemma C.3. It shows a sufficient condition for to grow.
Under the Assumption C.1 and Assumption C.2, if
and as long as there exist two number (to be determined) and some at time t s.t.
we have .
We use property 2 of Lemma C.3 to obtain the following expression:
Notice that all inequalities hold since for all . In the first inequality, we use the bound in (E1), and in the second we just replace with its lower bound Then we use and complete the proof.
Then, we use Assumption C.1 to prove the next lemma. It tells that condition (14) is satisfied under this assumption in a time interval. That means during this period.
Under Assumption C.1, we have condition (14) satisfied with in the time interval . Here, is the iteration that for the first time, and is the iteration when for the first time.
In this way, the only two possibility that all doesn’t satisfy the condition (14) is: (1) the ; (2) . Otherwise, there must be some s.t. Thus, if condition (15) is satisfied, we have this lemma proved.
Now suppose . By Bernoulli’s inequality,
since for all , we have
Hence we have the following inequalities:
Then we pay attention back to sharpness. We have the sharpness’s dynamics by Lemma C.2.
This equation shows that the dynamics of sharpness is closely related to the dynamics of , i.e. highly dependent on . Based on the lemmas above, we can prove progressive sharpening happens almost along the whole training trajectory (Lemma C.6) until the loss converges to .
Under Assumption C.1 and C.2, if and
we have until the time t when .
Remark. When , the lower bound of guarantee that
is larger than 0. So as long as the first order term
First, we give a lower bound for the number :
where the first equation holds due to Property 2 of Lemma C.3.
With the lower bound of , we show the dynamics of the first order term by similar technique in the expression (C.4) :
The last inequality holds due to the lower bound of (16) assumed in Lemma C.6.
Now, begins to decrease each iteration. Before the time when becomes smaller than , always holds because of the lower bound of (16) assumed in Lemma C.6.
Then, after the time when and before the time when for all , we enter the time interval where Lemma C.5 begins to hold. We use Lemma C.5 to show that there exists some to make
Before the time , we have this inequality always hold. Thus
holds until the iteration . Thus during this period, keeps increasing.
At this iteration, , and we can bound the norm of the residual with the inequality below. We have
Thus, before the norm of the residual decreases to this value, keeps increasing. ∎
C.3 Edge of Stability (Phase II-IV)
In the edge of stability regime, we focus on the largest eigenvalue and its corresponding eigenvector . Since has a large similarity with in progressive sharpening phase, we consider the eigenvector corresponding to the largest eigenvalue of .
After , the proof in Section C.2 does not extend to this phase. However, the bound of (Lemma C.3) still holds up to a constant factor empirically (See Figure 20). Hence, we make this bound an assumption as follows.
There exists some constant , such that for any time ,
Note that in above progressive sharpening stage, the assumption holds by Theorem 3. We propose this assumption to keep the gram matrix from deviating too far from the original trajectory even in other phases. The verification of this assumption can be found in Appendix D.2.2.
Recall that is the largest eigenvector of and is the largest eigenvector of . There exists a constant , such that , and .
By difinition of in 10, , here .
Let and decompose by . Then we have .
Also we have . So , which induces . Because in our setting , there exists a constant such that .
The inequality is because by definition of . The other side can be proved as the following:
To prove the main theorem (Theorem 4), we need two more assumptions.
There exists some constant such that for some at the beginning of phase II.
There exists some constant , such that
The above assumption is consistent with Assumption 3.4, in which we assume an upper bound of the sharpness. Lewkowycz et al. showed that is a upper bound of the sharpness in two-layer linear network with one datapoint, otherwise the training process would diverge. Here we make it an assumption.
Suppose the smallest nonzero eigenvalue . Under Assumption C.3, C.5, C.4, and in Assumption C.1, there exists constants , such that if , we have
(Lemma C.13) There exists which is related to such that if for some , there must exist some such that .
(Lemma C.11) If , then there is a constant (related to ) such that .
(Lemma C.10) Define , and . We have .
Next, we prove this theorem in three parts: first we prove the third statement, which gives an upper bound (Lemma C.10), then we prove the second statement, in which we use Assumption C.4 to prove that when sharpness is above , increases geometrically (Lemma C.11), and lastly we prove that the sharpness eventually drops below (Lemma C.13), which is the first statement in our theorem.
The dynamics of the approximation on sharpness is:
The proof of the equation is long and tedious, so we leave that in Lemma E.11.
Next we deal with the gap between and . Note that is the Gram Matrix, but in gradient descent trajectory, , so is the one that truly controls ’s dynamics. From the following lemma, we can see that is a smoothed version of and plus a small perturbation.
If (recall that is defined in Assumption C.3), then there exists and a constant such that .
Recall that . Then we consider two different cases.
Case 1: .
In this case . Here the last inequality follows from the inequality (5).
Case 2: .
We claim that in this case we have . If it does not hold, then . Hence we can have
The last inequality uses the restriction of in this lemma and the inequality (5). Hence we have , which leads to a contradiction.
Hence now holds. Since and , we can have:
Now let , by the inequality above we have .
we have . Hence . Now combining the conclusions in both cases together, we finish the proof. ∎
Then we consider a corollary of this lemma. Basically, since is a weighted sum of and adding a small perturbation and has a decomposition to the component and a small noise , can also be decomposed into the component and a small noise.
can be decomposed to , where and for any eigenvector of except , and if let ,
By Lemma C.8, if we denote , then .
Denote by . By Assumption C.3 and Lemma C.8, .
Note that by Assumption C.1, for any . Then, we can see that
Here the last inequality holds due to Assumption C.5.
Now the inequality above shows that for any eigenvector of except ,
On the other side,
Take . Now because and is some constant, we can see . ∎
Before using this corollary to derive the dynamics of (and thus gives an upper bound of ), we need an upper bound for .
For any constant , if and , there exists a constant such that .
First we analyze the right hand side of equation (17). We can get
Here the third inequality follows from inequality (5) which is , and the last inequality holds because and by the restriction of in this lemma.
On the other hand, the left hand side of equation (17) is . Here the first inequality follows because of and Corollary C.2, and the second inequality holds because of Assumption C.5.
Hence we have . Now if , the inequality cannot hold. Note that and , and also from inequality (5), , we finish the proof. ∎
Now we can give a lemma on . The proof idea is similar to Lemma 3.5 in Section 3.
Define . We have .
We consider the update rule for , whose proof is in Lemma E.12:
Hence if we denote , then we have
Using the upper bound of in Lemma C.9, and Assumption C.3 we have
Now we consider the sequence .
First by Corollary C.3, we can see that the eigenvalues of are all the eigenvalues of except the largest one, hence are in . Hence because , if we let , then by Corollary C.3 we have all eigenvalues of are in where . Hence .
Thus if we denote by , and replace in the inequality above by , we can get . Hence, we can have for any time . Therefore, we can obtain .
Now based on Theorem C.10, we can give an upper bound of . Because is always decreasing and , hence if , we can have . Hence
Next we can use Assumption C.4 to prove that increases geometrically when , which then causes the drop of the sharpness.
Let , , . If , we have .
Also we have .
Here the third inequality holds by the definition of . ∎
Now we state a lemma which proves that if is large enough, then the sharpness will decrease in the next iteration.
Assume . There exists constant such that if , then .
Recall Equation (17). Also we have by (19). Hence
Here , , and the first inequality holds because of Assumption C.5, Assumption C.3 and , the second inequality holds because of , and the third inequality follows from the upper bound (19) of .
Note that it is a quadratic function of . Hence if , we have
Now we can prove the final part (the first conclusion) of Theorem 4.
Let be the one defined in Theorem C.11. If for some , there exists some such that .
Otherwise, for any , . Then by Theorem C.11, increases geometrically, hence there exists , such that . Now by Lemma C.12, each iteration will decrease by at least a fixed amount. Hence there must exist a time such that . Then by Corollary C.2, we get a contradiction. ∎
C.4 Our Results and the NTK Regime
In this subsection, we explain why our results (Theorem 3, Theorem 4) are sufficiently different from the quadratic setting (e.g., linear regression) or the recent convergence analysis in NTK setting.
A key requirement in the convergence analysis in the NTK regime is that the learning rate is very small and the GD trajectory almost tracks the gradient flow, hence converges to the global minimum. However, we consider typical learning rate used in practice, which can be much larger. In particular, can happen in our setting, which causes instability (i.e., such as the growth of loss in Lemma C.11) along the training trajectory. Such instability cannot be captured by any existing convergence analysis in NTK regime at all. Hence, all existing NTK convergence results do not directly apply here.
Equally importantly, we find that even when changes slightly (several orders of magnitude smaller than its initialization), PS and EOS still happen with a not so small learning rate . To support our claim, we include the experimental results in Appendix D.2.3. In Figure 22, we can see that the initialization is much larger than the change of and the norm of grows larger when becomes larger. However, we still observe that PS and EOS occur in this setting. Hence, the setting we study in this paper and our results are intrinsically different from the quadratic setting (in which case EOS cannot happen).
Last, in our proofs in Section C.2 and C.3, our current bound requires that and we also assume . This may create an impression that we need a very wide network which operates in the NTK regime. However, we remark that if our analysis can be tightened to , one can formally prove that can actually change significantly () has the same scale as the initialization ), resulting a significant change of sharpness as well, hence beyond the NTK regime. For example, in the proof of EOS (Section C.3), we prove a loose upper bound of (Lemma C.9). However by Lemma C.12, when reaches , the sharpness starts dropping quickly. So if a better upper bound of can be proven (this is true empirically for all of our experiments), the width can be set to , and this suffices to implies a significant change of . We leave these improvements as future directions.
Appendix D Verification for Assumptions
In this section, we first justify the assumptions we made in Section 3 and Section 4 empirically. Then we present the experiment described in Section 5.
In this subsection, we conduct experiments to verify the assumptions in Section 3. The detailed experiment settings can be found in Appendix A.
In Section 3.2, we mentioned that the largest eigenvalue of is much smaller than the sharpness. We verify this assumption under different settings in Figure 13, including a fully-connected linear network, a fully-connected network with tanh activation and a convolutional one. Observe that (the blue curve) is very close to 0 and hardly increases during the training process along the whole trajectory.
D.1.2 Assumption 3.7
In this assumption, we assume that there is a large gap between the largest and the second largest eigenvalue, and thus the second largest eigenvalue is always below . We verify the outlier assumption by calculating the largest and the second largest eigenvalue of . In Sagun et al. , the sharpness is much larger than the largest eigenvalue in the bulk (the -th largest eigenvalue of where is the number of classes). In our binary setting . In Figure 16, we show that the largest eigenvalue indeed dominates the second one, and the second one never reaches , which verifies Assumption 3.7.
D.1.3 Assumption 3.2 (First Order Approximation of GD)
In Assumption 3.2, we assume the gradient descent trajectory is close to the first order approximation. To verify that the first order term is indeed dominant along the trajectory, for both the residual and the output layer norm , we plot the norms of the actual GD update, the first order approximation order approximation and the higher order terms of the update rule in Figure 15. Observe that in the progressive sharpening phase, the first order approximation is almost the same as the actual gradient update; while in the EOS phase, the first order approximation is still close to the actual gradient most of the time. We can see that the norm of the higher order terms spikes occasionally, but when this happens the first order term spikes much higher.
D.1.4 Assumption 3.3 (Gradient flow for the PS phase)
In Assumption 3.3, we assume that in the progressive sharpening phase, the gradient descent trajectory is close to the gradient flow trajectory. We refer to Appendix J in Cohen et al. for more experiments about this claim. Here for readers’ convenience, we duplicate their Figure 29 in Appendix J as Figure 16.
D.1.5 Assumption 3.5 (iii) (principal directions moves slowly)
In Figure 17 we verify Assumption 3.5 (iii) and as well as the discussion after Assumption 3.5 (i). In general models, we find that the eigenvectors corresponding to small eigenvalues may change drastically. But for the largest eigenvector, it indeed changes slowly from the initialized direction. In Figure 17, we can see that over a long training time the similarity of with its initialization is still larger than at least 0.98. Mulayoff et al. also proved that near the minima, the top eigenvectors of the Hessian matrices tend to align. That is, the directions of these top eigenvectors are approximately parallel. This fact also corroborates our assumption near the minima.
D.2 Assumptions in Section 4
In this subsection, we present the assumptions in Section 4, and conduct experiments to verify them. We add a scale coefficient in the linear network to be consistent with the settings of theoretical analysis.
In Assumption 4.1, we assume the ratio between the two adjacent eigenvalues of is bounded by a small constant. In the 1000-example subset of CIFAR-10, we verify this assumption by experiments. We plot the eigenvalues and their ratio in Figure 18. It shows that Assumption 4.1 holds and the constant , since almost all the ratios are close to 1, and the largest ratio is .
D.2.2 Assumption 4.3
In Appendix C.2, by Theorem 3 we prove that is bounded by in the progressive sharpening phase. When gradient descent enters EOS, the proof does not hold and we make this bound into an assumption (Assumption 4.3). We empirically verify that the bound can only increase by a constant factor (despite some spikes in EOS). See Figure 20. In this figure with .
Actually there are two interesting empirical facts related to . One is the noticeable fact that spikes, the other is that the values of are overall quite small (despite the fact that changes non-trivially in our experiments) and decreases as becomes larger. Our assumption tries to model the second fact (see Figure 20, (despite the spikes) decreases as the width grows, and the largest is almost in all these experiments). However, we admit that our results do not reflect the first fact (the spikes of ), and it is an interesting fact that is worth investigating. We have strong intuition that only grows by at most a constant factor, but currently do not have a formal proof yet. Nevertheless, the spiking behavior does not directly contradict our assumption.
Remark: Note that Assumption 4.3 is not equivalent to a small movement of . Actually, in the experiments above () the movement of is quite significant compared to the norm of at initialization. See Figure 21.
D.2.3 Comparison with the NTK regime: the non-quadratic property
Here we illustrate why our setting and results are sufficiently different from the quadratic setting (e.g., linear regression) or the recent convergence analysis in NTK setting. In particular, we show that even when the movement of is comparably negligible compared to the initialization , EOS can still happen. Here we take a larger initialization of , which is ten times of the standard initialization in order to dwarf the movement of . The widths are . We can see that the initialization is much larger than the change of and the norm of grows larger when becomes larger. See Figure 22. Detailed comparison is in Appendix C.4.
D.3 Experiments in Section 5
In this subsection we show some empirical results that may reveal some interesting relation between the inner layers and the sharpness, which is not yet reflected in our theory. Our experimental results show that all layers seem to work together to influence the sharpness, and contribute to the progressive sharpening and edge of stability phenomena. In our experiment, while the sharpness is still calculated by the gradient of all parameters, we freeze some of the layers in the training process. The experimental results show that the more layers we freeze, the slower progressive sharpening happens and the weaker the oscillation of the sharpness is (See Figure 23, Figure 24). This indicates that layers other than the output layer has nontrivial influence on the sharpness, but since different layers seem to work in the same direction, further justifying our assumption that is positively related with the sharpness.
Appendix E Missing proofs
In this section, we provide the missing proofs in Section 3.
(Lemma 3.1) For all in Phase I, under Assumption 3.5 (i) and 3.3, it holds that .
Consider the inner product . Recall is the -th eigenvector of . By Assumption 3.5(i), does not change with . By Assumption 3.3, we have
where is the corresponding eigenvalue of .
Since , Then the differential equation has the solution
Plug it into the expression and we have:
(Lemma 3.2) Suppose Assumption 3.5 (iii) and 3.6 hold during this phase (with constants and ). If and , then increases geometrically with factor for in this phase.
First by (3), we have .
where first inequality holds due to Assumption 3.5 (iii) and the third follows from Assumption 3.6. ∎
(Proposition 3.1) If , then .
This proposition can be proved by simply noticing that when . ∎
(Proposition 3.2) Under Assumption 3.2, if , then .
Use Assumption 3.2 and notice that . ∎
Then the second statement is due to Assumption 3.2. ∎
(Lemma 3.4) Suppose Assumption 3.5 (iii) holds. satisfies the following:
We consider the update rule for :
Now if we decompose , where . Then we have
Similar result can be obtained for the term .
Therefore, ∎
(Lemma 3.5) Define an auxiliary sequence by , and . If Assumption 3.4, Assumption 3.5 (iii), Assumption 3.7 hold, and for any time there exists a quantity , such that the smallest eigenvalue of , i.e. , then there exists a constant such that .
First we can see that the eigenvalues of are all the eigenvalues of except the largest one. Hence with Assumption 3.7, all eigenvalues of are in . Thus .
Thus if we denote by , and replace in the inequality above by , we can get . Hence, we can see that for any time . Therefore, we obtain that
For all in Phase I, under Assumption 3.5 (i) and Assumption 3.7, it holds that where is defined in Lemma 3.5.
Consider the inner product . Recall is the -th eigenvector of . By Assumption 3.5 (i), does not change with .
By Assumption 3.7, for , where is the corresponding eigenvalue of .
By definition of and Assumption 3.5 (i), , hence for and . Hence for any , .
Since , hence for any .
Plug it into the expression and we have:
E.2 Progressive Sharpening under Weaker Assumptions
We prove Lemma 3.1 in Section 3, i.e. progressive sharpening happens under Assumption 3.5 (i) that the set of eigenvectors of the Gram matrix is fixed throughout. However, empirically, the eigenvectors of change non-negligibly (see Figure 26). In this section, we show that it is possible to relax Assumption 3.5 (i) to more realistic assumption on the eigenspace of . To this end, we first present a dynamical system view of the dynamics of , then prove Lemma E.7 which is analogue of Lemma 3.1 but under weaker assumptions.
E.2.2 Progressive sharpening when eigendirections change slowly
Suppose at initialization . By , we know . With loss of generality, we assume at initialization for all (Otherwise, we define and this condition holds).
Suppose Assumption 3.3 holds, and the set of (unit) eigenvectors of is . Assume at all time and direction , the following condition holds:
Then we have for all , where is the first time when there exists some , .
We show for each , under the conditions of the lemma.
We first consider the dynamics of inner product . According to Assumption 3.3, when , due to the continuity. Moreover, by the dynamics of in Assumption 3.3, we can see
With this dynamics above and , we can get ’s dynamics:
E.2.3 Empirical verification of inequality (20)
We verify the condition (20) in Lemma E.7 via experiments. See Figure 26. We can see that (20) holds for during the first hundred iterations of the training process. However, for very large , the eigenvectors corresponding to very small eigenvalues may change quickly and (20) does not hold. The contributions (i.e., ) from those corresponding to very small eigenvalues tend to cancel each other empirically, hence does not affect the sign of the total sum . Hence, it is possible to further relax the condition (20) and we leave it as a future direction.
E.3 Proofs of equations in Appendix C
The proof of some equations in Appendix C is omitted, and we list them in this subsection.
(Lemma C.1) The update rule of the residual vector of :
(Lemma C.2) The update rule of the Gram matrix is,
By the update rule of and in equation (6) and (7), we have
Rearrange the terms and we complete the proof. ∎
If , then
With the dynamics of , we have
(Lemma C.7) Here we give the proof of the equation (17):
First, since is initialized as , by definition, we have
.
(Equation 18)
Appendix F Missing Preliminaries
Hessian, Fisher information matrix and NTK: The Hessian of the objective is:
We need the relationship between the Hessian matrix, the Fisher information matrix (FIM) and the neural tangent kernel (NTK). As shown in Papyan , Martens , Bottou et al. , the Hessian can be decomposed into two components:
in other words, is also an eigenvalue of .
Sharpness: There are various definitions of sharpness in the literature (). In particular, a popular definition of the sharpness is the largest eigenvalue of the Hessian (). Based on the above discussion, in this paper, we adopt the largest eigenvalue of , as the definition of the sharpness, which is a close approximation of the largest eigenvalue of the Hessian empirically.
Gradient Descent: In this paper, we study the trajectory of gradient descent and gradient flow Gradient flow is a good approximation of gradient descent in the beginning of the training. See Cohen et al. for more experiments and Ahn et al. for theoretical justification. We assume this fact during the progressive sharpening phase. See Assumption 3.3. . We use to denote the parameter at iteration (or time ) and the sharpness at time as . We similarly define .
Along GD trajectory, the weight vector is updated in the following way:
When the learning rate is infinitesimal, the GD trajectory above is equivalent to gradient flow trajectory. Here we show the gradient flow dynamics of the residual vector :
In light of (23), we have the following approximate update rule of under gradient descent: