S TRENGTH OF M INIBATCH N OISE IN SGD
Anonymous authors
Paper under double-blind review
A BSTRACT
The noise in stochastic gradient descent (SGD), caused by minibatch sampling, is poorly understood despite its practical importance in deep learning.
This work presents the ﬁrst systematic study of the SGD noise and ﬂuctuations close to a local minimum.
We ﬁrst analyze the SGD noise in linear regression in detail and then derive a general formula for approximating SGD noise in different types of minima.
For application, our results (1) provide insight into the stability of training a neural network, (2) suggest that a large learning rate can help generalization by introducing an implicit regularization, (3) explain why the linear learning ratebatchsize scaling law fails at a large learning rate or at a small batchsize and (4) can provide an understanding of how discrete-time nature of SGD affects the recently discovered power-law phenomenon of SGD.
I NTRODUCTION
Stochastic gradient descent (SGD) is the simple and efﬁcient optimization algorithm behind the success of deep learning (Allen-Zhu et al., 2019;
Xing et al., 2018; Zhang et al., 2018; Wang et al., 2020; He and Tao, 2020; Liu et al., 2021; Simsekli et al., 2019; Wu et al., 2020).
Minibatch noise, also known as the SGD noise, is the primary type of noise in the learning dynamics of neural networks.
Practically, minibatch noise is unavoidable because a modern computer’s memory is limited while the size of the datasets we use is large; this demands the dataset to be split into “minibatches" for training.
At the same time, using minibatch is also a recommended practice because using a smaller batch size often leads to better generalization performance (Hoffer et al., 2017).
Therefore, understanding minibatch noise in SGD has been one of the primary topics in deep learning theory.
Dominantly many theoretical studies take two approximations: (1) the continuous-time approximation, which takes the inﬁnitesimal step-size limit; (2) the Hessian approximation, which assumes that the covariance matrix of the SGD noise is equal to the Hessian H .
While these approximations have been shown to provide some qualitative understanding, the limitation of these approximations is not well understood.
For example, it is still unsure when such approximations are valid, which hinders our capability to assess the correctness of the results obtained by approximations.
In this work, we ﬁll this gap by deriving analytical formulae for discrete-time SGD with arbitrary learning rates and exact minibatch noise covariance.
In summary, the main contributions are: (1) we derive the strength and the shape of the minibatch SGD noise in the cases where the noise for discrete-time SGD is analytically solvable; (2) we show that the SGD noise takes a different form in different kinds of minima and propose general and more accurate approximations.
This work is organized as follows:
Sec. 2 introduces the background.
Sec. 3 discusses the related works.
Sec.outlines our theoretical results.
Sec. 5 derives new approximation formulae for SGD noises.
In
Sec. 6, we show how our results can provide practical and theoretical insights to problems relevant to contemporary machine learning research.
For reference, the relationship of this work to the previous works is shown in Table 1.
B ACKGROUND
In this section, we introduce the minibatch SGD algorithm.
Let { x i ,y i } Ni
= 1 be a training set.
We can deﬁne the gradient descent (GD) algorithm for a differentiable loss function L as w t = w t − 1 − λ ∇ w L ( w , { x , y }) , where λ is the learning rate and w ∈ R D is the weights of the model.
We consider an additive loss function for applying the minibatch SGD.
Deﬁnition 1.
A loss function L ({ x i ,y i } Ni = 1 , w ) is additive if L ({ x i ,y i } Ni = 1 , w ) = for some differentiable, non-negative function (cid:96) (⋅) .
[Table]
This deﬁnition is quite general.
Most commonly studied and used loss functions are additive, e.g., the mean-square error (MSE) and cross-entropy loss.
For an additive loss, the minibatch SGD with momentum algorithm can be deﬁned.
Deﬁnition 2.
The minibatch SGD with momentum algorithm by sampling with replacement computes the update to the parameter w with the following set of equations:
[Equation]
where µ ∈ [ 0 , 1 ) is the momentum hyperparameter, S ∶= ∣ B t ∣ is the minibatch size, and the set
B t = { i 1 ,...i S } are S i.i.d.
random integers sampled uniformly from [ 1 ,N ] .
One can decompose the gradient into a deterministic plus a stochastic term.
Note that E B [ ˆ g t ] = ∇ L is equal to the gradient for the GD algorithm.
We use E B (⋅) to denote the expectation over batches, and use E w (⋅) to denote the expectation over the stationary distribution of the model parameters.
Therefore, we can write ˆ g t = E B
[ ˆ g t ] + η t , where η t ∶= 1 S
∑ i ∈ B t ∇ (cid:96) ( x i ,y i , w t − 1 ) − E B
[ ˆ g t ] is the noise term; the noise covariance is C ( w t ) ∶= cov ( η t ,η t ) .
Of central importance to us is the averaged asymptotic noise covariance C ∶=
lim
t →∞ E w t
[ C ( w t )] .
Also, we consider the asymptotic model ﬂuctuation Σ ∶= lim t →∞ cov ( w t , w t ) .
Σ gives the strength and shape of the ﬂuctuation of w around a local minimum and is another quantity of central importance to this work.
Throughout this work, C is called the “noise" and Σ the “ﬂuctuation".
R ELATED W ORKS
Noise and Fluctuation in SGD .
Deep learning models are trained with SGD and its variants.
To understand the parameter distribution in deep learning, one needs to understand the stationary distribution of SGD (Mandt et al., 2017).
Sato and Nakagawa (2014) describes the stationary distribution of stochastic gradient Langevin dynamics using discrete-time Fokker-Planck equation.
Yaida (2019) connects the covariance of parameter Σ to that of the noise C through the ﬂuctuationdissipation theorem.
When Σ is known, one may obtain by Laplace approximation the stationary distribution of the model parameter around a local minimum w ∗ as N( w ∗ , Σ ) .
Therefore, knowing Σ can be of great practical use.
For example, it has been used to estimate the local minimum escape efﬁciency (Zhu et al., 2019; Liu et al., 2021) and argue that SGD prefers a ﬂatter minimum; it can also be used to assess parameter uncertainty and prediction uncertainty when a Bayesian prior is speciﬁed (Mandt et al., 2017; Gal and Ghahramani, 2016; Pearce et al., 2020).
Empirically, both the ﬂuctuation and the noise are known to crucially affect the generalization of a deep neural network.
Wu et al.
(2020) shows that the strength and shape of the Σ due to the minibatch noise lead to better generalization of neural networks in comparison to an artiﬁcially constructed noise.
Hessian Approximation of the Minibatch Noise.
However, it is not yet known what form C and Σ actually take for SGD in a realistic learning setting.
Early attempts assume isotropic noise in the continuous-time limit (Sato and Nakagawa, 2014;
Mandt et al., 2017).
In this setting, the noise is an isotropic Gaussian with C ∼ I D , and Σ is known to be proportional to the inverse Hessian H − 1 .
More recently, the importance of noise structure was realized (Hoffer et al., 2017; Jastrzebski et al., 2018;
Zhu et al., 2019; HaoChen et al., 2020).
“Hessian approximation", which assumes C ≈ c 0 H for some constant c 0 , has often been adopted for understanding SGD (see Table 1); this assumption is often motivated by the fact that C =
J w ≈ H , where J w is the Fisher information matrix (FIM)
(Zhu et al., 2019); the ﬂuctuation can be solved to be isotropic: Σ ∼ I D .
However, it is not known under what conditions the Hessian approximation is valid, while previous works have argued that it can be very inaccurate (Martens, 2014;
Liu et al., 2021; Thomas et al., 2020; Kunstner et al., 2019).
However,
Martens (2014) and Kunstner et al.
(2019) only focuses on the natural gradient descent (NGD) setting;
Thomas et al.
(2020) is closest to ours, but it does not apply to the case with momentum, a matrix learning rate, or regularization.
Discrete-time SGD with a Large Learning Rate .
Recently, it has been realized that networks trained at a large learning rate have a dramatically better performance than networks trained with a vanishing learning rate (lazy training)
(Chizat and Bach, 2018).
Lewkowycz et al.
(2020) shows that there is a qualitative difference between the lazy training regime and the large learning rate regime; the performance features two plateaus in testing accuracy in the two regimes, with the large learning rate regime performing much better.
However, the theory regarding discrete-time SGD at a large learning rate is almost non-existent, and it is also not known what Σ may be when the learning rate is non-vanishing.
Our work also sheds light on the behavior of SGD at a large learning rate.
Some other works also consider discrete-time SGD in a similar setting (Fontaine et al., 2021;
Dieuleveut et al., 2020; Toulis et al., 2017), but the focus is not on deriving analytical formulae or does not deal with the stationary distribution.
SGD N OISE AND F LUCTUATION IN L INEAR R EGRESSION
This section derives the shape and strength of SGD noise and ﬂuctuation for linear regression; concurrent to our work, Kunin et al.
(2021) also studies the same problem but with continuous-time approximation; our result is thus more general.
To emphasize the message, we discuss the label noise case in more detail.
The other situations also deserve detailed analysis; we delay such discussion to the appendix due to space constraints.
Notation : S denotes the minibatch size.
w ∈ R D is the model parameter viewed in a vectorized form; λ ∈ R + denotes a scalar learning rate; when the learning rate takes the form of a preconditioning matrix, we use Λ ∈ R D × D .
A ∈ R D
× D denotes the covariance matrix of the input data.
When a matrix X is positive semi-deﬁnite, we write X ≥ 0 ; throughout, we require Λ ≥ 0 .
γ ∈ R denotes the weight decay hyperparameter; when the weight decay hyperparameter is a matrix, we write Γ ∈ R D × D .
µ is the momentum hyperparameter in SGD.
For two matrices X,Y , the commutator is deﬁned as [ X,Y ] ∶= XY − Y X .
Other notations are introduced in the context.
The results of this section are numerically veriﬁed in Sec.
A.
4. K EY P REVIOUS R ESULTS
When N ≫ S , the following proposition is well-known and gives the exact noise due to minibatch sampling.
See Appendix E.1 for derivation.
Proposition 1.
The noise covariance of SGD as deﬁned in Deﬁnition 2 is
[Equation]
where the notations (cid:96) i ( w ) ∶= l ( x i ,y i , w ) and L ( w ) ∶=
L ({ x i ,y i } Ni = 1 , w ) are used.
This gradient covariance matrix C is crucial to understand the minibatch noise.
The standard literature often assumes C ( w ) ≈ H ( w ) ; however, the following well-known proposition shows that this approximation can easily break down.
Proposition 2.
Let w ∗ be the solution such that L ( w ∗ )
= 0 , then C ( w ∗ )
= 0 .
Proof .
Because (cid:96) i is non-negative for all i , L ( w ∗ ) =
implies that (cid:96) i ( w ∗ )
= 0 .
The differentiability in turn implies that each ∇ (cid:96) i ( w ∗ ) = 0 ; therefore, C = 0 . ◻
This proposition implies that there is no noise if our model can achieve zero training loss (which is achievable for an overparametrized model).
This already suggests that the Hessian approximation
C ∼ H is wrong since the Hessian is unlikely to vanish in any minimum.
The fact that the noise strength vanishes at L = 0 suggests that the SGD noise might at least be proportional to L ( w ) , which we will show to be true for many cases.
The following theorem relates C and Σ of the discrete-time
SGD algorithm with momentum for a matrix learning rate.
Theorem 1.
(Liu et al., 2021) Consider running SGD on a quadratic loss function with Hessian H , learning rate matrix Λ , momentum µ .
Assuming ergodicity, then
[Equation]
Propostion 1 and Theorem 1 allow one to solve C and Σ .
Equation (3) can be seen as a general form of the Lyapunov equation (Lyapunov, 1992) and is hard to solve in general (Hammarling, 1982;
Ye et al., 1998; Simoncini, 2016).
Solving this analytical equation in settings of machine learning relevance is one of the main technical contributions of this work
4. R ANDOM N OISE IN THE L ABEL
We ﬁrst consider the case when the labels contain noise.
The loss function takes the form
[Equation]
where x i ∈ R D are drawn from a zero-mean Gaussian distribution with feature covariance A ∶= E
B [ xx T ] , and y i =
u T x i + (cid:15) i , for some ﬁxed u and (cid:15) i ∈ R is drawn from a distribution with zero mean and ﬁnite second momentum σ 2 .
We redeﬁne w − u → w and let N → ∞ with D held ﬁxed.
The following lemma ﬁnds C as a function of Σ .
Lemma 1.
( Covariance matrix for SGD noise in the label )
Let the model be updated according to
Eq.
(1) with random noise in the label while N → ∞ .
Then,
[Equation]
The model ﬂuctuation can be obtained using this lemma.
Theorem 2.
( Fluctuation of model parameters with random noise in the label ) Let the assumptions be the same as in Proposition 1 and [ Λ ,A ] = 0 .
Then,
[Equation]
where κ µ ∶=
Tr [
[Equation] [Equation]
Remark.
This result is numerically validated in Appendix A.
The subscript µ refers to momentum.
To obtain results for vanilla SGD, one can set µ = 0 , which has the effect of reducing G µ → G = 2 I D − ( 1 + 1 S )
Λ A .
From now on, we focus on the case when µ = 0 for notational simplicity, but we note that the results for momentum can be likewise studied.
The condition [ Λ ,A ] = 0 is not peculiar because this condition holds for a scalar learning rate and common second-order methods such as
Newton’s method.
If σ 2 = 0 , then Σ = 0 .
This means that when there is no label noise, the model parameter has a vanishing stationary ﬂuctuation, which corroborates Proposition 2.
When a scalar learning rate λ ≪and 1 ≪ S , we have
[Equation]
which is the result one would expect from the continuous-time theory with the Hessian approximation (Liu et al.,
; Xie et al., 2021; Zhu et al., 2019), except for a correction factor of σ 2 .
Therefore, a
Hessian approximation fails to account for the randomness in the data of strength σ 2 .
We provide a systematic and detailed comparison with the Hessian approximation in Table 2 of Sec.
B.
Moreover, it is worth comparing the exact result in Theorem 2 with Eq.
(7) in the regime of nonvanishing learning rate and small batch size.
One notices two differences: (1) an anisotropic enhancement, appearing in the matrix G µ and taking the form − λ
( 1 + 1 / S ) A ; compared with the result in Liu et al.
(2021), this term is due to the compound effect of using a large learning rate and a small batchsize; (2) an isotropic enhancement term κ , which causes the overall magnitude of ﬂuctuations to increase; this term does not appear in the previous works that are based on the
Hessian approximation and is due to the minibatch sampling process alone.
As the numerical example in Sec.
A shows, at large batch size, the discrete-time nature of SGD is the leading source of ﬂuctuation; at small batch size, the isotropic enhancement becomes the dominant source of ﬂuctuation.
Therefore, the minibatch sampling process causes two different kinds of enhancement to the ﬂuctuation, potentially increasing the exploration power of SGD at initialization but reducing the convergence speed.
Now, combining Theorem 2 and Lemma 1, one can obtain an explicit form of the noise covariance.
Theorem 3.
The noise covariance matrix of minibatch SGD with random noise in the label is
[Equation]
By deﬁnition, C =
J is the FIM.
The Hessian approximation, in sharp contrast, can only account for the term in orange.
A signiﬁcant modiﬁcation containing both anisotropic and isotropic (up to Hessian) is required to fully understand SGD noise, even in this simple example.
Additionally, comparing this result with the training loss (127), one can ﬁnd that the noise covariance contains one term that is proportional to the training loss.
In fact, we will derive in Sec.
that containing a term proportional to training loss is a general feature of the SGD noise.
We also study the case when the input is contaminated with noise.
Interestingly, the result is the same with the label noise case with σ 2 replaced by a more complicated term of the form Tr [ AK − 1 BU ] .
We thus omit this part from the main text.
A detailed discussion can be found in Appendix E.3.1.
In the next section, we study the effect of regularization on SGD noise and ﬂuctuation.
4. L EARNING WITH R EGULARIZATION
Now, we show that regularization also causes a unique SGD noise.
The loss function for Γ − Lregularized linear regression is
[Equation]
where Γ is a symmetric matrix; conventionally, one set Γ = γI D with a scalar γ > 0 .
For conciseness, we assume that there is no noise in the label, namely y i =
u T x i with a constant vector u .
One important quantity in this case will be uu T ∶= U .
The noise for this form of regularization can be calculated but takes a complicated form.
Proposition 3.
( Noise covariance matrix for learning with L 2 regularization )
Let the algorithm be updated according to Eq.
(1) with L 2 regularization with N → ∞ and [ A, Γ ] = 0 .
Then,
[Equation]
where A ′ ∶= K − 1 A , Γ ′ ∶=
K − 1 Γ with K ∶=
A + Γ .
Notice that the last term Γ A ′ UA ′ Γ in C is unique to the regularization-based noise: it is rankbecause U is rank-1.
This term is due to the mismatch between the regularization and the minimum of the original loss.
Also, note that the term Tr [ A Σ ] is proportional to the training loss.
Deﬁne the test loss to be L test ∶=
lim t →∞ E w t
[ 12 ( w t − u ) T A ( w t − u )] , we can prove the following theorem.
We will show that one intriguing feature of discrete-time SGD is that the weight decay can be negative.
Theorem 4.
( Test loss and model ﬂuctuation for L 2 regularization ) Let the assumptions be the same as in Proposition 3.
Then
[Equation]
where κ ∶=
Tr [ A 2 K − 1 G − 1 ] 1 −
[Equation]
Tr
[Equation]
A
[Equation]
G
[Equation]
r
[Equation]
=
Tr
[Equation]
K
[Equation]
G
[Equation]
G
[Equation]
1 ] , with G ∶= 2 I D − λ
( K + 1 S K − 1 A 2 ) .
Moreover, let [ Γ ,U ] = 0 , then
[Equation]
This result is numerically validated in Appendix A.
The test loss (11) has an interesting consequence.
One can show that there exist situations where the optimal Γ is negative .
2 When discussing the test loss, we make the convention that if w t diverges, then L test = ∞ .
Corollary 1.
Let γ ∗ = arg min γ L test .
There exist a , λ and S such that γ ∗ < 0 .
The proof shows that when the learning rate is sufﬁciently large, only negative weight decay is allowed.
This agrees with the argument in Liu et al.
(2021) that discrete-time SGD introduces an implicit L 2 regularization that favors small norm solutions.
A too-large learning rate requires a negative weight decay because a large learning rate already over-regularizes the model and one needs to introduce an explicit negative weight decay to offset this over-regularization effect of SGD.
This is a piece of direct evidence that using a large learning rate can help regularize the models.
This result relates to the implicit regularization effect of SGD.
It has been hypothesized that the dynamics of
SGD implicitly regularizes neural networks such that the training favors simpler solutions (Kalimeris et al., 2019).
Our result suggests one new mechanism for such a regularization.
N OISE S TRUCTURE FOR G ENERIC S ETTINGS
The results in the previous sections suggest that (1) the SGD noises differ for different kinds of situations, and (2) SGD noise contains a term proportional to the training loss in general.
These two facts motivate us to derive the noise covariance differently for different kinds of minima.
Let f ( w ,x ) denote the output of the model for a given input x ∈ R D .
Here, we consider a more general case; f ( w ,x ) may be any differentiable function, e.g., a non-linear deep neural network.
The number of parameters in the model is denoted by P , and hence w ∈ R P .
For a training dataset { x i ,y i } i = 1 , 2 ,...,N , the loss function with a L 2 regularization is given by
[Equation]
(13) where L 0 ( w ) =
1 N ∑ N i = 1 (cid:96) ( f ( w ,x i ) ,y i ) is the loss function without regularization, and H 0 is
the
Hessian of L 0 .
We focus on the MSE loss (cid:96) ( f ( w ,x i ) ,y i ) =
[ f ( w ,x i ) − y i ] 2 / 2 .
Our result crucially relies on the following two assumptions, which relate to the conditions of different kinds of local minima.
Assumption 1.
(Fluctuation decays with batch size) Σ is proportional to S − 1 , i.e. Σ
= O ( S − 1 ) .
This is justiﬁed by the results in all the related works (Liu et al., 2021; Xie et al., 2021;
Meng et al., 2020; Mori et al., 2021), where Σ is found to be O
( S − 1 ) .
Assumption 2.
(Weak homogeneity) ∣ L − (cid:96) i ∣ is small; in particular, it is of order o ( L ) .
This assumption amounts to assuming that the current training loss L reﬂects the actual level of approximation for each data point well.
In fact, since L ≥ 0 , one can easily show that ∣ L − (cid:96) i ∣ =
O ( L ) .
Here, we require a slightly stronger condition for a more clean expression, when ∣ L − (cid:96) i ∣
=
O
( L ) we can still get a similar expression but with some constant that hinders the clarity.
Relaxing this condition can be an important and interesting future work.
The above two conditions allow us to state our general theorem formally.
Theorem 5.
Let the training loss be L Γ =
L 0 + 12 w T Γ w and the models be optimized with SGD in the neighborhood of a local minimum w ∗ .
Then,
[Equation]
The noise takes different forms for different kinds of local minima.
Corollary 2.
Omitting the terms of order o
( L 0 ) , when Γ ≠ 0 ,
[Equation]
When Γ = 0 and L 0 ( w ∗ ) ≠ 0 ,
[Equation]
When Γ = 0 and L 0 ( w ∗ ) = 0 ,
[Equation] [Equation]
Remark.
Assumption 2 can be replaced by a weaker but more technical assumption called the “decoupling assumption", which has been used in recent works to derive the continuous-time distribution of SGD (Mori et al., 2021; Wojtowytsch, 2021).
The Hessian approximation was invoked in most of the literature without considering the conditions of its applicability (Jastrzebski et al., 2018;
Zhu et al., 2019; Liu et al., 2021;
Wu et al., 2020; Xie et al., 2021).
Our result does provide such conditions for applicability.
As indicated by the two assumptions, this theorem is applicable when the batch size is not too small and when the local minimum has a loss close to 0 .
The reason for the failure of the Hessian approximation is that, while the FIM is equal to the expected Hessian
J = E
[ H ] , there is no reason to expect the expected Hessian to be close to the actual Hessian of the minimum.
The proof is given in Appendix C. Two crucial messages this corollary delivers are (1) the SGD noise is different in strength and shape in different kinds of local minima and that they need to be analyzed differently; (2) the SGD noise contains a term that is proportional to the training loss L 0 in general.
Recently, it has been experimentally demonstrated that the SGD noise is indeed proportional to the training loss in realistic deep neural network settings, both when the loss function is MSE and cross-entropy (Mori et al., 2021); our result offers a theoretical justiﬁcation.
The previous works all treat all the minima as if the noise is similar (Jastrzebski et al., 2018; Zhu et al., 2019;
Liu et al., 2021; Wu et al., 2020; Xie et al., 2021), which can lead to inaccurate or even incorrect understanding.
For example, Theorem 3.2 in Xie et al.
(2021) predicts a high escape probability from a sharp local or global minimum.
However, this is incorrect because a model at a global minimum has zero probability of escaping due to a vanishing gradient.
In contrast, the escape rate results derived in Mori et al.
(2021) correctly differentiate the local and global minima.
We also note that these general formulae are consistent with the exact solutions we obtained in the previous section than the
Hessian approximation.
For example, the dependence of the noise strength on the training loss in
Theorem 2, and the rank- 1 noise of regularization are all well-reﬂected in these formulae.
In contrast, the simple Hessian approximation misses these crucial distinctions.
Lastly, combining Theoremwith Theorem 1, one can also ﬁnd the ﬂuctuation.
Corollary 3.
Let the noise be as in Theorem 5, and omit the terms of order
O ( S − 2 ) and
O (∣ w − w ∗ ∣ 2 ) .
Then, when Γ ≠ 0 and when Λ , H 0 ( w ∗ ) and Γ commute with each other, P r ′ Σ
= 1 S Λ1 − µ ( 2 L 0 H 0 − Γ w ∗ w ∗ T Γ )
( H 0 + Γ )
+ [ 2 I D − Λ1 + µ ( H 0 + Γ )] − 1 .
When Γ = 0 and L 0 ( w ∗ ) ≠ 0 ,
P r Σ = 2 L 0 S ( 1 − µ ) P r Λ ( 2 I D − Λ1 + µ H 0 ) − 1 .
When Γ = 0 and L 0 ( w ∗ ) = 0 , P r Σ = 0 .
Here the superscript + is the Moore-Penrose pseudo inverse, P r ∶= diag ( 1 ,..., 1 , 0 ,..., 0 ) is the projection operator with r non-zero entries, r ≤ D is the rank of the Hessian H 0 , and r ′ ≤ D is the rank of H
+ Γ .
For the null space H 0 , Σ can be arbitrary.
A PPLICATIONS
One major advantage of analytical solutions is that they can be applied in a simple “plug-in" manner by the practitioners or theorists to analyze new problems they encounter.
In this section, we brieﬂy outline a few examples where the proposed theories can be relevant.
6. H IGH -D IMENSIONAL R EGRESSION
We ﬁrst apply our result to the high-dimensional regression problem and show how over-andunderparametrization might play a role in determining the minibatch noise.
Here, we take N,D → ∞ with the ratio α ∶= N / D held ﬁxed.
The loss function is L ( w ) = 12 N ∑ Ni = 1 ( w T x i − y i ) 2 .
As in the standard literature (Hastie et al., 2019), we assume the existence of label noise:
y i =
u T x i + (cid:15) i , with
Var [ (cid:15) i ]
= σ 2 .
A key difference between our setting and the standard high-dimensional setting is that, in the standard setting (Hastie et al., 2019), one uses the GD algorithm with vanishing learning rate λ instead of the minibatch SGD algorithm with a non-vanishing learning rate.
Tackling the high-dimensional regression problem with non-vanishing λ and a minibatch noise is another main technical contribution of this work.
In this setting, we can obtain the following result on the noise covariance matrix.
Proposition 4.
Let ˆ A = 1 N ∑ Ni x i x T i and suppose assumptions 1 and 2 hold.
With ﬁxed S , λ , then
[Equation]
We note that this proposition follows from Theorem 5, showing an important theoretical application of our general theory.
An interesting observation is that one Σ -independent term proportional to σemerges in the underparametrized regime ( α > 1 ).
However, for the overparametrized regime, the noise is completely dependent on Σ , which is a sign that the stationary solution has no ﬂuctuation.
This shows that the degree of underparametrization also plays a distinctive role in the ﬂuctuation.
In fact, one can prove the following theorem, which is veriﬁed in Sec. A.2.
Theorem 6.
When a stationary solution exists for w , we have Tr [ ˆ A Σ ] = max { 0 , λσ 2 S ( 1 − 1 α ) ˆ κ } , where ˆ κ ∶=
[Equation]
ˆ G
[Equation]
6. I MPLICATION FOR N EURAL N ETWORK T RAINING
It is commonly believed that the high-dimensional linear regression problem can be a minimal model for deep learning.
Taking this stance, Theorem 6 suggests a technique for training neural networks.
For SGD to converge, a positive semi-deﬁnite Σ must exist; however, Σ ≥
if and only if ˆ κ ≥ 0 .
From ˆ κ > 0 , we have ∑ Di =1 2 / λa i − 1 + 1 / S < S , where a i are the eigenvalues of ˆ A .
This means that each summand should have the order of D / S .
Thus the upper bound of λ should have the order of 2 S / aD , where a is the typical value of a i ’s. One implication of the dependence on the dimension is that the stability of a neural network trained with SGD may strongly depend on its width d , and one may rescale the learning rate according to the width to stabilize neural network training.
See Figure 1-Left and Middle.
We train a two-layer tanh neural network on MNIST and plot the variance of its training loss in the ﬁrst epoch with ﬁxed λ = 0 .
We see that, when d ≥ 200 , the training starts to destabilize, and the training loss begins to ﬂuctuate dramatically.
When rescaling the learning rate by 1 / d , we see that the variance of the training loss is successfully kept roughly constant across all d .
This suggests a training technique worth being explored by practitioners in the ﬁeld.
In Figure 1-Middle, we also use Adam for training the same network and ﬁnd a similar stabilizing trick to work for Adam.
6. A N ATURAL L EARNING E XAMPLE WITH N EGATIVE W EIGHT D ECAY
Sec.
4.3 shows that a too-large learning rate introduces an effective L 2 regularization that can only be corrected by setting the weight decay to be negative.
This effect can be observed in more realistic learning settings.
We train a logistic regressor on the MNIST dataset with a large learning rate (of order O ( 1 ) ).
Figure 1-Right conﬁrms that, at a large learning rate, the optimal weight decay can indeed be optimal.
This agrees with our argument that using a large learning rate can effectively regularize the training.
6. S ECOND - ORDER M ETHODS
Understanding stochastic second-order methods (including the adaptive gradient methods) is also important for deep learning (Agarwal et al., 2017; Zhiyi and Ziyin, 2021; Martens, 2014; Kunstner et al., 2019).
In this section, we apply our theory to two standard second-order methods: damped
Newton’s method (DNM) and natural gradient descent (NGD).
We provide more accurate results than those derived in Liu et al.
The derivations are given in Appendix D.2.
For DNM, the preconditioning learning rate matrix is deﬁned as Λ ∶= λA − 1 .
The model ﬂuctuation is shown to be proportional to the inverse of the Hessian: Σ = λσ 2 gS − λD
A − 1 , where g ∶= 2 ( 1 − µ ) − ( 1 − µ 1 + µ + 1 S ) λ .
The main difference with the previous results is that the ﬂuctuation now depends explicitly on the dimension D , and implies a stability condition:
S ≥ λD / g , corroborating the stability condition we derived above.
For NGD, the preconditioning matrix is deﬁned by the inverse of the Fisher information that Λ ∶= λS J ( w ) − 1 = λS C − 1 .
We show that Σ
= λ 2 ( 1 1 + D 11 + µ + 11 − µ 1 S )
A − 1 is one solution when σ = 0 , which also contains a correction related to D compared to the result in Liu et al.
(2021) which is Σ = λ 2 ( 11 + µ + 11 − µ 1 S )
A − 1 .
A consequence is that J ∼ Σ − 1 .
The surprising fact is that the stability of both NGD and DNM now crucially depends on D ; combining with the results in Sec. 6.1, this suggests that the dimension of the problem may crucially affect the stability and performance of the minibatch-based algorithms.
This result also implies that some features we derived are shared across many algorithms that depend on minibatch noise and that our results may be relevant to a broad class of optimization algorithms other than SGD.
6. F AILURE OF THE λ − S SCALING LAW
One well-known technique in deep learning training is that one can scale λ linearly as one increases the batch size S to achieve high-efﬁciency training without hindering the generalization performance; however, it is known that this scaling law fails when the learning rate is too large, or the batch size is too small (Goyal et al., 2017).
In Hoffer et al.
(2017), this scaling law is established on the ground that Σ ∼ λ / S .
However, our result in Theorem 2 suggests the reason for the failure even for the simple setting of linear regression.
Recall that the exact Σ takes the form:
[Equation]
for a scalar λ .
One notices that the leading term is indeed proportional to λ / S .
However, the discrete-time SGD results in a second-order correction in S , and the term proportional to 1 / S 2 does not contain a corresponding λ ; this explains the failure of the scaling law in small S , where the second-order contribution of S becomes signiﬁcant.
To understand the failure at large λ , we need to look at the term G µ :
[Equation]
One notices that the second term contains a part that only depends on λ but not on S .
This part is negligible compared to the ﬁrst term when λ is small; however, it becomes signiﬁcant as the second term approaches the ﬁrst term.
Therefore, increasing λ changes this part of the ﬂuctuation, and thus the scaling law no more holds if λ is large. 6. P OWER
[Figure]
It has recently been discovered that the SGD noise causes a heavytail distribution (Simsekli et al., 2019; 2020), with a tail decaying like a power law with tail index β (Hodgkinson and Mahoney, 2020).
In continuous-time, the stationary distribution has been found to obey a Student’s t-like distribution, p ( w ) ∼ L −( 1 + β )/ 2 ∼ ( σ 2 + aw 2 ) −( 1 + β )/ 2 (Meng et al., 2020; Mori et al., 2021; Wojtowytsch, 2021).
However, this result is only established for continuous-time approximations to SGD and one does not know what affects the exponent β for discrete-time SGD.
Our result in
Theorem 2 can serve as a tool to ﬁnd the discrete-time correction to the tail index of the stationary distribution.
In Appendix D.3, we show that the tail index of discrete-time SGD in 1d can be estimated as β ( λ,S )
= 2 Saλ − S .
A clear discrete-time contribution is −( S + 1 ) which depends only on the batch size, while 2 Saλ + 1 is the tail index in the continuous-time limit (Mori et al., 2021).
See Figure 2; the proposed formula agrees with the experiment.
Knowing the tail index β is important for understanding the SGD dynamics because β is equal to the smallest moment of w that diverges.
For example, when β ≤ 4 , then the kurtosis of w diverges, and one expects to see outliers of w very often during training; when β ≤ 2 , then the second moment of w diverges, and one does not expect w to converge in the minimum under consideration.
Our result suggests that the discrete-time dynamics always leads to a heavier tail than the continuous-time theory expects, and therefore is more unstable.
O UTLOOK
In this work, we have presented a systematic analysis with a focus on exactly solvable results to promote our fundamental understanding of SGD, and our results are shown to provide a novel and accurate understanding of how SGD works for problems relevant to deep learning.
One major limitation is that we have only focused on studying the asymptotic behavior of SGD, and one major future step is to investigate the dynamical, non-asymptotic noise and ﬂuctuations of SGD.
A E XPERIMENTS A. L ABEL NOISE AND REGULARIZATION
Theorem 2 can be veriﬁed empirically.
We run 1d experiment in Figure 4(a) and high dimensional experiments in Figures 4(b)-(c) where we choose D = 2 for visualization.
We see that the continuous
Hessian approximation fails badly for both large and small batch sizes.
When the batch size is large, both the discrete-time Hessian approximation and our solution give a accurate estimate of the shape and the spread of the distribution.
This suggests that when the batch size is large, discreteness is the determining factor of the ﬂuctuation.
When the batch size is small, the discrete Hessian approximation severely underestimates the strength of the noise.
This reﬂects the fact that the isotropic noise enhancement is dominant at a small batch size.
In Figure 3-Left, we run a 1d experiment with λ = 1 , N = 10000 and σ 2 = 0 .
Comparing the predicted Σ , we see that the proposed theory agrees with the experiment across all ranges of S .
The continuous theory with the Hessian approximation fails almost everywhere, while the recently proposed discrete theory with the Hessian approximation underestimates the ﬂuctuation when S is small.
In Figure 3-Right, we plot a standard case where the optimal regularization strength γ is vanishing.
Now, we validate the existence of the optimal negative weight decay as predicted by our formula.
For illustration, we plot in Figure 5 the test loss (11) for a 1d example while varying either S or λ .
The orange vertical lines show the place where the theory predicts a divergence in the test loss.
We also plot a standard case where the optimal γ is close to 0 in Appendix A.
Also, we note that the proposed theory agrees better with the experiment.
A. H IGH -D IMENSIONAL R EGRESSION
See Figure 6-Left.
We vary N with D = 1000 held ﬁxed.
We set λ = 0 .
01 and S = 32 .
We see that the agreement between the theory and experiment is good, even for this modest dimension number D .
The vertical line shows where the over-to-underparametrization transition takes place.
As expected, there is no ﬂuctuation when α < 1 , and the ﬂuctuation gradually increases as α → ∞ .
On the other hand, the Hessian approximation gives a wrong picture, predicting ﬂuctuation to rise when there is no ﬂuctuation and predicting a constant ﬂuctuation just when the ﬂuctuation starts to rise.
[Table]
Eq. Eq.
B C OMPARISON WITH C ONVENTIONAL H ESSIAN A PPROXIMATION
We compare our results for the three cases with the results obtained with the conventional Hessian approximation of the noise covariance, i.e., C ≈ H , where H is the Hessian of the loss function.
We summarize the analytical results for a special case in Table 2.
B. L ABEL N OISE
We ﬁrst consider discrete-time dynamics with the Hessian approximation.
The matrix equation is
[Equation]
Compared with the exact result (3), it is a large- S limit up to the constant σ 2 .
This constant factor is ignored during the approximation
that J ( w ) ∶=
E B [∇ l ∇ l T ] ≈ E B [∇∇ T l ] ∶= H ( w ) , which is exact only when l ({ x i } , w ) is a negative log likelihood function of w .
Solving the matrix equation yields
[Equation]
The training loss and the test loss are
[Equation]
[Equation]
On the other hand, by taking the large- S limit directly from the exact equation (3), the factor σ 2 is present:
[Equation]
For the continuous-time limit with the Hessian approximation, the matrix equation is
[Equation]
(23) which is the small- λ limit up to the factor σ 2 .
The variance is
[Equation]
The training and the test error are
[Equation]
Again, taking the small- λ limit directly from the exact result (3) shows the presence of the factor σon the right hand side of the matrix equation.
B. I NPUT N OISE
The case with the input noise is similar to the label noise.
This can be understood if we replace
A by K and σ 2 by Tr [ AK − 1 BU ] .
The model parameter variance resulting from the discrete-time dynamics under the Hessian approximation is
[Equation]
The training and the test error are
[Equation]
[Equation]
The large- S limit from the exact matrix equation (144) results in a prefactor
Tr
[ AK − 1 BU ] in the ﬂuctuation:
[Equation]
For the continuous-time limit, we take λ → 0 .
The Hessian approximation gives
[Equation]
[Equation] [Equation]
The large- S limit again produces a prefactor
Tr [ AK − 1 BU ] .
B. L 2 R EGULARIZATION
For learning with regularization, there is a more difference between the Hessian approximation and the limit taken directly from the exact theory.
We ﬁrst adopt the Hessian approximation for the discrete-time dynamics.
The matrix equation is
[Equation]
(34) which is similar to the previous subsection.
However, it is different from the large- S limit of the exact matrix equation (154):
[Equation] [Equation]
This signiﬁcant difference suggests that the conventional Fisher-to-Hessian approximation J ≈ H fails badly.
The ﬂuctuation, the training loss, and the test loss with the Hessian approximation are
[Equation]
[Equation] [Equation]
[Equation]
The continuous-time results are obtained by taking the small- λ limit on Eqs.
(36)-(38) for the Hessian approximation and on Eqs.
(39)-(41) for the limiting cases of the exact theory.
Speciﬁcally, for the
Hessian approximation, we have
[Equation]
The small- λ limit of the exact theory yields
[Equation]
C P ROOF OF THE G ENERAL F ORMULA C. P ROOF OF T HEOREM 5 AND C OROLLARY
We restate the theorem.
Theorem 7.
Let the training loss be L Γ =
L 0 + 12 w T Γ w and the models be optimized with SGD in the neighborhood of a local minimum w ∗ .
When Γ ≠ 0 , the noise covariance is given by
[Equation]
When Γ = 0 and L 0 ( w ∗ ) ≠ 0 ,
[Equation]
L
[Equation]
w
[Equation]
When Γ = 0 and L 0 ( w ∗ ) = 0 ,
[Equation]
Proof.
We will use the following shorthand notations:
[Equation]
The Hessian of the loss function without regularization H 0 ( [Equation]
[Equation] T L 0 ( w ) is given by
[Equation]
The last term of Eq.
(51) can be ignored when L 0 ≪ 1 , since
[Equation]
where ∥ ⋅ ∥ F stands for the Frobenius norm 3 , and we have deﬁned the variable ⟨ (cid:96) ′ 2 ⟩ ∶= 1 N ∑ Ni = 1 ( (cid:96) ′ i ) 2 .
Since (cid:96) ′′ i = 1 for the mean-square error, we obtain
[Equation]
near a minimum.
The Hessian with regularization H Γ ( w ) = ∇∇ T L Γ ( w ) is just given by H 0 ( w )+ Γ .
On the other hand, the SGD noise covariance C ( w ) is given by Eq.
By assumption 2, the SGD noise covariance is directly related to the Hessian: [Equation]
[Equation]
This ﬁnishes the proof.
◻
Now we prove Corollary 2.
Proof .
Near a minimum w ∗ of the full loss L Γ ( w ) , we have
[Equation]
within the approximation L Γ ( w ) =
L Γ ( w ∗ )
+( 1 / 2 )( w − w ∗ ) T H Γ ( w ∗ )( w − w ∗ ) T + O
(∣ w − w ∗ ∣ 2 ) .
Equations (14) and (54) give the SGD noise covariance near a minimum of L Γ ( w ) .
Now it is worth discussing two different cases separately: (1) with regularization and (2) without regularization.
We ﬁrst discuss the case when regularization is present.
In this case, the regularization Γ is not small enough, and the SGD noise covariance is not proportional to the Hessian.
Near a local or global minimum w ≈ w ∗ , the ﬁrst term of the right-hand side of Eq.
(54) is negligible, and hence we obtain
[Equation]
where we have used the fact that E [ w ] = w ∗ .
The SGD noise does not vanish even at a global minimum of L Γ ( w ) .
Note that this also agrees with the exact result derived in Sec. 4.3: together with an anisotropic noise that is proportional to the Hessian, a rank- 1 noise proportional to the strength of the regularization appears.
This rank-1 noise is a signature of regularization.
On the other hand, as we will see below, the SGD noise covariance is proportional to the Hessian near a minimum when there is no regularization, i
[Equation]
e., Γ = 0 .
We have
[Equation] [Equation]
For this case, we need to differentiate between a local minimum and a global minimum.
When
L 0 ( w ∗ ) is not small enough (e
[Equation]
g. at a local but not global minimum),
[Equation]
and so, to leading order,
[Equation]
which is proportional to the Hessian but also proportional to the achievable approximation error.
On the other hand, when L 0 ( w ∗ ) is vanishingly small (e
[Equation]
g. at a global minimum), we have 2 L 0 ( w ) ≈ ( w − w ∗ ) T H 0 ( w ∗ )( w − w ∗ ) , and thus obtain
[Equation] [Equation]
This completes the proof.
Remark.
It should be noted that the second term on the right-hand side of Eq.
(59) would typically be much smaller than the ﬁrst term for large D .
For example, when H 0 ( w ∗ )
=
aI D with a > 0 , the ﬁrst and the second terms are respectively given by ( a 2 / S )
∥ w − w ∗ ∥ 2 I D and −( a 2 / S )( w − w ∗ )( w − w ∗ ) T .
The Frobenius norm of the former is given by ( Da 2 / S )
∥ w − w ∗ ∥ 2 , while that of the latter is given by ( a 2 / S )
∥ w − w ∗ ∥ 2 , which indicates that in Eq.
(59), the ﬁrst term is dominant over the second term for large D .
Therefore the second term of Eq.
(59) can be dropped for large D , and Eq.
(59) is simpliﬁed as
[Equation]
Again, the SGD noise covariance is proportional to the Hessian.
In conclusion, as long as the regularization is small enough, that the SGD noise covariance near a minimum is proportional to the Hessian is a good approximation.
This implies that the noise is multiplicative, which is known to lead to a heavy tail distribution (Clauset et al., 2009; Levy and
Solomon, 1996).
Thus, we have studied the nature of the minibatch SGD noise in three different situations.
As an example, we have demonstrated the power of this general formulation by applying it to the high-dimensional linear regression problem in Sec. 6.1.
C. P ROOF OF C OROLLARY
Proof.
We prove the case where Γ = 0 and L ( w ∗ ) ≠ 0 as an example.
Substituting Theorem 5 into
Theorem 1yields
[Equation]
(62) where we have assumed necessary commutation relations.
Suppose that the Hessian H 0 is of rank- r with r ≤ D .
The singular-value decomposition and its Moore-Penrose pseudo inverse are given by
H
= USV T and H + 0 = V S + U T , respectively, where U and V are unitary
, S is a rank- r diagonal matrix with elements being singular values of H 0 , and S + is obtained by inverting every non-zero entry of S .
Multiplying H
+ 0 to both sides of the above equation, we have
[Equation]
where P r = diag ( 1 , 1 ,..., 1 , 0 ,..., 0 ) is the projection operator with r non-zero entries.
When the
Hessian is full-rank, i.e., r = D , the Moore-Penrose pseudo inverse is nothing but the usual inverse.
The other cases can be calculated similarly.
D A PPLICATIONS D. I NFINITE - DIMENSIONAL L IMIT OF THE L INEAR R EGRESSION P ROBLEM
Now we apply the general theory in Sec.
5 to linear regressions in the high-dimensional limit, namely
N,D → ∞ with α ∶= N / D held ﬁxed.
D.1. P ROOF OF P ROPOSITION
The loss function
[Equation]
64) with y i =
u T + (cid:15) i can be written as
[Equation]
where ˆ A ∶= 1 N ∑ N i =
1 x i x T i is an empirical covariance for the training data and v ∶= 1 N ∑ N i = 1 x i (cid:15) i .
The symbol (⋅) + denotes the Moore-Penrose pseudoinverse.
We also introduce the the averaged traing loss: L train ∶=
E w [ L ( w )]
The minimum of the loss function is given by
[Equation]
(66) where r ∈ R D is an arbitrary vector and Π is the projection onto the null space of ˆ A .
Since 1 − Π =
ˆ A + ˆ A , w ∗ is also expressed as
[Equation]
In an underparameterized regime α > 1 , Π = 0 almost surely holds as long as the minimum eigenvalue of A (not ˆ A ) is positive (Hastie et al., 2019).
In this case, ˆ A + =
ˆ A −
and we obtain
[Equation]
for α > 1 .
On the other hand, in an overparameterized regime α > 1 , Π ≠ 0 and there are inﬁnitely many global minima.
In the ridgeless regression, we consider the global minimum that has the minimum norm ∥ w ∗ ∥ , which corresponds to
[Equation]
for ridgeless regression with α <
[Equation]
In both cases, the loss function is expressed as
[Equation]
Asymptotically, w t converges to a stationary point w ∗ with ﬂuctuation Σ obeying the following equation (Theorem 1:
[Equation]
The SGD noise covariance C is given by Eq.
In the present case, the Hessian is given by H
= ˆ A
and we also have
[Equation]
On the other hand, ∇ L ( w )∇ L ( w ) T = ˆ A ( w − w ∗ )( w − w ∗ )
T ˆ A , and hence E w [∇ L ( w )∇ L ( w ) T ] =
ˆ A Σ ˆ A .
Therefore we obtain
[Equation]
Now, we ﬁnd L train .
First, we deﬁne X ∈ R N × D as X ik =
( x i ) k , and ⃗ (cid:15) ∈
R N as ⃗ (cid:15)
i = (cid:15) i .
Then w
[Equation]
With this notation, we have ˆ A =
X T X / N , and the loss function is expressed as
[Equation]
We therefore obtain
[Equation]
Here,
E [⃗ (cid:15) T X (
[Equation]
T
[Equation]
+ X T ⃗
[Equation]
= σ
[Equation]
Tr
[Equation] [Equation]
We can prove that the following identity is almost surely satisﬁed (Hastie et al., 2019) as long as the smallest eigenvalue of A (not ˆ A ) is positive:
[Equation]
We therefore obtain
[Equation]
By substituting Eq.
(78) into Eq.
(73), we obtain the following SGD noise covariance:
[Equation]
This ﬁnishes the proof.
◻
D.1. P ROOF OF T HEOREM
Proof.
We have to solve this equation:
[Equation]
where C is given in Proposition 4.
Using the similar trick of multiplying by ˆ G ∶= 2 I D − λ
1 − 1 S )
ˆ A as in Appendix E.2.2, one obtains
[Equation]
≤
[Equation]
81) where ˆ κ ∶=
Tr [ ˆ G − 1 ˆ A ] 1 − λS Tr
[ ˆ G − 1 ˆ A ] with ˆ G ∶= 2 I D − λ ( 1 − 1 S ) ˆ A .
Substituting the above trace into the matrix equation, we have
[Equation]
for
[Equation] [Equation]
D. S ECOND - ORDER M ETHODS
Proposition 5.
Suppose that we run DNM with Λ ∶= λA − 1 with random noise in the label.
The model ﬂuctuation is
[Equation]
(83) where g ∶= 2 ( 1 − µ ) − ( 1 − µ 1 + µ + 1 S ) λ .
Proof.
Substituting Λ = λA − 1 into Eqs.
(3) and (5) yields
[Equation]
where g ∶== 2 ( 1 − µ ) − ( 1 − µ 1 + µ + 1 S ) λ .
Multiplying A and taking trace on both sides, we have
[Equation]
Therefore, the model ﬂuctuation is
[Equation]
Proposition 6.
Suppose that we run NGD with Λ ∶= λS J ( w ) − 1 ≈ λS C − 1 with random noise in the label.
The model ﬂuctuation is
[Equation]
where g ∶= 1 1 + D 11 + µ + 11 − µ 1 S .
Proof.
Similarly to the previous case, the matrix equation satisﬁed by Σ is
[Equation]
Although it is not obvious how to directly solve this equation, it is possible to guess one solution according to the hope that Σ be proportional to J − 1 , in turn, A − 1 (Amari, 1998; Liu et al., 2021).
We assume that Σ = xA − 1 and substitute it into the above equation to solve for x .
This yields one solution without claiming its uniqueness.
By simple algebra, this x is solved to be
[Equation]
Let σ = 0 .
We obtain the result in Sec. 6.4.
D. E STIMATION OF T AIL I NDEX
In Mori et al.
; Meng et al.
(2020), it is shown that the (1d) discrete-time SGD results in a distribution that is similar to a Student’s t-distribution:
[Equation]
where σ 2 is the degree of noise in the label, and a is the local curvature of the minimum.
For large w , this distribution is a power-law distribution with tail index:
[Equation]
and it is not hard to check that β also equal to the smallest moment of w that diverges: E [ w β ] = ∞ .
Therefore, estimating β can be of great use both empirically and theoretically.
In continuous-time, it is found that β cts = 2 Saλ + 1 (Mori et al., 2021).
For discrete-time SGD, we hypothesize that the discrete-time nature causes a change in the tail index β
= β cts + (cid:15) , and we are interested in ﬁnding (cid:15) .
We propose a “semi-continuous" approximation to give the formula to estimate the tail index.
Notice that Theorem 2 gives the variance of the discrete-time SGD, while Eq.
(90) can be integrated to give another value of the variance, and the two expressions must be equal for consistency.
This gives us an equation that β must satisfy:
[Equation]
this procedure gives the following formula:
[Equation]
) and one immediately recognizes that −( S + 1 ) is the discrete-time contribution to the tail index.
See
Figure 7 for additional experiments.
We see that the proposed formula agrees with the experimentally measured value of the tail index for all ranges of the learning rate, while the result of Mori et al.
(2021) is only correct when λ → 0 + .
Hodgkinson and Mahoney (2020) also studies the tail exponent of discrete-time SGD; however, their conclusion is only that the “index decreases with the learning rate and increases with the batch size".
In contrast, our result give the functional form of the tail index directly.
In fact, this is the ﬁrst work that gives any functional form for the tail index of discrete-time
SGD ﬂuctuation to the best of our knowledge.
The following proposition gives the intermediate steps in the calculation.
Proposition 7.
( Tail index estimation for discrete-time SGD ) Let the parameter distribution be p ( w ) ∼ ( σ
+
aw 2 ) − 1 + β 2 , and Var [ w ] be given by Theorem 2.
Then
[Equation]
Proof.
The normalization factor for the distribution exists if β > 0 :
[Equation]
If β > 2 , the variance exists and the value is
[Equation]
By equating Eq.
(96) with the exact variance (6), we are able to solve for an expression of the tail index as
[Equation]
E P ROOFS AND A DDITIONAL T HEORETICAL C ONSIDERATIONS E. P ROOF OF P ROPOSITION
The with-replacement sampling is deﬁned in Deﬁnition 2.
Let us here deﬁne the without-replacement sampling.
Deﬁnition 3.
A minibatch SGD without replacement computes the update to the parameter w with the following set of equations:
[Equation]
where S ∶= ∣ B t ∣ ≤ N is the minibatch size, and the set B t is an element uniformly-randomly drawn from the set of all S -size subsets of { 1 ,...,N } .
From the deﬁnition of the update rule for sampling with or without replacement, the covariance matrix of the SGD noise can be exactly derived.
Proposition 8.
The covariance matrices of noise in SGD due to minibatch sampling as deﬁned in
Deﬁnitions 2 and 3 with an arbitrary N are
[Equation]
where the shorthand notation (cid:96) i ( w ) ∶= l ( x i ,y i , w ) is used.
In the limit of S = 1 or N ≫ S , two cases coincide.
In the N ≫ S limit, both methods of sampling have the same noise covariance as stated in Proposition 1:
[Equation]
Remark.
We also note that a different way of deﬁning minibatch noise exists in Hoffer et al.
The difference is that our deﬁnition requires the size of each minibatch to be exactly S , while Hoffer et al.
(2017) treats the batch size also as a random variable and is only expected to be S .
In comparison, our deﬁnition agrees better with the common practice.
Now we prove Proposition 8.
Proof.
We derive the noise covariance matrices for sampling with and without replacement.
We ﬁrst derive the case with replacement.
According to the deﬁnition, the stochastic gradient for sampling with replacement can be rewritten as
[Equation]
where g n ∶= ∇ (cid:96) n and s n = l, if l − multiple n ′ s are sampled in S , with 0 ≤ l ≤ S.
The probability of s n assuming value l is given by the multinomial distribution
[Equation]
Therefore, the expectation value of s n is given by
[Equation]
which gives
[Equation]
For the covariance, we ﬁrst calculate the covariance between s n and s n ′ .
Due to the properties of the covariance of multinomial distribution, we have for n ≠ n ′
[Equation]
106) and for n = n ′
[Equation]
Substituting these results into the deﬁnition of the noise covariance yields
[Equation]
Then, we derive the noise covariance for sampling without replacement.
Similarly, according to the deﬁnition, the stochastic gradient for sampling without replacement can be rewritten as
[Equation]
where
[Equation]
The probability of n that is sampled in S from N is given by
[Equation]
The expectation value of s n is then given by
[Equation]
which gives
[Equation]
For the covariance, we ﬁrst calculate the covariance between s n and s n ′ .
By deﬁnition, we have for n ≠ n ′
[Equation]
and for n = n ′
[Equation]
Substituting these results into the deﬁnition of the noise covariance yields
[Equation]
E. P ROOFS IN S EC . 4. E.2. P ROOF OF L EMMA
Proof.
From the deﬁnition of noise covariance (2)
[Equation]
the covariance matrix for the noise in the label is
[Equation]
where we have invoked the law of large numbers and the expectation value of the product of four
Gaussian random variables in the third line is evaluated as follows
[Equation]
Because N is large
[Equation]
we invoke the law of large numbers to obtain the ( j,k ) -th component of the matrix as
[Equation]
Because the average is taken with respect to x and each x is a Gaussian random variable
[Equation]
we apply the expression for the product of four Gaussian random variables E
[ x 1 x 2 x 3 x 4 ] =
E [ x 1 x
[Equation] [Equation]
Janssen and Stoica, 1988) to obtain
[Equation] [Equation]
Writing Σ ∶= E w [ ww T ] , we obtain
[Equation]
This method has been utilized repeatedly in this work.
E.2. P ROOF OF T HEOREM
Proof.
We substitute Eq.
(5) into Eq.
(3) which is a general solution obtained in a recent work (Liu et al., 2021):
[Equation]
To solve it
[Equation]
we assume the commutation relation that [ Λ
[Equation]
A ] ∶= Λ A − A Λ = 0 .
Therefore, the above equation can be alternatively rewritten as
[Equation]
To solve this equation
[Equation]
we ﬁrst need to solve for Tr [ A Σ ] .
Multiplying Eq.
(123) by G − 1 µ ∶= [
[Equation]
A ] − 1 and taking trace, we obtain
[Equation]
which solves to give
[Equation]
Therefore, Σ is
[Equation]
T RAINING E RROR AND T EST E RROR FOR L ABEL N OISE
In the following theorem
[Equation]
we calculate the expected training and test loss for random noise in the label.
Theorem 8.
( Approximation error and test loss for SGD noise in the label )
The expected approximation error, or the training loss, is deﬁned as L train ∶=
E w [ L ( w )] ; the expected test loss is deﬁned as L test ∶= 12 E w E B
[( w T x ) 2 ] .
For SGD with noise in the label given by Eq.
(5) , the expected approximation error and test loss are
[Equation]
Remark.
Notably, the training loss decomposes into two additive terms.
The term that is proportional to 1 is the bias, caused by insufﬁcient model expressivity to perfectly ﬁt all the data points, while the second term that is proportional to λκ / S is the variance in the model parameter, induced by the randomness of minibatch noise.
Remark.
When the learning rate λ is vanishingly small, the expected test loss diminishes whereas the training error remains ﬁnite as long as label noise exists.
Proof.
We ﬁrst calculate the approximation error.
By deﬁnition,
[Equation]
The test loss is
[Equation]
E. M INIBATCH N OISE FOR R ANDOM N OISE IN THE I NPUT E.3. N OISE S TRUCTURE
Similar to label noise, noise in the input data can also cause ﬂuctuation.
We assume that the training data points ˜ x
i = x
i + η i can be decomposed into a signal part and a random part.
As before, we assume
Gaussian distributions, x i ∼ N( 0 ,A ) and η i ∼ N( 0 ,B ) .
The problem remains analytically solvable if we replace the Gaussian assumption by the weaker assumption that the fourth-order moment exists and takes some matrix form.
For conciseness, we assume that there is no noise in the label, namely y i =
u T x i with a constant vector u .
One important quantity in this case will be uu T ∶= U .
Notice that the trick w − u = w no more works, and so we write the difference explicitly here.
The loss function then takes the form
[Equation]
[Equation]
The gradient ∇ L =
( A + B )( w − u ) + B u vanishes at w ∗ ∶=
( A + B ) − 1 A u , which is the minimum of the loss function and the expectation of the parameter at convergence.
It can be seen that, even at the minimum w ∗ , the loss function remains ﬁnite unless u = 0 , which reﬂects the fact that in the presence of input noise, the network is not expressive enough to memorize all the information of the data.
The SGD noise covariance for this type of noise is calculated in the following proposition.
Proposition 9.
( Covariance matrix for SGD noise in the input ) Let the algorithm be updated according to Eq.
(1) or (98) with random noise in the input while the limit N → ∞ is taken with D held ﬁxed.
Then the noise covariance is
[Equation]
where K ∶= A + B , and Σ ∶= E w [( w − w ∗ )( w − w ∗ ) T ] .
Remark.
It can be seen that the form of the covariance (132) of input noise is similar to that of label noise (5) with replacing A by K and σ 2 by Tr [ AK − 1 BU ] , suggesting that these two types of noise share a similar nature.
Deﬁning the test loss as L test ∶= 12 E w E B
[( w T x − u T x ) 2 ] , Proposition 9 can then be used to calculate the test loss and the model ﬂuctuation.
Theorem 9.
( Training error, test loss and model ﬂuctuation for noise in the input )
The expected training loss is deﬁned as L train ∶=
E w [ L ( w )] , and the expected test loss is deﬁned as L test ∶= 12 E w E B
[( w T x − u T x ) 2 ] .
For SGD with noise in the input given in Proposition (9) , the expected approximation error and test loss are
[Equation]
[Equation] [Equation]
where κ ′ ∶=
Tr [ KG ′− 1 ] 1 − λ 1 S
Tr
[ KG ′− 1 ] with G ′ ∶=
I D − λ ( 1 + 1 S ) K , and B ′ ∶=
K − 1 B .
Moreover, let [ K,U ] = 0 .
Then the covariance matrix of model parameters is
[Equation] [Equation]
Remark.
Note that
[ K,U ] = 0 is necessary only for an analytical expression of Σ .
It can be obtained by solving Eq.
(144) even without invoking [ K,U ] = 0 .
In general, the condition that [ K,U ] =does not hold.
Therefore, only the training and test error can be calculated exactly.
Remark.
The test loss is always smaller than or equal to the training loss because all matrices involved here are positive semideﬁnite.
E.3. P ROOF OF P ROPOSITION
Proof.
We deﬁne Σ ∶= E w [( w − w ∗ )( w − w ∗ ) T ] .
Then,
[Equation]
where we use the shorthand notations A ′ ∶=
( A + B ) − 1 A , B ′ ∶=
( A + B ) − 1 B and Σ A ∶= Σ + A ′ UA ′ T , Σ B ∶= Σ + B ′ UB ′ T .
We remark that the covariance matrix Σ here still satisﬁes the matrix equation (3) with the Hessian being
K ∶= A + B .
The noise covariance is
[Equation]
In Eq.
(138), there are four terms without trace and two terms with trace.
We ﬁrst calculate the traceless terms.
For the latter two terms, we have
[Equation] [Equation]
Because A ′ + B ′ =
I D , after simple algebra the four traceless terms result in 2 ( A + B ) Σ ( A + B ) .
The two traceful terms add to Tr [ A Σ B + B Σ A ] K .
With the relation AB ′ =
BA ′ , what inside the trace is
[Equation]
[Equation]
Therefore, the asymptotic noise is
[Equation]
E.3. P ROOF OF T HEOREM
Proof.
The matrix equation satisﬁed by Σ is
[Equation]
[Equation]
By using a similar technique as in Appendix E.2.2, the trace Tr [ K Σ ] can be calculated to give
[Equation] [Equation]
where κ ′ ∶=
Tr [ KG ′− 1 ] 1 − λ 1 S
Tr
[ KG ′− 1 ] with G ′ ∶=
I D − λ ( 1 + 1 S ) K .
With Eq.
(145), the training error and the test error can be calculated.
The approximation error is
[Equation]
The test loss takes the form of a bias-variance tradeoff:
[Equation]
Let [ K
[Equation]
U ] = 0 .
Then Σ can be explicitly solved because it is a function of K and U .
Speciﬁcally,
[Equation]
E. P ROOFS IN S EC . 4. E.4. P ROOF OF P ROPOSITION
Proof.
The covariance matrix of the noise is
[Equation]
Using a similar trick as in Appendix E.3.
[Equation]
the asymptotic noise is
[Equation]
E.4. P ROOF OF T HEOREM
Besides the test loss and the model ﬂuctuation
[Equation]
we derive the approximation error here as well.
Theorem.
( Training error, test loss and model ﬂuctuation for learning with L 2 regularization )
The expected training loss is deﬁned as L train ∶=
E w [ L ( w )] , and the expected test loss is deﬁned as
L test ∶= 12 E w E B [ ( w T x − u T x ) 2 ] .
For noise induced by L 2 regularization given in Proposition 3, let [ A, Γ ] = 0 .
Then the expected approximation error and test loss are
[Equation]
152) where κ ∶=
Tr [ A 2 K − 1 G − 1 ] 1 − λS
Tr
[ A 2 K − 1 G − 1 ] , r ∶=
Tr [ A 3 K − 3 Γ 2 G − 1 U ] 1 − λS
Tr
[ A 2 K − 1 G − 1 ] , with G ∶= 2 I D − λ ( K + 1 S K − 1 A 2 ) .
Moreover, if A , Γ and U commute with each other, the model ﬂuctuation is
[Equation]
Remark.
Because Γ may not be positive semideﬁnite, the test loss can be larger than the training loss, which is different from the input noise case.
Proof.
The matrix equation obeyed by Σ is
[Equation]
where we use the shorthand notation K ∶=
A + Γ
[Equation]
Let [ A
[Equation]
Γ ] = 0 .
Using the trick in Appendix E.2.
[Equation]
the trace term Tr [ A Σ ] is calculated as
[Equation]
where κ
[Equation]
and G ∶= 2 I D
[Equation]
( K
[Equation]
The training error is
[Equation]
The test loss is
[Equation]
Let A , Γ and U commute with each other.
Then,
[Equation]
E.4. P ROOF OF C OROLLARY
For a 1d example, the training loss and the test loss have a simple form.
We use lowercase letters for 1d cases.
Corollary 4.
For a 1d SGD with L 2 regularization, the training loss and the test loss are
[Equation]
Proof.
The training error and the test loss for 1d cases can be easily obtained from Theorem E.4.2.
Now we prove Corollary 1.
Proof.
The condition for convergence is 1 − λS
Tr [ A 2 K
[Equation]
1 G
[Equation] [Equation]
> 0 .
Speciﬁcally,
[Equation] [Equation]
For a given γ , the learning rate needs to satisfy
[Equation]
For a given λ , γ needs to satisfy
[Equation]
which indicates a constraint on λ :
[Equation]
If γ is allowed to be non-negative, the optimal value can only be 0 due to the convergence condition.
Therefore, a negative optimal γ requires an upper bound on it being negative, namely
[Equation]
Solving it, we have
[Equation]
By combining with Eq.
(164), a necessary condition for the existence of a negative optimal γ is
[Equation]
Hence, a negative optimal γ exists, if and only if
[Equation]
For higher dimension with Γ = γI D , it is possible to calculate the optimal γ for minimizing the test loss (11) as well.
Speciﬁcally, the condition is given by
[Equation]
where
[Equation]
Although it is impossible to solve the equation analytically, it can be solved numerically.