L EARNING C URVES FOR S TOCHASTIC G RADIENT D ESCENT ON S TRUCTURED F EATURES
Anonymous authors
Paper under double-blind review
A BSTRACT
The generalization performance of a machine learning algorithm such as a neural network depends in an intricate way on the structure of the data distribution.
To analyze the inﬂuence of data structure on test loss dynamics, we study an exactly solveable model of stochastic gradient descent (SGD) which predicts test loss when training on features with arbitrary covariance structure.
We solve the theory exactly for both Gaussian features and arbitrary features and we show that the simpler
Gaussian model accurately predicts test loss of nonlinear random-feature models and deep neural networks trained with SGD on real datasets such as MNIST and
CIFAR-10.
We show that the optimal batch size at a ﬁxed compute budget is typically small and depends on the feature correlation structure, demonstrating the computational beneﬁts of SGD with small batch sizes.
Lastly, we extend our theory to the more usual setting of stochastic gradient descent on a ﬁxed subsampled training set, showing that both training and test error can be accurately predicted in our framework on real data.
I NTRODUCTION
Understanding the dynamics of SGD on realistic learning problems is fundamental to learning theory.
Due to the challenge of modeling the structure of realistic data, theoretical studies of generalization often attempt to derive data-agnostic generalization bounds or study the typical performance of the algorithm on high-dimensional, factorized data distributions (Engel & Van den Broeck, 2001).
Realistic datasets, however, often lie on low dimensional structures embedded in high dimensional ambient spaces (Pope et al., 2021).
For example, MNIST and CIFAR-10 lie on surfaces with intrinsic dimension of ∼ 14 and ∼ 35 respectively (Spigler et al., 2020).
To understand the average-case performance of SGD in more realistic learning problems and its dependence on data, model and choice of hyperparameters, incorporating structural information about the learning problem is necessary.
In this paper, we calculate the average case performance of SGD on models of the form f ( x ) = w · ψ ( x ) for nonlinear feature map ψ trained with MSE loss.
We express test loss dynamics in terms of the induced second and fourth moments of ψ .
Under a regularity condition on the fourth moments, we show that the test error can be accurately predicted in terms of second moments alone.
We demonstrate the accuracy of our theory on random feature models and wide neural networks trained on MNIST and CIFAR-10 and accurately predict test loss scalings on these datasets.
We explore in detail the effect of minibatch size, m , on learning dynamics.
By varying m , we can interpolate our theory between single sample SGD ( m = 1 ) and gradient descent on the population loss ( m → ∞ ).
To explore the computational advantages SGD compared to standard full batch gradient descent we analyze the loss achieved at a ﬁxed compute budget C = tm for different minibatch size m and number of steps t , trading off the number of parameter update steps for denoising through averaging.
We show that generally, the optimal batch size is small, with the precise optimum dependent on the learning rate and structure of the features.
Overall, our theory shows how learning rate, minibatch size and data structure interact with the structure of the learning problem to determine generalization dynamics.
It provides a predictive account of training dynamics in wide neural networks.
1. O UR C ONTRIBUTIONS
The novel contributions of this work are described below.
• We calculate the exact expected test error for SGD on MSE loss for arbitrary feature structure in terms of second and fourth moments as we discuss in Section 4.2.
We identify how the structured gradient noise induced by sampling alters the loss curve compared to vanilla GD.
• For Gaussian features (or those with regular fourth moments), we compute the test error in Section 4.1.
This theory is shown to be accurate in experiments with random feature models and wide networks in the kernel regime trained on MNIST and CIFAR-10.
• We show that for ﬁxed compute/sample budgets and structured features with power law spectral decays, optimal batch sizes are small.
We study how optimal batch size depends on the structure of the feature correlations and learning rate.
• We extend our exact theory to study multi-pass SGD on a ﬁxed ﬁnite training set.
Both test and training error can be accurately predicted for random feature models on MNIST.
R ELATED W ORK
The analysis of stochastic gradient descent has a long history dating back to seminal works of Polyak & Juditsky (1992) and Ruppert (1988), who analyzed time-averaged iterates in a noisy problem.
Many more works have examined a similar setting, identifying how averaged and accelerated versions of SGD perform asymptotically when the target function is noisy (not a deterministic function of the input)
(Flammarion & Bach, 2015; 2017; Shapiro, 1989; Robbins & Monro, 1951; Chung, 1954;
Duchi & Ruan, 2021; Yu et al., 2020; Anastasiou et al., 2019; Gurbuzbalaban et al., 2021).
Recent studies have also analyzed the asymptotics of noise-free MSE problems with arbitrary feature structure to see what stochasticity arises from sampling.
Prior works have found exponential loss curves problems as an upper bound (Jain et al., 2018) or as typical case behavior for SGD on unstructured data (Werfel et al., 2004).
A series of more recent works have considered the overparameterized (possibly inﬁnite dimension) setting for SGD, deriving power law test loss curves emerge with exponents which are better than the O ( t − 1 ) rates which arise in the noisy problem (Berthier et al., 2020; Pillaud-Vivien et al., 2018; Dieuleveut et al., 2016;
Varre et al., 2021; Dieuleveut & Bach, 2016; Ying & Pontil, 2008; Fischer & Steinwart, 2020; Zou et al., 2021).
These works provide bounds of the form O ( t − β ) for exponents β which depend on the task and feature distribution.
Several works have analyzed average case online learning in shallow and two-layer neural networks.
Classical works often analyzed unstructured data (Heskes & Kappen, 1991; Biehl & Riegler, 1994;
Mace & Coolen, 1998; Saad & Solla, 1999; LeCun et al., 1991; Goldt et al., 2019), but recently the hidden manifold model enabled characterization of learning dynamics in continuous time when trained on structured data, providing an equivalence with a Gaussian covariates model (Goldt et al., 2020; 2021).
In the continuous time limit considered in these works, SGD converges to gradient ﬂow on the population loss, where ﬂuctuations due to sampling disappear and order parameters obey deterministic dynamics.
Other recent works, however, have provided dynamical mean ﬁeld frameworks which allow for ﬂuctuations due to random sampling of data during a continuous time limit of SGD, though only on simple generative data models (Mignacco et al., 2020; 2021).
Studies of fully trained linear (in trainable parameters) models also reveal striking dependence on data and feature structure.
Analysis for models trained on MSE (Bartlett et al., 2020; Tsigler &
Bartlett, 2020; Bordelon et al., 2020; Canatar et al., 2020), hinge loss (Chatterji & Long, 2021; Cao et al., 2021; Cao & Gu, 2019) and general convex loss functions (Loureiro et al., 2021) have now been performed, demonstrating the importance of data structure for ofﬂine generalization.
Other works have studied the computational advantages of SGD at different batch sizes m .
Ma et al.
(2018) study the tradeoff between taking many steps of SGD at small m and taking a small number of steps at large m .
After a critical m , they observe a saturation effect where increasing m provides diminishing returns.
Zhang et al.
(2019) explore how this critical batch size depends on SGD and momentum hyperparameters in a noisy quadratic model.
Since they stipulate constant gradient noise induced by sampling, their analysis results in steady state error rather than convergence at late times, which may not reﬂect the true noise structure induced by sampling.
P ROBLEM D EFINITION AND S ETUP
We study stochastic gradient descent on a linear model with parameters w and feature map ψ ( x ) ∈ R N (with N possibly inﬁnite).
Some interesting examples of linear models are random feature models, where ψ ( x ) =
φ ( G x ) for random matrix G and point-wise nonlinearity φ (Rahimi & Recht, 2008; Mei & Montanari, 2020).
Another interesting linearized setting is wide neural networks with neural tangent kernel (NTK) parameterization (Jacot et al., 2020; Lee et al., 2020).
Here the features are parameter gradients of the neural network function ψ ( x ) = ∇ θ f ( x , θ ) | θ 0 at initialization.
We will study both of these special cases in experiments.
We optimize the set of parameters w by SGD to minimize a population loss of the form
[Equation]
where x are input data vectors associated with a probability distribution p ( x ) , ψ ( x ) is a nonlinear feature map and y ( x ) is a target function which we can evaluate on training samples.
We assume that the target function is square integrable (cid:10) y ( x ) 2 (cid:11) x < ∞ over p ( x ) .
Our aim is to elucidate how this population loss evolves during stochastic gradient descent on w .
We derive a formula in terms of the eigendecomposition of the feature correlation matrix and the target function
[Equation]
where (cid:104) y ⊥ ( x ) ψ ( x ) (cid:105) = 0 .
We justify this decomposition of y ( x ) in the Appendix A using an eigendecomposition and show that it is general for target functions and features with ﬁnite variance.
During learning, parameters w are updated to estimate a target function y which, as discussed above, can generally be expressed as a linear combination of features y = w ∗ · ψ + y ⊥ .
At each time step t , the weights are updated by taking a stochastic gradient step on a fresh mini-batch of m examples
[Equation]
where each of the vectors ψ t,µ are sampled independently and y t,µ =
w ∗ · ψ t,µ .
The learning rate η controls the gradient descent step size while the batch size m gives a empirical estimate of the gradient at timestep t .
At each timestep, the test-loss, or generalization error, has the form
[Equation]
(4) which quantiﬁes exactly the test error of the vector w t .
Note, however, that L t is a random variable since w t depends on the precise history of sampled feature vectors D t
= { ψ t,µ } .
Our theory, which generalizes the recursive method of (Werfel et al., 2004) allows us to compute the expected test loss by averaging over all possible sequences to obtain (cid:104) L t (cid:105) D t .
Our calculated learning curves are not limited to the one-pass setting, but rather can accommodate sampling minibatches from a ﬁnite training set with replacement and testing on a separate test set which we address in Section 4.4.
In summary, we will develop a theory that predicts the expected test loss (cid:104)
L t (cid:105) D t averaged over training sample sequences D t in terms of the quantities { λ k , v k , (cid:10) y ⊥
( x ) 2 (cid:11) x } .
This will reveal how the structure in the data and the learning problem inﬂuence test error dynamics during SGD.
This theory is a quite general analysis of linear models on square loss, analyzing the performance of linearized models on arbitrary data distributions, feature maps ψ , and target functions y ( x ) .
A NALYTIC F ORMULAE FOR L EARNING C URVES 4. L EARNABLE AND N OISE F REE P ROBLEMS
Before studying the general case, we ﬁrst analyze the setting where the target function is learnable , meaning that there exist weights w ∗ such that y ( x ) = w ∗ · ψ ( x ) .
For many cases of interest, this is a reasonable assumption, especially when applying our theory to real datasets by ﬁtting an atomic measure on P points 1 P (cid:80) µ δ ( x − x µ ) .
We will further assume that the induced feature distribution is Gaussian so that all moments of ψ can be written in terms of the covariance Σ .
We will remove these assumptions in later sections.
Theorem 4.1.
Suppose the features ψ follow a Gaussian distribution ψ ∼ N (0 , Σ ) and the target function is learnable in these features y = w ∗ · ψ .
After t steps of SGD with minibatch size m and learning rate η , the expected (over possible sample sequences D t ) test loss (cid:104)
L t (cid:105) D t has the form (cid:104)
[Equation]
where λ is a vector containing the eigenvalues of Σ and v 2 is a vector containing elements ( v 2 )
k
= v 2 k = ( u k · w ∗ ) 2 for eigenvectors u k of Σ .
The function diag ( · ) constructs a diagonal matrix with the argument vector placed along the diagonal.
Proof.
See Appendix B for the full derivation.
We will provide a brief sketch of the proof here.
The strategy of the proof relies on the fact that (cid:104)
L t (cid:105) =
Tr Σ C t where C t = (cid:10) ( w t − w ∗ ) ( w t − w ∗ ) (cid:62) (cid:11) D t .
We derive the following recursion relation for this error matrix
[Equation]
The loss only depends on c k,t = u (cid:62)
k C t u k .
Solving the recurrence, c t =
A t v 2 and using (cid:104)
L t (cid:105) =
(cid:80) k
λ k u
[Equation]
k C t u k =
[Equation]
k
[Equation]
k
[Equation]
λ k = λ
[Equation]
A t v 2 , we obtain the desired result.
Below we provide some immediate interpretations of this result.
• The matrix A contains two components; a matrix ( I − η diag ( λ )) 2 which represents the timeevolution of the loss under average gradient updates .
The remaining matrix η
[Equation]
arises due to ﬂuctuations in the gradients, a consequence of the stochastic sampling process.
• The test loss obtained when training directly on the population loss can be obtained by taking the minibatch size m → ∞ .
In this case, A → ( I − η diag ( λ )) 2 and one obtains the population loss L popt =
(cid:80) k v 2 k λ k (1 − ηλ k ) 2 t .
This population loss can also be obtained by considering small learning rates, i.e. the η → 0 limit,
where A =
( I − η diag ( λ ))
2 + O ( η 2 ) .
• For general λ and η 2 /m > 0 , A is non-diagonal, indicating that the components { u 1 , ..., u k } are not learned independently as t increases like for L popt , but rather interact during learning due to non-trivial coupling across eigenmodes at large η 2 /m .
This is unlike ofﬂine theory for learning in feature spaces (kernel regression), (Bordelon et al., 2020; Canatar et al., 2020), this observation of mixing across covariance eigenspaces agrees with a recent analysis of SGD, which introduced recursively deﬁned “mixing terms” that couple each mode’s evolution (Varre et al., 2021).
• Though increasing m always improves generalization at ﬁxed time t (proof given in Appendix D), learning with a ﬁxed compute budget (number of gradient evaluations)
C
= tm , can favor smaller batch sizes.
We provide an example of this in the next sections and Figure 1 (d)-(f).
• The lower bound (cid:104) L t (cid:105) ≥ λ (cid:62) v 2 (cid:104) (1 − η ) 2 + η 2 m | λ | 2 (cid:105) t can be used to ﬁnd necessary stability conditions on m, η .
This bound implies that (cid:104)
L t (cid:105) will diverge if m < η 2 − η | λ | 2 .
The learning rate must be sufﬁciently small and the batch size sufﬁciently large to guarantee convergence.
This stability condition depends on the features through | λ | 2 = (cid:80) k
λ 2 k .
One can derive heuristic optimal batch sizes and optimal learning rates through this lower bound.
See Figure 2 and Appendix C.
4.1. S PECIAL C ASE 1: U NSTRUCTURED I SOTROPIC F EATURES
This special case was previously analyzed by Werfel et al.
(2004) which takes Σ
= I ∈ R N × N and m = 1 .
We extend their result for arbitrary m , giving the following learning curve
[Equation]
where the second expression has optimal η .
First, we note the strong dependence on the ambient dimension N : as N (cid:29) m , learning happens at a rate (cid:104)
L t (cid:105) ∼ e − tm/N .
Increasing the minibatch size m improves the exponential rate by reducing the gradient noise variance.
Second, we note that this feature model has the same rate of convergence for every learnable target function y .
At small m ,
[Figure]
at large t , which is both quantitatively and qualitatively different predicted isotropic features the convergence at any learning rate η is much slower than the convergence of the m → ∞ limit,
L pop = (1 − η ) 2 t || w ∗ || 2 which does not suffer from a dimensionality dependence due to gradient noise.
Lastly, for a ﬁxed compute budget C = tm , the optimal batch size is m ∗ = 1 ; see Figure 1 (d).
This can be shown by differentiating (cid:10) L C/m (cid:11) with respect to m (see Appendix E).
In Figure 1 (a) we show theoretical and simulated learning curves for this model for varying values of N at the optimal learning rate and in Figure 1 (d), we show the loss as a function of minibatch size for a ﬁxed compute budget C = tm = 100 .
While ﬁxed C represents ﬁxed sample complexity, we stress that it may not represent wall-clock run time when data parallelism is available (Shallue et al., 2018).
4.1. S PECIAL C ASE 2: P OWER L AWS AND E FFECTIVE D IMENSIONALITY
Realistic datasets such as natural images or audio tend to exhibit nontrivial correlation structure, which often results in power-law spectra when the data is projected into a feature space, such as a randomly intialized neural network (Spigler et al., 2020; Canatar et al., 2020; Bahri et al., 2021).
In the η 2 m (cid:28) 1 limit, if the feature spectra and task specra follow power laws, λ k ∼ k − b and λ k v 2 k ∼ k − a with a, b > 1 , then Theorem 4.1 implies that generalization error also falls with a power law: (cid:104)
L t (cid:105) ∼ Ct − β , β = a − 1 b where C is a constant.
See Appendix G for a derivation with saddle point integration.
Notably, these predicted exponents we recovered as a special case of our theory agree with prior work on SGD with power law spectra, which give exponents in terms of the feature correlation structure (Berthier et al., 2020; Dieuleveut et al., 2016; Velikanov & Yarotsky, 2021; Varre et al., 2021).
Further, our power law scaling appears to accurately match the qualitative behavior of wide neural networks trained on realistic data (Hestness et al., 2017; Bahri et al., 2021), which we study in Section 5.
[Figure]
We show an example of such a power law scaling with synthetic features in Figure 1 (b).
Since the total variance approaches a ﬁnite value as N → ∞ , the learning curves are relatively insensitive to
N , and are rather sensitive to the eigenspectrum through terms like | λ | 2 and 1 (cid:62) λ , etc.
In Figure 1 (c), we see that the scaling of the loss is more similar to the power law setting than the isotropic features setting in a random features model of MNIST, agreeing excellently with our theory.
For this model, we ﬁnd that there can exist optimal batch sizes when the compute budget C = tm is ﬁxed (Figure 1 (e) and (f)).
In Appendix C.1, we heuristically argue that the optimal batch size for power law features should scale as, m ∗ ≈ 1 (2 b − 1) .
Figure 2 tests this result.
We provide further evidence of the existence of power law structure on realistic data in Figure(a)-(c), where we provide spectra and test loss learning curves for MNIST and CIFAR-10 on ReLU random features.
The eigenvalues λ k ∼ k − b and the task power tail sums (cid:80) ∞ n =
k λ n v 2 n ∼ k − a + both follow power laws, generating power law test loss curves.
These learning curves are contrasted with isotropically distributed data in R 784 passed through the same ReLU random feature model and we see that structured data distributions allow much faster learning than the unstructured data.
Our theory is predictive across variations in learning rate, batch size and noise (Figure 3).
4. A RBITRARY I NDUCED F EATURE D ISTRIBUTIONS : T HE G ENERAL S OLUTION
The result in the previous section was proven exactly in the case of Gaussian vectors (see Appendix
B).
For arbitrary (possibly non-Gaussian) distributions, we obtain a slightly more involved result (see
Appendix F).
Theorem 4.2.
Let ψ ( x ) ∈ R N be an arbitrary feature map with covariance matrix Σ
= (cid:80) k
λ k u k u (cid:62) k .
After diagonalizing the features φ k ( x ) = u (cid:62) k ψ ( x ) , introduce the fourth moment tensor κ 4 ijkl = (cid:104) φ i φ j φ k φ l (cid:105) .
The expected loss is exactly (cid:104)
L t (cid:105) =
(cid:80) k
λ k c k ( λ , κ , v , t ) .
We provide an exact formula for c k in the Appendix F We see that the test loss dynamics depends only on the second and fourth moments of the features through quantities
λ k and κ ijk(cid:96) respectively.
We recover the Gaussian result as a special case when κ ijkl is a simple weighted sum of these three products of Kronecker tensors κ Gaussijkl =
[Equation]
δ kl + λ i λ j δ il δ jk .
As an alternative to the above closed form expression for (cid:104)
L t (cid:105) , a recursive formula which tracks N mixing coefﬁcients has also been used to analyze the test loss dynamics for arbitrary distributions (Varre et al., 2021).
[Figure]
asymptotic error L ∞ which persists even as t → ∞ .
Next we show that a regularity condition, similar to those assumed in other recent works (Jain et al., 2018; Berthier et al., 2020; Varre et al., 2021), on the fourth moment structure of the features allows derivation of an upper bound which is qualitatively similar to the Gaussian theory.
Theorem 4.3.
If the fourth moments satisfy (cid:10) ψψ [Equation] Gψψ [Equation]
(cid:11) (cid:22) ( α + 1) Σ G Σ + α Σ
Tr Σ G for any positive-semideﬁnite G , then
[Equation]
We provide this proof in Appendix F.1.
We note that the assumed bound on the fourth moments is tight for Gaussian features with α = 1 , recovering our previous theory.
Thus, if this condition on the fourth moments is satisﬁed, then the loss for the non-Gaussian features is upper bounded by the
Gaussian test loss theory with the batch size effectively altered ˜ m
= m/α .
The question remains whether the Gaussian approximation will provide an accurate model on realistic data .
We do not provide a proof of this conjecture, but verify its accuracy in empirical experiments on MNIST and CIFAR-10 as shown in Figure 3.
In Appendix Figure F.1, we show that the fourth moment matrix for a ReLU random feature model and its projection along the eigenbasis of the feature covariance is accurately approximated by the equivalent Gaussian model.
4. U NLEARNABLE OR N OISE C ORRUPTED P ROBLEMS
In general, the target function y ( x ) may depend on features which cannot be expressed as linear combinations of features ψ ( x ) , y ( x )
=
w ∗ · ψ ( x )+ y ⊥ ( x ) .
Let (cid:10) y ⊥ ( x ) 2 (cid:11) x = σ 2 . Note that y ⊥ does not have to be a deterministic function of x , but can also be a stochastic process which is uncorrelated with ψ ( x ) .
[Figure]
Theorem 4.4.
For a target function with unlearnable variance (cid:10) y 2 ⊥ (cid:11) =
σ 2 trained on Gaussian ψ , the expected test loss has the form
[Equation]
which has an asymptotic, irreducible error (cid:104) L ∞ (cid:105)
= 1 m η 2 σ 2 λ (cid:62) ( I − A ) − 1 λ as t → ∞ .
See Appendix H for the proof.
The convergence to the asymptotic error takes the form (cid:104)
L t − L ∞ (cid:105) =
λ (cid:62) A t (cid:0) v 2 − 1 m η 2 σ
I − A ) − 1 λ (cid:1) .
We note that this quantity is not necessarily monotonic in t and can exhibit local maxima for sufﬁciently large σ 2 , as in Figure 3 (f).
4. T EST /T RAIN S PLITS
Rather than interpreting our theory as a description of the average test loss during SGD in a one-pass setting, where data points are sampled from the a distribution at each step of SGD, our theory can be suitably modiﬁed to accommodate multiple random passes over a ﬁnite training set.
To accomplish this, one must ﬁrst recognize that the training and test distributions are different.
Theorem 4.5.
Let ˆ p ( x ) = 1 M (cid:80) µ δ ( x − x µ ) be the empirical distribution on the M training data points and let ˆΣ =
(cid:10) ψ ( x ) ψ ( x ) (cid:62) (cid:11) x ∼ ˆ p ( x ) =
(cid:80) k
ˆ λ k u k u (cid:62) k be the feature correlation matrix on this training set.
Let p ( x ) be the test distribution Σ its corresponding feature correlation.
Then we have
[Equation]
We provide the proof of this theorem in Appendix I.
The interpretation of this result is that it provides the expected training and test loss if, at each step of SGD, m points from the training set { x 1 , ..., x M } are sampled uniformly with replacement and used to calculate a stochastic gradient.
Note that while Σ can be full rank, the rank of ˆΣ has rank upper bounded by M , the number of training samples.
The recurrence for C t can again be more easily solved under a Gaussian approximation which we employ in Figure 4.
Since learning will only occur along the M dimensional subspace spanned by the data, the test error will have an irreducible component at large time, as evidenced in Figure 4.
While the training errors continue to go to zero, the test errors saturate at a M -dependent ﬁnal loss.
This result can also allow one to predict errors on other test distributions.
C OMPARING N EURAL N ETWORK F EATURE M APS
We can utilize our theory to compare how wide neural networks of different depths generalize when trained with SGD on a real dataset.
With a certain parameterization, large width NNs are approximately linear in their parameters (Lee et al., 2020).
To predict test loss dynamics with our theory, it therefore sufﬁces to characterize the geometry of the gradient features ψ ( x ) = ∇ θ f ( x , θ ) .
[Figure] In Figure 5, we show the Neural Tangent Kernel (NTK) eigenspectra and task-power spectra for fully connected neural networks of varying depth, calculated with the Neural Tangents API (Novak et al., 2020).
We compute the kernel on a subset of 10 , 000 randomly sampled MNIST images and estimate the power law exponents for the kernel and task spectra λ k and v 2 k .
Across architectures, the task spectra v 2 k are highly similar, but that the kernel eigenvalues λ k decay more slowly for deeper models, corresponding to a smaller exponent b .
As a consequence, deeper neural network models train more quickly during stochastic gradient descent as we show in Figure 5 (c).
After ﬁtting power laws to the spectra λ k ∼ k − b and the task power v 2 k ∼ k − a , we compared the true test loss dynamics (color) for a width-500 neural network model with the predicted power-law scalings β
= a − 1 b from the ﬁt exponents a, b .
The predicted scalings from NTK regression accurately describe trained widthnetworks.
On CIFAR-10, we compare the scalings of the CNN model and a standard MLP and ﬁnd that the CNN obtains a better exponent due to its faster decaying tail sum (cid:80) ∞ n = k λ n v 2 n .
We stress that the exponents β were estimated from our one-pass theory, but were utilized experiments on a ﬁnite training set.
This approximate and convenient version of our theory is quite accurate across these varying models, in line with recent conjectures about early training dynamics (Nakkiran et al., 2021).
C ONCLUSION
Studying a simple model of SGD, we were able to uncover how the feature geometry governs the dynamics of the test loss.
We derived average learning curves (cid:104)
L t (cid:105) for both Gaussian and general features and showed conditions under which the Gaussian approximation is accurate.
The proposed model allowed us to explore the role of the data distribution and neural network architecture on the learning curves, and choice of hyperparameters on realistic learning problems.
While our theory accurately describes networks in the lazy training regime, average case learning curves in the feature learning regime would be interesting future extension.
Further extensions of this work could be used to calculate the expected loss throughout curriculum learning where the data distribution evolves over time as well as alternative optimization strategies such as SGD with momentum.
A D ECOMPOSITION OF THE F EATURES AND T ARGET F UNCTION
Let y ( x ) be a square integrable target function with (cid:10) y ( x ) 2 (cid:11) < ∞ .
Deﬁne the following integral operator T K for kernel K ( x , x (cid:48) )
=
ψ ( x ) · ψ ( x (cid:48) ) :
[Equation]
We are interested in eigenfunctions of this operator, function φ k for which T K [ φ k ]
= λ k φ k .
For kernels with ﬁnite trace (cid:82) K ( x , x ) p ( x ) d x < ∞ , Mercer’s theorem (Rasmussen & Williams, 2005) guarantees the existence of a set of orthonormal eigenfunctions.
Since ψ ( x ) spans an N dimensional function space, only N of the kernel eigenfunctions will have non-zero eigenvalue.
Since the basis of kernel eigenfunctions (including the zero eigenvalue functions) is complete over the space of square integrable functions.
After ordering the eigenvalues λ 1 > λ 2 > ... > λ N with λ N + (cid:96) = 0 , we obtain the expansion
[Equation]
Further, we can decompose the feature map in this basis ψ ( x ) = (cid:80)
Nk =
√ λ k u k φ k ( x ) .
We recognize through these decompositions the coefﬁcients v k can be computed uniquely as v k = λ − 1 / 2 k u (cid:62) k (cid:104) ψ ( x ) y ( x ) (cid:105) .
This provides a recipe for determining the necessary spectral quantities for our theory.
We see that the feature map’s decomposition above reveals that λ k are also the eigenvalues of the feature correlation matrix Σ since
[Equation]
A. F INITE S AMPLE S PACES
When we discuss experiments on MNIST or CIFAR, we use this technology for an atomic data distribution p ( x ) = 1 M (cid:80) Mµ
=1 δ ( x − x (cid:48) ) .
Plugging this into the integral operator gives
[Equation]
We see that, restricting the domain to the set of points { x 1 , ..., x M } , this amounnts to solving a matrix eigenvalue problem 1 M Kφ k = λ k φ k where K ∈ R M × M is the kernel gram matrix with entries
K µν = K
( x µ , x ν ) and φ k has entries φ k,µ =
φ k ( x µ ) .
B P ROOF OF T HEOREM 4.
Let ∆ t = w t − w ∗ represent the difference between the current and optimal weights and deﬁne the correlation matrix for this difference
[Equation]
Using stochastic gradient descent, w t
+1 =
w t − η g t with gradient vector g t = 1 m (cid:80) mi
[Equation]
1 ψ
[Equation]
ψ (cid:62) i ∆ t , the C t matrix satisﬁes the recursion
[Equation]
First, note that since ψ i are all independently sampled at timestep t , we can break up the average into the fresh batch of m samples and an average over D t −
[Equation]
[Table]
[Equation]
First, consider the case where i = j .
Letting ψ
= ψ
i , we need to compute terms of the form
[Equation]
For Gaussian random vectors, we resort to Wick-Isserlis theorem for the fourth moment
[Equation] [Equation]
giving
[Equation]
This correlation structure for g t implies that its covariance has the form
[Equation]
Using the formula for (cid:10) g t g (cid:62) t (cid:11) , we arrive at the following recursion relation for C t
[Equation]
[Equation]
Since we are ultimately interested in the generalization error (cid:104)
L t (cid:105) =
(cid:10) ∆ (cid:62)
[Equation]
=
Tr ΣC
[Equation]
= (cid:80) k
λ k u (cid:62) k
C t u k , it sufﬁces to track the evolution of c t,k = u (cid:62) k C t u k
[Equation]
Vectorizing this equation for c generates the following solution
[Equation]
The coefﬁcient c 0 ,k = v 2 k = (cid:0) u (cid:62) k w ∗ (cid:1) 2 .
To get the generalization error, we merely compute (cid:104)
L t (cid:105) =
λ (cid:62) a t = λ (cid:62)
A t v 2 as desired.
C P ROOF OF S TABILITY C ONDITIONS
We will ﬁrst establish the following lower bound on the loss, where without loss of generality we assumed the maximum correlation is 1 :
[Equation]
We will then use this lower bound to provide necessary conditions on the learning rate and batch size for stability of the loss evolution.
First, note that the following inequality holds elementwise
[Equation] [Equation]
Repeating this inequality t times gives A t λ ≥ (cid:104) (1 − η ) 2 + η 2 m | λ | 2 (cid:105) t λ .
Using the fact that L t = λ (cid:62) A t v 2 gives the desired inequality.
Note that this inequality is very close to the true result for isotropic features λ = 1 which gives L t ∝ (cid:104) (1 − η ) 2 + η 2 m ( | λ | 2 + 1) (cid:105) t .
For anisotropic features with small learning rate, this bound becomes less tight.
For the loss to converge to zero at large time, the quantity in brackets must necessarily be less than one.
This implies the following necessary condition on the batchsize and learning rate
[Equation]
) where m min is the minimal batch size for learning rate η and feature covariance eigenvalues λ .
C. H EURISTIC B ATCH S IZE AND L EARNING R ATE
We can derive heuristic optimal choices of the learning rate and batch size hyperparameters η, m at a ﬁxed compute budget which optimize the lower bound derived above.
C.1. F IXED L EARNING R ATE
We will ﬁrst consider optimizing only the batch size at a ﬁxed learning rate η before discussing the optimal m when η is chosen optimally.
The loss at a ﬁxed compute budget C = tm is lower bounded by
[Equation]
For the purposes of optimization, we introduce x = 1 /m and consider optimizing
[Equation]
The ﬁrst order optimality condition f (cid:48) ( x ) = 0 implies that ( A + x ) ln( A + x ) = − x .
This equation has solutions for A ∈ (0 , 1) giving solutions x ∈ (0 , e − 1 ) .
Thus the predicted heuristic optimal batch size is always greater than Euler’s constant m ∗ = 1 x ∗ > e .
As A increases the optimal batch-size m ∗ increases monotonically.
We can get an intuition for this optimality criterion by noticing that x
≈ A gives a decent approximation to the solution.
Thus we expect optimal batch size to scale roughly as
[Equation]
which is roughly 2 /η the size of the stability bound m min when η is small.
C.1. H EURISTIC O PTIMAL L EARNING R ATE AND B ATCH S IZE
We will now examine what happens when one ﬁrst optimizes loss bounmd with respect to the the learning rate at any value of m and then subsequently optimizes over the batch size m .
We can easily ﬁnd the η which minimizes the lower bound.
[Equation]
Note that this heuristic optimal learning rate is very close to the true optimum in the isotropic data setting η true =
[Equation]
Plugging this back into the loss bound, we ﬁnd that at ﬁxed compute C = tm , the loss scales like
[Equation]
With the optimal choice of learning rate, the loss at ﬁxed compute monotonically increases with batch size, giving an optimal batchsize of m = 1 .
This shows that if the learning rate is chosen optimally then small batch sizes give the best performance per unit of computation.
This corresponds to the hyperparameter choices ( η, m ) =
(cid:16)
[Equation]
D I NCREASING m R EDUCES THE L OSS AT FIXED t
We will show that for a ﬁxed number of steps t , increasing the minibatch size m can only decrease the expected error.
To do this, we will simply show that the derivative of the expected loss with respect to m ,
[Equation]
is always non-positive.
The derivative of the t -th power of A can be identiﬁed with the chain rule
[Equation]
Note that the matrix
[Equation]
37) has all non-positive entries.
Thus we ﬁnd that
[Equation]
Note that since all entries in v 2 k and A t − n − 1 are non-negative, the vector z n =
A t − n − 1 v 2 has non-negative entries.
By the same argument, the vector q n =
A n λ is also non-negative in each entry.
Therefore
[Equation]
each of the terms in ∂ (cid:104)
L t (cid:105) ∂m above must be non-positive
[Equation]
Thus we ﬁnd ∂ (cid:104)
L t (cid:105) ∂m ≤ 0 , implying that optimal (cid:104)
L t (cid:105) is always obtained (possibly non-uniquely) at m → ∞ .
E I NCREASING m I NCREASES THE L OSS AT F IXED C = tm ON I SOTROPIC F EATURES
Unlike the previous section, which considered ﬁxed t and varying m , in this section we consider ﬁxing the total number of samples (or gradient evaluations) which we call the compute budget C = tm .
For a ﬁxed compute budget C = tm , and unstructured N dimensional Gaussian features and optimal learning rate η ∗ = m m
+ N +1 , we have
[Equation]
Taking a derivative with respect to the batch size we get
[Equation]
This exercise demonstrates that, for the isotropic features, smaller batch-sizes are preferred at a ﬁxed compute budget C .
This result does not hold for arbitrary spectra λ k .
In the general case, optimal minibatch sizes can exist as we show in Figure 1 (e)-(f) for power law and MNIST spectra.
F P ROOF OF T HEOREM 4.
Let Vec ( · ) denote a ﬂattening of an N × N matrix into a vector of length N 2 and let Mat ( · ) represent a ﬂattening of a 4D tensor into a N 2 × N 2 two-dimensional matrix.
We will show that the expected loss (over D t ) is
[Equation]
where [ G ] ij,kl = δ
ik
[Equation]
λ
i
[Equation]
and [ v ] k = u k · w
[Equation]
We rotate all of the feature vectors into the eigenbasis of the covariance, generating diagonalized features φ k = u (cid:62) k ψ and introduce the following fourth moment tensor
[Equation]
We redeﬁne C t in the appropriate (rotated) basis by projecting onto the eigenvectors of the covariance
[Equation] [Equation]
where U =
[ u 1 , u 2 , ..., u N ] .
With this deﬁnition, C ’s dynamics take the form
[Equation]
The elements of the matrix can be expressed with the fourth moment tensor
[Equation]
We thus generate the following dynamics for C tij
[Equation]
Let c t =
Vec ( C t ) , then we have c t +
[Equation]
Solving these dynamics for c , recognizing that c
=
Vec ( vv (cid:62) ) , and computing (cid:104)
L t (cid:105) =
Tr ΣC t = (cid:80) k C kk λ k gives the desired result.
F. P ROOF OF T HEOREM 4.
Suppose that the features satisfy the regularity condition
[Equation]
Recalling the recursion relation for C t
[Equation]
[Equation]
Deﬁning that c k,t = u (cid:62) k C t u k , we note c t +1 ≤ (cid:16) ( I − η diag ( λ ))
2 + η 2 αm (cid:2) diag ( λ 2 ) + λλ (cid:62) (cid:3)(cid:17) c t .
Using the fact that L t = c (cid:62) t λ , we ﬁnd
[Equation]
which proves the desired bound.
G P OWER L AW S CALINGS IN S MALL L EARNING R ATE L IMIT
By either taking a small learning rate η or a large batch size, the test loss dynamics reduce to the test loss obtained from gradient descent on the population loss.
In this section, we consider the small learning rate limit η → 0 , where the average test loss follows
[Equation]
[Equation]
Gauss 0.0 0.
0.8 1.0 | 4 Gauss | 0.
(a) Non-Gaussian Effects on MNIST
Gauss 0.0 0.
0.8 1.0 | 4 Gauss | 0.
[Figure]
Non
[Figure]
Under the assumption that the eigenvalue and target function power spectra both follow power laws λ k ∼ k − b and v 2 k λ k ∼ k − a , the loss can be approximated by an integral over all modes k
[Equation]
We identify the function f ( k ) = 2 ηk − b + 1 t ln k and proceed with Laplace’s method (Bender &
Orszag, 1999).
This consists of Taylor expanding f ( k ) around its minimum to second order and computing a Gaussian integral
[Equation]
We must identify the k ∗ which minimizes f ( k ) .
The interpretation of this value is that it indexes the mode which dominates the error at a large time t .
The ﬁrst order condition gives
[Equation]
The second derivative has the form
[Equation]
Thus we are left with a scaling of the form
[Equation]
H P ROOF OF T HEOREM 4.
Let (cid:10) y 2 ⊥ (cid:11) =
σ 2 and (cid:104)
y ⊥ (cid:105) =
0 , (cid:104)
y ⊥ ψ (cid:105) =
The gradient descent updates take the following form ∆ t +1 =
∆ t − η g t with g t = 1 m m (cid:88) i =
ψ i (cid:2) ψ (cid:62) i ∆ t + y ⊥ ,i (cid:3) .
Again, deﬁning C t = (cid:10) ∆ t ∆ (cid:62) t (cid:11) we perform the average over each of the ψ i vectors to obtain the following recursion relation
[Equation]
Again, analyzing c t,k = u (cid:62) k C t u k we ﬁnd
[Equation]
The vector c t follows the linear evolution
[Equation]
Let b =
η 2 σ 2 λ .
Writing out the ﬁrst few steps
[Equation]
we identify a pattern
[Equation]
The geometric sum (cid:16)(cid:80) t − 1 n =
A n (cid:17) can be computed exactly under the assumption that ( I − A ) is invertible which holds provided all of A ’s eigenvalues are less than unity, which necessarily holds provided the system is stable.
The geometric sum yields
[Equation]
Recalling the deﬁnition of b = σ 2 η 2 λ and the deﬁnition of the average loss (cid:104)
L t (cid:105) =
λ (cid:62) c t
[Equation]
we have
[Equation]
Recognizing c
= v 2 gives the desired result.
I P ROOF OF THEOREM 4.
We will now prove that if the training ˆ p ( x ) and test distributions p ( x ) are different and have feature correlation matrices ˆΣ and Σ respectively, then the average training and test losses have the form
[Equation]
As before
[Equation]
we will assume that there exist weights w ∗ which satisfy y =
w ∗ · ψ .
We start by noticing that the update rule for gradient descent
[Equation]
generates the following dynamics for the weight discrepancy correlation C t
[Equation]
This formula can be obtained through the simple averaging procedure shown in B. Under the Gaussian approximation, we can obtain a simpliﬁcation
[Equation]
[Equation]
We can solve for the evolution of the diagonal and off-diagonal entries in this matrix giving
[Equation]
[Equation]
To calculate the training and test error, we have
[Equation]
Note that in the training error formula, since ˆΣ has eigenvectors u k only the diagonal terms u (cid:62)
k C t u k enter into the formula for L train , but off-diagonal components u (cid:62)
k C t u (cid:96) do enter into the formula for
L test
J E XPERIMENTAL D ETAILS
For Figures 3, we use the last two classes of MNIST and CIFAR-10.
We encode the target values as binary y ∈ { +1 , − 1 } .
For Figure 5, we use 6000 random training points drawn from entire MNIST and CIFAR-10 datasets to calculate the spectrum of the Fisher information matrix.
We train with SGD on these training data, using one-hot label vectors for each training example and plot the error on the test set.
We train our models on a Google Colab GPU and include code to reproduce all experimental results in the supplementary materials.
To match our theory, we use ﬁxed learning rate SGD.
Both evaluation of the inﬁnite width kernels and training were performed with the Neural Tangents API (Novak et al., 2020).