Contrasting random and learned features in deep Bayesian linear regression

Jacob A. Zavatone-Veth, William L. Tong, Cengiz Pehlevan

I Introduction

Deep neural networks (NNs) display a rich and often-perplexing spectrum of generalization behaviors. Highly overparameterized NNs may possess the expressivity to fit random noise, yet in practice can still generalize well to unseen data . The ability of NNs to flexibly learn features from data is widely believed to be a critical contributor to their practical success , but the precise contributions of feature learning to their generalization behavior remain incompletely understood .

In recent years, intensive theoretical work has begun to elucidate the properties of deep networks in the limit of infinite hidden layer width. In this limit, a dramatic simplification occurs, and inference in deep networks is equivalent to kernel regression or classification . This correspondence has enabled detailed characterizations of inference at infinite width in both maximum-likelihood and fully Bayesian settings, providing new insights into the inductive biases that allow deep networks to overfit benignly . Yet, understanding inference in the kernel limit is not sufficient, because kernel descriptions cannot capture feature learning .

As a result, a growing number of recent works have aimed to study the behavior of networks near the kernel limit, with the hope that leading-order corrections to the large-width behavior might elucidate how width and depth affect inference . Some of these works focus on the properties of the function-space prior distribution , some consider maximum-likelihood inference with gradient descent , and some consider properties of the full Bayes posterior . This body of research has resulted in several conjectural conditions under which when narrower and deeper networks might perform better than their infinitely-wide cousins in the Bayesian setting, as measured by generalization for fixed data or by some alternative criterion based on entropic considerations .

However, previous studies of Bayesian neural network generalization near the kernel limit have not clearly differentiated the effect of width on feature learning from its other potential effects on inference. Concretely, it is not clear whether potential improvements in generalization afforded by the leading finite-width correction reflect the benefits of feature learning, or if a similar gain would be observed in random feature models, where only the readout layer is trained. Here, we explore how random and learned features affect generalization in the simplest class of Bayesian NNs—deep linear models—when trained on unstructured, noisy data. By developing a detailed understanding of this simple setting, one might hope to gain intuition that may prove useful in studying more complex networks .

In this work, we study the asymptotic generalization performance of deep linear Bayesian regression for data generated with an isotropic Gaussian covariate model. Using the replica trick , we compute learning curves for simple linear regression, deep linear Gaussian random feature (RF) models, and deep linear NNs. Our results are obtained using an isotropic Gaussian likelihood in the limit of small likelihood variance, which renders this analysis analytically tractable . Using alternative replica-free methods and numerical simulation, we show that the predictions obtained under a replica-symmetric (RS) Ansatz are accurate for all three model classes. In particular, the RS result for learning curves of NNs with hidden layers of equal widths is consistent with results obtained by Li and Sompolinsky using a different approximation method.

In the presence of label noise, both RF and NN models display sample-wise non-monotonicity in their learning curves. As we work in a high-dimensional limit, this non-monontonicity is of a particularly extreme form: the generalization error diverges at a particular data density. In keeping with modern deep learning parlance, we refer to this behavior as “double-descent,” though this monotonicity can arise from distinct effects in different settings . If one introduces a bottleneck layer that is narrower than the input dimension, an RF model will display model-wise double-descent behavior at fixed data density—or equivalently sample-wise double-descent at fixed width—even in the absence of label noise, while an NN model will not show this divergence. This distinct small-width behavior shows one advantage afforded by the flexibility to learn features. For both models, we analyze how optimal network architecture depends on data density and prior mismatch. We show that, at a given data density, RF models have a particular optimal width for fixed depth and optimal depth for fixed width that minimizes the generalization error. In contrast, it is always optimal to take an NN to be as wide or as narrow as possible, depending on the regime.

We further analyze models of arbitrary depth perturbatively in the limit in which the network depth and dataset size are small relative to the hidden layer widths, connecting these results to those of previous work on fixed-dataset perturbation theory . We find that the leading order correction to the large-width behavior of RF and NN models is identical, hence first-order perturbation theory for the generalization error cannot distinguish between random and learned features. To distinguish between training only the readout layer and training all layers, one must go to second order in perturbation theory. Therefore, at large widths, the ability to perform representation learning provides only a small advantage in generalization performance in these simple models relative to random features, which is invisible in first-order perturbation theory. In total, our results provide new insight into how the generalization behavior of deep Bayesian linear regression in high dimensions depends on architectural details. Moreover, they shed light onto which qualitative features of generalization behavior can or cannot be captured by low-order perturbative corrections .

II Problem setting

In this section, we introduce the three classes of regression models we consider in this work, as well as our generative data model. Our notation throughout is standard; we use ∥⋅∥\|\cdot\| to denote the Euclidean norm, Id\mathbf{I}_{d} to denote the d×dd\times d identity matrix, and 1\mathbf{1} to denote the vector with all elements equal to one.

In this work, we consider three classes of scalar Bayesian linear regression models for a scalar-valued function of dd-dimensional inputs. All three of these model classes are of the form

Below, we list the three classes of models we consider, and introduce a two-letter abbreviation for each:

Simple Bayesian linear regression. For this model, the end-to-end weight vector is directly parameterized as

Previous works have extensively studied this model in both maximum-likelihood and fully Bayesian settings , hence we include it as a baseline against which we will compare our results for more complicated models.

Deep Bayesian random feature models. For these models, the weight vector is parameterized as

while the hidden layer weights are drawn from a fixed isotropic Gaussian distribution

Deep Bayesian linear neural networks. For these models, the weight vector is parameterized as

Though NNs are parameterized identically to the RF models above, they differ in that all of the weights are trainable, not only the readout. We again choose isotropic Gaussian prior distributions

From a physical perspective, the hidden layer weights in the RF model are ‘quenched’ disorder, whereas they are ‘annealed’ disorder in NNs .

II.2 Data model and the Bayes posterior

We train all models on a dataset {(xμ,yμ)}μ=1p\{(\mathbf{x}_{\mu},y_{\mu})\}_{\mu=1}^{p} of pp examples, generated according to a standard isotropic Gaussian covariate model . In this model, the example inputs are independent and identically distributed samples from a standard Gaussian distribution:

while the labels are generated by a ground truth linear model, possibly corrupted by additive Gaussian noise:

where η≥0\eta\geq 0 sets the noise variance. The noise variables are independent and identically distributed as

For a dataset thusly generated, we introduce an isotropic Gaussian likelihood of variance 1/β1/\beta:

where W\mathcal{W} denotes the set of trainable parameters for a given model, and the normalization constant is implied. We will refer to β\beta as the ‘inverse temperature’ by standard analogy with statistical mechanics . Then, the partition function of the resulting Bayes posterior is given as

We denote expectations with respect to this Bayes posterior by ⟨⋅⟩\langle\cdot\rangle.

II.3 Generalization error in the thermodynamic limit

Moreover, we focus on the zero-temperature limit β→∞\beta\to\infty, in which the likelihood tends to a constraint that the network interpolates the training set with probability one. In the noise-free case, this limiting likelihood is matched to the true generative model of the data, but it is clearly mismatched in the presence of label noise. This limit has been considered in several recent studies of deep linear Bayesian neural networks .

Our goal is to study the average-case generalization error ϵ\epsilon of the resulting model, as measured by the deviation of its end-to-end weight vector w\mathbf{w} from the true teacher weight vector w∗\mathbf{w}_{\ast}:

We remark that (17) is the average-case error of the Gibbs estimator (i.e., a single sample from the posterior); one could instead consider the error of the mean estimator ⟨w⟩\langle\mathbf{w}\rangle. For the LR and RF models, this corresponds to studying Bayesian minimum mean-squared error (MMSE) inference . As one has the thermal bias-variance decomposition

our results include an additional contribution to the generalization error from the posterior covariance ⟨ww⊤⟩−⟨w⟩⟨w⟩⊤\langle\mathbf{w}\mathbf{w}^{\top}\rangle-\langle\mathbf{w}\rangle\langle\mathbf{w}\rangle^{\top} of the end-to-end weight vector, which is not identically zero. If one considered an alternative low-temperature limit in which the prior variance is proportional to 1/β1/\beta, then this additional contribution would vanish in the low-temperature limit. Our choice of scaling is motivated by the considerations described in our previous work , and is the one classically used in studies of the statistical mechanics of Bayesian inference . This choice is important as it affects the relationship of our results to those in the setting of ridge regression. As discussed in Appendices C and D, in our previous work , and in previous works of Advani and Ganguli and Barbier et al. , the zero-temperature limit of the MMSE estimator would in this case coincide with the ridge regression estimator.

We compute the limiting average generalization error using the replica method, a non-rigorous but powerful heuristic that has seen broad use in statistical mechanical studies of inference . As our main results can be understood independently of calculation through which they were obtained, we relegate the details to Appendices A and B. We note the important caveat that our main results are obtained under a replica-symmetric Ansatz. We expect this assumption to hold exactly for the LR and RF models by virtue of the concavity of their log-posteriors, but replica symmetry may be broken in deep linear NNs . We will not address this possibility analytically by considering Ansätze with broken replica symmetry , but will instead simply compare the RS predictions against results obtained through a combination of alternative analytical methods and numerics.

III Learning curves for the LR model

We begin by briefly describing the learning curve of the simple LR model. Our result extends the classic result of Krogh and Hertz for ridge regression in the ridgeless limit to the Bayesian setting:

For this simple model, the learning curve can also be computed directly by first evaluating the posterior average defining ϵLR\epsilon_{\textrm{LR}} for a fixed realization of the disorder, and then averaging the result over the disorder in the zero-temperature limit (see Appendix C for details). The result of can be recovered from (19) by setting σ=0\sigma=0. We provide further discussion of the relationship between the Bayesian LR model in the zero-temperature limit and ridge regression in the ridgeless limit in Appendix C.

Therefore, as found in the ridge regression setting, the LR model exhibits sample-wise double-descent behavior—i.e., non-monotonicity in ϵLR\epsilon_{\textrm{LR}} as a function of α\alpha —in the presence of label noise. In the thermodynamic limit, the double-descent behavior is particularly striking: ϵLR\epsilon_{\textrm{LR}} diverges as α→1\alpha\to 1. In the absence of noise, ϵLR\epsilon_{\textrm{LR}} decreases monotonically from 1+σ21+\sigma^{2} to as α↑1\alpha\uparrow 1, and then remains at zero for all α>1\alpha>1. We remark that, for this and subsequent models, we will not conduct a detailed analysis of what happens precisely at exceptional points, e.g., α=1\alpha=1. In the ridge regression setting, the phase transition at α=1\alpha=1 has recently been analyzed in detail by Canatar et al. . We also direct the interested reader to an expository note by Nakkiran for further intuitions on double-descent in ridge regression, and to work by Hastie et al. for a detailed rigorous analysis. We will take the model-wise double-descent behavior of the LR model as a benchmark for our subsequent analyses of the more complex RF and NN models.

IV Learning curves for the RF model

We validate the accuracy of this RS result by comparing it against the result of an alternative semi-analytical approach. As shown in Appendix C, the zero-temperature posterior average in (17) can be computed for a fixed realization of the disorder. Even without explicitly evaluating the disorder average, this shows that the RF model should display the three phases indicated by the RS result (20), and confirms the prediction for in which of the phases the learning curve should depend on the prior variance σ2\sigma^{2} (see Appendix C). Importantly, the RF model learning curve (17) does not depend on the ordering of the hidden layer widths, which follows from the fact that the random Gaussian hidden layer weight matrices weakly commute . For conceptual clarity, we therefore refer to the cases in which different hidden layers are the narrowest as a single phase. To quantitatively test the accuracy of the RS result, the disorder average can be evaluated numerically using sampling (see Appendix G). As shown in Figures 1 and 2, we observe excellent agreement over a broad range of parameter values. These results are consistent with our expectation that the RS Ansatz should yield accurate results for the RF models .

While the LR model only exhibits double-descent behavior in the presence of label noise (19), the RF model can also exhibit double-descent behavior in the absence of label noise if any one of the hidden layers is narrower than the input dimension, i.e., γmin<1\gamma_{\textrm{min}}<1. This phenomenon occurs in a model-wise fashion at fixed data density: if one considers a decreasing sequence of widths γmin\gamma_{\textrm{min}} at fixed α\alpha, ϵRF\epsilon_{\textrm{RF}} will diverge as γmin↓α\gamma_{\textrm{min}}\downarrow\alpha (Figure 1a,c,e). Equivalently, this divergence can be observed in a sample-wise fashion at fixed width, with ϵRF→∞\epsilon_{\textrm{RF}}\to\infty as α→γmin\alpha\to\gamma_{\textrm{min}}. Moreover, as illustrated in Figure 2, it is determined by the width of the narrowest hidden layer. If one adds more bottleneck layers, then the expression for the generalization error in the regime α<γmin\alpha<\gamma_{\textrm{min}} will formally include more poles (20), but these poles will not be visible as one varies the size of the training set or the width of the narrowest bottleneck.

IV.2 Large-width behavior

where O(α2/γ2)\mathcal{O}(\alpha^{2}/\gamma^{2}) denotes terms that include two or more factors of any combination of the layer widths.

where we have defined the re-scaled prior variance

Then, for α/γ<1\alpha/\gamma<1, we can read off the full series expansion using the binomial theorem and the geometric series:

IV.3 Optimal width and depth

which is consistent with the result for optimal width at fixed depth given in (25). Therefore, much like we found in our analysis of optimal width, the optimal depth of an RF model is related to the match between the scale of the prior and of the target. This behavior is illustrated in Figure 3.

V Learning curves for the NN model

For the NN model, we do not obtain a simple closed-form solution for the RS learning curve at general depth. As shown in Appendix B.3, we find that the solution is of the form

We defer more detailed discussion of which root should be selected to Appendix B.3, where we show that one required condition on the solution is that

The special case of (28) for networks with hidden layers of equal widths follows from results obtained through a rather different approach in a recent study by Li and Sompolinsky . Concretely, they use an iterative saddle-point argument to approximate the posterior expectation in (17) for fixed data, and then apply that result to a random Gaussian covariate model under what amounts to the assumption that the quantity y⊤(XX⊤)−1y\mathbf{y}^{\top}(\mathbf{X}\mathbf{X}^{\top})^{-1}\mathbf{y} concentrates rapidly. In Appendix D, we provide a detailed discussion of the mapping between the polynomial condition in terms of which their result is expressed and the RS condition (29). In Appendix D, we also use a finite-size fixed-data approach derived from our previous work to show that the learning curve should be of the form (28). Concretely, this approach gives an expression for zz as the thermodynamic limit of a dataset average of a ratio of prior averages, with the remaining components of the learning curve exactly matching the RS prediction. Taken together, these result suggests that the RS prediction for the learning curve correctly captures at least the coarse behavior of generalization in NNs.

To further probe whether the RS prediction is quantitatively accurate, we evaluate the finite-size data average numerically. As shown in Figures 4 and 5, and in supplemental figures provided in Appendix G, we observe good agreement for two-layer networks. To probe the accuracy of the RS prediction for deeper networks, we solve the polynomial (29) numerically. As shown in Figures 4 and 5, we again observe good agreement. Therefore, both alternative heuristic analytical approaches and numerical results are consistent with the RS learning curve, suggesting that it provides a reasonably accurate picture of generalization in deep NNs.

Like the previously-studied models, we see that label noise can induce sample-wise double-descent, with ϵNN→∞\epsilon_{\textrm{NN}}\to\infty as α→1\alpha\to 1 (Figure 4). However, unlike for the RF model, having relatively narrow hidden layers does not introduce the possibility of divergences other than at α=1\alpha=1, as zz should remain bounded. This is illustrated in Figure 5, where we repeat the analysis of Figure 2, but do not observe similar model-wise divergences. Moreover, this means that the NN model does not display sample-wise divergences in the absence of label noise. Therefore, training the hidden layers affords the advantage of avoiding the possible model- and sample-wise divergences that can arise in RF models with narrow bottlenecks. This sharp contrast makes sense, since in the RF model the presence of layers width γl<1\gamma_{l}<1 introduces a true bottleneck, while in the NN model one could in principle find a solution where, in all layers except the first, exactly one weight is nonzero, and the model essentially reduces to shallow linear regression. The existence of this solution reflects the fact that, from the standpoint of expressivity, NN models should be able to perform as well as LR models, and differences in performance reflect the behavior of the inference algorithm . Indeed, if σ=1\sigma=1 and η=0\eta=0, we have the solution z=1−αz=1-\alpha, and ϵNN=ϵLR\epsilon_{\textrm{NN}}=\epsilon_{\textrm{LR}}. Therefore, in this special case, the RS result predicts that depth has no effect on generalization performance. This behavior is clearly illustrated by Figure 5, where the generalization error of a three-layer NN remains constant as the widths of the two hidden layers are varied. Even at non-zero noise levels, Figure 4 illustrates that width has a relatively minimal effect of generalization performance when σ=1\sigma=1.

V.2 Large-width behavior

This limiting result has several interesting features. First, paralleling our analysis of the RF model at large widths, the closeness of the NN model’s learning curve to that of simple linear regression is determined by a combination of depth, dataset size and width. Second, not only do the RS learning curves for NN and RF models agree at infinite width, but the leading order corrections agree (i.e., the term that is linear in α/γl\alpha/\gamma_{l}; see (21)). Thus, if one tracked only the generalization error, one could not differentiate between training only the readout layer and training all of the layers simply by considering the leading order perturbative correction. One could of course distinguish between these two models by considering leading-order corrections to observables that explicitly measure task-relevant feature learning in early hidden layers, such as the kernels considered in our previous work .

V.3 Generalization gap between RF and NN models

Therefore, the next-to-leading order correction can distinguish between RF and NN models. Moreover, the gap in the generalization performance of the two models is, to the given order,

The coefficient of the leading term is always positive, hence at very large widths training both layers should produce a small benefit relative to simply training the readout. In the two-layer case, one can use the closed-form solution for the RS generalization error to show that the generalization gap ϵRF−ϵNN\epsilon_{\textrm{RF}}-\epsilon_{\textrm{NN}} is strictly positive, except at vanishing load or in the limit γ1→∞\gamma_{1}\to\infty (see Appendix F.4). These results suggest that training all layers of a deep linear network can yield improved generalization relative to training only the last layer, even if the widths are large enough such that the RF model does not display double-descent in the absence of noise. See Figure 6 for an illustration of this behavior.

V.4 Optimal width and depth

VI Discussion and conclusions

In this work, we studied the statistical mechanics of inference in deep Bayesian linear models. We characterized the learning curves of deep linear random feature models and deep linear neural networks for isotropic Gaussian covariates, using a combination of the replica trick and replica-free methods. Our primary results for how deep Bayesian linear models with random and learned features differ or resemble may be summarized as follows:

In the presence of label noise, both RF and NN models display sample-wise double-descent (Figures 1 and 4). For RF models, the presence of a bottleneck layer with width less than the input dimension induces model-wise double-descent at fixed dataset size and sample-wise double descent at fixed width (Figures 1 and 2), while bottlenecks do not affect the double-descent behavior of NN models (Figures 4 and 5). In particular, NN models do not display model-wise double-descent, and do not display sample-wise double-descent in the absence of label noise.

For both RF and NN models, the effect of width on generalization depends on the match between the prior variance and the true scale of the targets, with wider networks yielding better generalization when the prior variance is less than the average target scale (Figures 3 and 7). For NN models, taking the network to be as wide or as narrow as possible is always optimal. In contrast, when the prior variance is greater than the average target scale, there is a particular width that yields optimal generalization in RF models.

Similarly, the optimal depth for both models depends on prior-target mismatch. Paralleling the case of optimal width, deeper models always perform worse when the prior variance is less than the average target scale (Figures 3 and 7). When prior variance is greater than the average target scale, shallower models perform better. In this regime, as in the case of optimal width, there is a particular depth that yields optimal RF model generalization for fixed width, prior variance, and data density.

VI.2 Prior work

Double-descent phenomena have recently garnered significant interest in deep learning . In high-dimensional random feature models like those considered in §IV, divergences in the generalization error can arise through interactions between randomness in the features and randomness in the training data . Moreover, as noted in our discussion of simple linear regression models in §III, divergences can arise in models without additional feature randomness—including kernel regressors with deterministic nonlinear features—due to overfitting of noisy labels . Disentangling the causes of non-monotonicitic generalization performance observed in experimental settings for realistic data models remains an interesting subject for further study .

The statistical mechanics of inference in shallow linear models with more general priors and likelihoods was investigated in detail by Advani and Ganguli , who showed a correspondence between the performance of Bayesian MMSE inference and a class of algorithms known as M-estimators. The effect of prior mismatch on the performance of the shallow MMSE estimator has also been considered in recent rigorous work by Barbier et al. . However, neither of these works considered the effect of depth on inference.

This regime has thus far proven challenging to access perturbatively, as large deviations from the kernel limit may emerge . Existing fixed-data approaches to regimes in which either the dataset size or the output dimension is not negligible relative to hidden layer width rely on saddle-point approximations that may break down when both of these parameters are large. New approaches will therefore be required to study networks in this limit non-perturbatively. With such results in hand, it will be interesting to test whether existing perturbative predictions do in fact capture qualitative features of how generalization depends on network architecture and other hyperparameters. For the simple models considered here, we found that small-sample-size perturbation theory does in fact yield largely correct predictions for when wider networks generalize better, even at large sample size.

VI.3 Outlook

We conclude by noting that our work has several important limitations, which will be interesting to address in future work. First, our approach is highly specialized to deep linear networks, and would not extend easily to nonlinear models. Though the utility of linear networks as a model system for studying the effect of depth on inference has been clearly established , rigorous characterization of the effect of nonlinearity on inference in deep Bayesian neural networks remains a largely open problem . Second, we have assumed that the covariates are drawn from an isotropic Gaussian distribution. Though this is a standard generative model in theoretical studies of inference , it is undoubtedly not reflective of real-world data. Extending results of this form to more realistic generative models will be an interesting objective for future work . We remark that some of the fixed-data results of Appendices C and D would extend immediately to anisotropic and non-Gaussian data provided that the requisite invertibility conditions hold. While BNNs are finding practical applications in physics and elsewhere , another important direction for future work will be to develop a rigorous theoretical understanding of how results on the generalization performance of BNNs, like those obtained here, relate to the generalization performance of networks trained with stochastic gradient-based algorithms, a link that remains incompletely understood . Finally, our replica theory approach is of course non-rigorous. For the RF model, we do not expect replica symmetry to be broken, and conjecture that our results might be rigorously justifiable . Moreover, our replica-free analytical approaches and numerical experiments suggest that our RS results for NNs are at the very least a reasonable approximation for their true generalization performance. With that in mind, careful exploration of the possibility of replica symmetry breaking will be an interesting topic for further investigation.

Note added. Following the appearance of our work in preprint form, results on the behavior of the ridge regression estimator—which in this case would coincide with the limiting MMSE estimator—for a model with a single layer of Gaussian linear random features were announced by Rocks and Mehta .

Appendix A Replica theory framework

In this appendix, we introduce the replica theory framework we use to compute learning curves. We direct the interested reader to for more details on replica theory. Our starting point is the partition function of the Bayes posterior:

In the limit of interest, we expect the quenched free energy

We first integrate out the data. Introducing replicas indexed by a=1,…,ma=1,\ldots,m, the object of interest is the disorder-averaged replicated partition function:

where wa\mathbf{w}^{a} denotes the end-to-end weight vector with appropriate replica indices for a given model. Using the fact that the training examples are independent and identically distributed, we have

where we have defined the m×mm\times m overlap matrix

Enforcing the definition of the order parameter matrix Q\mathbf{Q} by introducing corresponding Lagrange multipliers Q^\hat{\mathbf{Q}} , we therefore have

Here, the integrals over Q\mathbf{Q} and Q^\hat{\mathbf{Q}} are taken over the spaces of real and imaginary m×mm\times m symmetric matrices, respectively. Our remaining task is to integrate out the weights, which we will do for each of the three models of interest in the following sections.

A.2 Integrating out the weights for the LR model

Using the assumption that ∥w∗∥22=d\|\mathbf{w}_{\ast}\|_{2}^{2}=d and defining

we can write the averaged replicated partition function of a single-layer network as

A.3 Integrating out the weights for the RF model

via Fourier representations of the Dirac distribution with corresponding Lagrange multipliers C^1\hat{\mathbf{C}}_{1}, we can integrate out U1\mathbf{U}_{1}, yielding

It is easy to see that we can iterate this procedure forward through the network, introducing order parameters

along with corresponding Lagrange multipliers, yielding

Then, using the assumption that ∥w∗∥22=d\|\mathbf{w}_{\ast}\|_{2}^{2}=d and defining

we can write the averaged replicated partition function as

We note that we have intentionally split the entropic contribution to the replica free energy into two pieces. The first, G2(Q,Q^,C1)G_{2}(\mathbf{Q},\hat{\mathbf{Q}},\mathbf{C}_{1}), reduces to the entropic contribution for simple linear regression upon fixing C^1=Im\hat{\mathbf{C}}_{1}=\mathbf{I}_{m}. The second, G3G_{3}, captures the effect of depth.

A.4 Integrating out the weights for the NN model

As we did for the RF model, we start by integrating out U1a\mathbf{U}_{1}^{a}. We introduce analogous order parameters

However, importantly, as the weights U1a\mathbf{U}_{1}^{a} are annealed rather than quenched, the covariance of hjah_{j}^{a} is replica-diagonal. For clarity of notation, we define the diagonal matrix

Then, introducing a corresponding diagonal matrix of Lagrange multipliers D^1\hat{\mathbf{D}}_{1}, we have

upon integrating out U1a\mathbf{U}_{1}^{a}. We can see that we can follow much the same procedure to integrate out the remaining weights as we did for the random feature model, except for the fact that we only consider the replica-diagonal component of the overlaps, which are re-defined to include the replica indices of the hidden layer weights, i.e.,

where FF is the same as for the random feature model and the matrices Dl\mathbf{D}_{l} and D^l\hat{\mathbf{D}}_{l} are constrained to be replica-diagonal. This difference reflects the fact that the hidden layer weights of the NN model are annealed, rather than being quenched as in the RF model.

A.5 The replica-symmetric Ansatz

In the thermodynamic limit, we evaluate the integral over the appropriate order parameters and Lagrange multipliers for each model via the method of steepest descent. Importantly, we note that the diagonal components of the order parameters QaaQ^{aa} give the posterior-averaged generalization errors of the replicas, as in the thermodynamic limit the mean value of these parameters is given by the saddle-point equations. Our eventual objective is therefore simply to evaluate the saddle-point values of Q\mathbf{Q} in the zero-temperature limit, and we will not consider the resulting values of the free energy.

As usual in the replica method, we seek extrema in the limit m→0m\to 0 of a constrained form, known as the replica-symmetric (RS) Ansatz . For all three models, the RS Ansatz for the variables Q\mathbf{Q} and Q^\hat{\mathbf{Q}} is simply

For a deep random feature model, the RS Ansatz for the remaining order parameters is

while, for a deep network, the RS Ansatz for the remaining order parameters is

as we consider only the replica-diagonal components of the overlaps Cl\mathbf{C}_{l}. With this Ansatz, one can simplify the expressions for the free energy and the saddle-point equations in the limit m→0m\to 0. These manipulations are standard exercises using the properties of RS matrices , hence we will only report the results (in Appendix B).

We remark briefly on the conditions under which the RS order parameters make physical sense given their definitions. We must have Q≥0Q\geq 0 and Cl≥0C_{l}\geq 0 for all ll, as these quantities are the squares of norms of vectors. If Cl=0C_{l}=0 for any ll, the norm of the end-to-end weight vector tends to zero, and we must have a trivial solution with Q=1Q=1. We must also have Q−q≥0Q-q\geq 0 and Cl−cl≥0C_{l}-c_{l}\geq 0 for all ll. Moreover, if Q−q=0Q-q=0 (respectively Cl−cl=0C_{l}-c_{l}=0 for some ll), then we must have q≥0q\geq 0 (respectively cl≥0c_{l}\geq 0), to obtain a nontrivial physical solution.

Appendix B Solution of the replica-symmetric saddle point equations

In this appendix, we analyze the replica-symmetric saddle point equations in the zero-temperature limit.

For simple linear regression, the RS saddle point is given by a 4-dimensional system of equations, which decouples into a two-dimensional nonlinear system for the replica-nonuniform components z≡Q−qz\equiv Q-q and z^≡Q^−q^\hat{z}\equiv\hat{Q}-\hat{q},

and a linear system for the replica-uniform components qq and q^\hat{q}:

Using the expression for z^\hat{z} as a function of zz, we obtain the quadratic condition

The two solutions z±z_{\pm} to this quadratic equation have zero-temperature limits

For α>1\alpha>1, z−z_{-} is negative, and is therefore unphysical. If 0<α<10<\alpha<1,

These are the two low-temperature scalings we would expect to be self-consistent given the saddle point equations; we could alternatively derive the above solutions by assuming these scalings for zz.

Considering the replica-uniform components, we use the expressions for 1−σ2z^1-\sigma^{2}\hat{z} and q^\hat{q} as functions of zz and qq to write

For the solution with z∼O(1)z\sim\mathcal{O}(1), we then have

hence, recalling that this scaling yields z=σ2(1−α)z=\sigma^{2}(1-\alpha) and is valid for 0<α<10<\alpha<1,

For the solution with z∼r/βz\sim r/\beta with r∼O(1)r\sim\mathcal{O}(1), we have

hence, recalling that this scaling yields r=1/(α−1)r=1/(\alpha-1) and is valid for α>1\alpha>1,

Combining these results, we obtain a zero-temperature solution which gives the result for ϵ=Q\epsilon=Q reported in the main text.

B.2 RF model

We can then solve the remaining equations for the replica-uniform components,

We first consider the replica nonuniform components. We start by noting that the equations for zz and z^\hat{z} yield

hence the equation for w^1\hat{w}_{1} yields

With this observation in mind, we will eliminate the Lagrange multipliers w^l\hat{w}_{l}. Formally defining wl+1≡1w_{l+1}\equiv 1 for convenience, we have

which yields a self-consistent equation for zz

As in the single-layer case, it can be seen that the self-consistent scalings for zz in the zero-temperature limit are z∼O(1)z\sim\mathcal{O}(1) and z∼O(1/β)z\sim\mathcal{O}(1/\beta). If we take β→∞\beta\to\infty with z∼O(1)z\sim\mathcal{O}(1), we simply have zz^→−αz\hat{z}\to-\alpha, which gives

for all ll. As physical solutions have z≥0z\geq 0 and all wl≥0w_{l}\geq 0, this solution is sensible in the regime α<min⁡{1,γ1,γ2,…,γl}\alpha<\min\{1,\gamma_{1},\gamma_{2},\ldots,\gamma_{l}\}.

If we take z∼r/βz\sim r/\beta for r∼O(1)r\sim\mathcal{O}(1), we have

For the zeroth solution with r0=1α−1r_{0}=\frac{1}{\alpha-1}, we have zz^→−1z\hat{z}\to-1, and thus

This solution is therefore physical for α>1\alpha>1 and all γl>1\gamma_{l}>1. For the l∗l_{\ast}-th such solution, we have zz^→−γl∗z\hat{z}\to-\gamma_{l_{\ast}}, hence

Thus, we have wl→0w_{l}\to 0 for all l≤l∗l\leq l_{\ast}. For l>l∗l>l_{\ast}, wl∼O(1)w_{l}\sim\mathcal{O}(1), and we must have γl≥γl∗\gamma_{l}\geq\gamma_{l_{\ast}} for all l>l∗l>l_{\ast} such that wl≥0w_{l}\geq 0. Moreover, we must have α>γl∗\alpha>\gamma_{l_{\ast}}, such that rl∗>0r_{l_{\ast}}>0. We will obtain further conditions on the validity of these solutions from solving for the replica-uniform components.

B.2.2 Solving for the replica-uniform components

We now consider the linear system of equations (96) that determines the replica-uniform components in terms of the non-uniform components. We start by noting that we can c^1\hat{c}_{1} express a function of qq alone, eliminating the dependence on c1c_{1} using the equation for qq:

where we have used the fact that q^=z^2(q+η2)/α\hat{q}=\hat{z}^{2}(q+\eta^{2})/\alpha.

Similarly, we can simplify the initial difference condition to

hence, substituting in w1=1σ2z1+zz^w_{1}=\frac{1}{\sigma^{2}}\frac{z}{1+z\hat{z}}, we have

To simplify our remaining task, we define new variables ulu_{l} such that

Given a solution to the recurrence for the variables ulu_{l}, we then have a closed equation for qq:

With this solution in hand, we can then obtain clc_{l} via the relation cl=γ1w12c^1(q)ulc_{l}=\gamma_{1}w_{1}^{2}\hat{c}_{1}(q)u_{l}.

We now consider the zero-temperature limits of interest. With z∼O(1)z\sim\mathcal{O}(1), we have zz^→−αz\hat{z}\to-\alpha. The limiting equation for qq is then

Considering the recurrence for ulu_{l}, we have

which can easily be iterated backward, yielding

hence, iterating one step backwards, we find that

It is now easy to see that we can iterate this process backwards, yielding

in particular. Using the initial difference condition to express u2u_{2} in terms of u1u_{1}, we then obtain a closed equation for u1u_{1}:

As this equation is linear, it is easy to solve, yielding

under the assumption that α≠γl\alpha\neq\gamma_{l} for all ll. Then, we have

in terms of the solution for 1−αu11-\alpha u_{1}. Then, in terms of these solutions for ulu_{l}, we have

We now consider the solutions with z∼r/βz\sim r/\beta for r∼O(1)r\sim\mathcal{O}(1). We first consider the solution with

For this solution, zz^→−1z\hat{z}\to-1, and the limiting self-consistent equation for qq reduces to

for any u1u_{1}. This is non-negative throughout the expected region of physical validity (α>1\alpha>1), and therefore the overall solution makes sense given that z→0z\to 0 in this regime. The recurrence for ulu_{l} simplifies to

This yields a self-consistent equation for c1c_{1}, which gives

for all ll, where the empty product is interpreted as unity. These results are positive throughout the region of physical validity we expect from our analysis of the replica-nonuniform components; recalling that wl>0w_{l}>0 for these solutions, no further conditions are imposed.

Iterating one step backward, we find that

It is then easy to see that we can iterate further back to obtain, for l<l∗l<l_{\ast},

hence the initial difference equation yields

For 2≤l≤l⋆2\leq l\leq l_{\star}, this yields the solution

By the same reasoning as in our analysis of the case r=1/(α−1)r=1/(\alpha-1), we have the limiting closed set of equations

Using the fact that u1=1/γl∗u_{1}=1/\gamma_{l_{\ast}}, we have

Then, for 2≤l≤l∗2\leq l\leq l_{\ast}, we have

using the solution for ulu_{l} obtained above. As wl=0w_{l}=0 for l≤l∗l\leq l_{\ast}, we must have cl≥0c_{l}\geq 0 for l≤l∗l\leq l_{\ast} in order for these solutions to be physical, hence we conclude that we must have γl≥γl∗\gamma_{l}\geq\gamma_{l_{\ast}} for all l<l∗l<l_{\ast}. As wl≥0w_{l}\geq 0 for l>l∗l>l_{\ast}, we will not obtain further conditions on the physical validity of these solutions by solving for clc_{l} for l>l∗l>l_{\ast}, hence we will not attempt to do so.

B.3 NN model

where, as before, we have defined z≡Q−qz\equiv Q-q and z^≡Q^−q^\hat{z}\equiv\hat{Q}-\hat{q} for brevity. Unlike for the RF model, in this case the replica-uniform and replica-nonuniform components do not decouple nicely. However, we have fewer equations to solve. Moreover, we can exclude solutions with Cl∼O(1/β)C_{l}\sim\mathcal{O}(1/\beta), as they will be trivial.

where we have noted that q^=z^2(q+η2)/α\hat{q}=\hat{z}^{2}(q+\eta^{2})/\alpha.

We now seek to eliminate the Lagrange multipliers C^l\hat{C}_{l} and all of the order parameters ClC_{l} except for C1C_{1}. To do so, we will follow our earlier analysis of the RF model. We define

which will allow us to close the equations.

Using the abovementioned fact that we can write

we can see that this set of equations is analogous to what we obtained for the deviations from uniformity wlw_{l} and w^l\hat{w}_{l} in the RF case (with, in that case, A=zz^A=z\hat{z}). Thus, using the results of our previous calculation, we conclude that

which gives us closed set of equations for zz, z^\hat{z}, qq, q^\hat{q}, and C1C_{1}.

With the scaling z∼O(1)z\sim\mathcal{O}(1), we have zz^→−αz\hat{z}\to-\alpha, and the condition on qq becomes

To determine the limiting condition on zz, we note that

Therefore, we have the polynomial condition

in order for it to be a nontrivial physical solution. This implies that we must have

For any γ1,σ>0\gamma_{1},\sigma>0, z+≥0z_{+}\geq 0 if 0<α<10<\alpha<1, and z−≥0z_{-}\geq 0 if α>1\alpha>1. However, noting that

the z+z_{+} solution yields a non-negative value for C1C_{1}, and is therefore physical for 0<α<10<\alpha<1, while the z−z_{-} solution yields a non-positive value, and is therefore unphysical.

order-by-order in λ\lambda with the Ansatz

It is easy to see that the zeroth-order condition yields

In this simplified setting, it is relatively straightforward to work out by hand or with the aid of Mathematica that

For solutions with z∼O(β−1)z\sim\mathcal{O}(\beta^{-1}) and C1∼O(1)C_{1}\sim\mathcal{O}(1), we have the limiting equation

As z→0z\to 0, we must have q≥0q\geq 0, hence this solution makes sense for all α>1\alpha>1. To solve for ClC_{l} for these solutions, it is most convenient to express AA in terms of C1∼O(1)C_{1}\sim\mathcal{O}(1). Noting that

Given a candidate positive solution for C1C_{1}, we can then determine ClC_{l} for all l>1l>1 via

for all ll (including l=1l=1) in order for the candidate solution to be physical and non-trivial. As we are interested only in learning curves, we will not analyze this equation further.

Appendix C Direct computation of posterior expectations for LR and RF models

For the LR and RF models, we can evaluate the zero-temperature posterior expectation in the definition of ϵ\epsilon analytically. In particular, writing

for brevity, we have the posterior moment generating function for v\mathbf{v}:

where the implied constants of proportionality are independent of the source j\mathbf{j}. Then, as w=dFv\mathbf{w}=\sqrt{d}\mathbf{F}\mathbf{v}. the posterior mean and covariance of the end-to-end weight vector are given as

respectively. We note that ⟨w⟩\langle\mathbf{w}\rangle is simply the RF ridge regression estimator with ridge parameter 1/β1/\beta, as

The thermal bias-variance decomposition of the zero-temperature generalization error is then given as

Under the stated assumptions, the matrices A⊤X⊤XA\mathbf{A}^{\top}\mathbf{X}^{\top}\mathbf{X}\mathbf{A} and BB⊤\mathbf{B}\mathbf{B}^{\top} are invertible with probability one, as is their product. Then, we have

We observe that, under the re-scaling of the feature map F↦σF\mathbf{F}\mapsto\sigma\mathbf{F} for any σ>0\sigma>0, εb\varepsilon_{b} is always constant, while εv\varepsilon_{v} is either identically zero or degree-two homogeneous in σ\sigma. This suggests that we should be able to read off the ridgeless results from our Bayesian replica results. We also note that we have recovered the three-region phase diagram indicated by our replica calculation.

For completeness, we also remark that we can use these results to directly compute ϵLR\epsilon_{\textrm{LR}} without the use of the replica trick. For the LR model, we have

in this regime. This recovers the result of our replica computation.

We remark that a similar, albeit more complex, procedure would likely allow one to derive the learning curve for a deep RF model rigorously using properties of products of large Gaussian random matrices . However, from a physical perspective, the non-rigorous replica theory approach used here has the advantages of being more transparent and of allowing a relatively unified treatment of NN models.

Appendix D Direct computation of posterior expectations for NN models

In this appendix, we show that the zero-temperature posterior expectation in the definition of ϵ\epsilon can be evaluated semi-analytically for NNs. Our approach mirrors that of our previous work in : we will integrate out the weights of the first hidden layer (U1\mathbf{U}_{1}) exactly, yielding expressions for the posterior mean and variance of the end-to-end weight vector in terms of expectations over the remaining weights. These results follow by applying the results of to a test dataset of dd examples with trivial data matrix X^=dId\hat{\mathbf{X}}=\sqrt{d}\mathbf{I}_{d} and then passing to the zero-temperature limit, but we will provide a detailed derivation for completeness.

for brevity, such that w=dU1f\mathbf{w}=\sqrt{d}\mathbf{U}_{1}\mathbf{f}, we can write the posterior moment generating function of w\mathbf{w} as

where we discard irrelevant constants of proportionality. This matrix Gaussian integral can be conveniently evaluated through vectorization . Using standard properties of the Kronecker product, we find that

By varying this result with respect to the source, we thus obtain

for brevity. This matches the result of applying ’s expressions to a trivial dataset with X^=dId\hat{\mathbf{X}}=\sqrt{d}\mathbf{I}_{d}.

As for the RF model, we introduce a thermal bias-variance decomposition

For any set of hidden layer widths, ∥f∥2\|\mathbf{f}\|^{2} is almost surely positive. Therefore, as the only matrix inverses present in these expressions are of the form (Ip+β∥f∥2XX⊤)−1(\mathbf{I}_{p}+\beta\|\mathbf{f}\|^{2}\mathbf{X}\mathbf{X}^{\top})^{-1}, the NN model should have two phases: p<dp<d and p>dp>d.

If p<dp<d, then the matrix XX⊤\mathbf{X}\mathbf{X}^{\top} is invertible with probability one. Then, up to (divergent) multiplicative constants which will cancel in the ratios of expectations, we have the almost-sure pointwise limit

Similarly, we have the almost-sure limits

Therefore, noting that lim⁡β→∞z\lim_{\beta\to\infty}\mathbf{z} is almost surely a constant function of f\mathbf{f}, we have

If p>dp>d, then the matrix XX⊤\mathbf{X}\mathbf{X}^{\top} is invertible with probability zero, but the matrix X⊤X\mathbf{X}^{\top}\mathbf{X} is invertible with probability one. By the Weinstein-Aronzjan identity,

hence the determinant factors in ρ\rho will yield a factor of ∥f∥−d\|\mathbf{f}\|^{-d} in the zero-temperature limit. We must be more careful in considering the exponential term in ρ\rho. Letting the orthonormal eigendecomposition of XX⊤\mathbf{X}\mathbf{X}^{\top} be

we have the low-temperature Neumann series

hence the divergent null-space projector term β∑{j : χj=0}mjmj⊤\beta\sum_{\{j\,:\,\chi_{j}=0\}}\mathbf{m}_{j}\mathbf{m}_{j}^{\top} does not depend on f\mathbf{f}, and will therefore cancel in the ratio of expectations. Thus, we have

By a simple application of the push-through identity, we have the almost-sure pointwise limits

Therefore, noting that lim⁡β→∞z\lim_{\beta\to\infty}\mathbf{z} is once again almost surely a constant function of f\mathbf{f}, we have

Comparing this result to the discussion of the LR model in Appendix C, we can see that the bias terms in each phase are identical to those for the LR model, hence we can apply the results given there for their dataset averages. This shows that the learning curve for the NN model is of the form (28), with

We remark that evaluation of the outer dataset average without resorting to the replica trick seems likely to be challenging.

For a network with a single hidden layer, we can evaluate the average over W∖U1=v\mathcal{W}\setminus\mathbf{U}_{1}=\mathbf{v} analytically. In this case, we have

for brevity. Using the fact that ∥v∥2∼χ2(n1)\|\mathbf{v}\|^{2}\sim\chi^{2}(n_{1}) under the prior, we have

where Kν(z)K_{\nu}(z) is a modified Bessel function of the second kind . Thus, for a NN with a single hidden layer, we have

rapidly concentrates about its limiting mean value, which is

Then, by equations (26) and (27) of the main text of , or by equations (24), (26), and (30) of their Supplemental Material, the result of their approximation is that

with λ≡α/γ\lambda\equiv\alpha/\gamma. We would like to show that this is consistent with the result of our RS calculation, which implies that zz should be a non-negative root of

which recovers Li and Sompolinsky’s result.

Appendix E Comparison to large-width perturbative calculations with fixed data

We remark that the results of show that it should be safe to interchange the limit β→∞\beta\to\infty with the high-dimensional limit and the expectation over data. Using the fact that XX⊤\mathbf{X}\mathbf{X}^{\top} is invertible with probability one in this regime, the disorder average of the thermal bias term yields

where we have again used the formula for the expectation of an inverse Wishart matrix with identity scale matrix . Similarly, the disorder average of the thermal variance term yields

Therefore, the perturbative result of implies a large-width disorder-averaged generalization error of

which agrees with the leading-order large-width solution of the RS result reported here. This makes sense, as we intuitively expect possible RSB effects to emerge at smaller width. Moreover, we remark that we have an exact correspondence between Q−qQ-q and qq and the averages of the thermal variance and bias terms, respectively. Finally, we note that the coefficient of the O(α/γ)\mathcal{O}(\alpha/\gamma) correction, which is the dataset average of dy⊤(XX⊤)−1y/p−σ2d\mathbf{y}^{\top}(\mathbf{X}\mathbf{X}^{\top})^{-1}\mathbf{y}/p-\sigma^{2}, gives the dataset average of the condition for when increasing width helps generalization noted by .

Appendix F Detailed analysis of optimal network architecture

In this appendix, we provide a detailed analysis of how width and depth affect generalization in RF and NN models.

We first consider optimizing the width of a deep random feature model. In the regime α<min⁡{1,γmin}\alpha<\min\{1,\gamma_{\textrm{min}}\}, we have

For γ1<γ⋆\gamma_{1}<\gamma_{\star}, ∂ϵRF/∂γ1<0\partial\epsilon_{\textrm{RF}}/\partial\gamma_{1}<0, while for γ1>γ⋆\gamma_{1}>\gamma_{\star}, ∂ϵRF/∂γ1>0\partial\epsilon_{\textrm{RF}}/\partial\gamma_{1}>0. This point is therefore a minimum of ϵRF\epsilon_{\textrm{RF}}.

To check whether this is indeed a local minimum, we compute the Hessian of ϵRF\epsilon_{\textrm{RF}} at the stationary point, which is given by

Diagonalizing this matrix is trivial, yielding eigenvalue

with multiplicity one. Both of these eigenvalues are positive throughout the parameter region of interest, confirming that the Hessian is positive-definite at the stationary point. Moreover, substituting γ⋆\gamma_{\star} into the generalization error ϵRF\epsilon_{\textrm{RF}}, we have

For RF models in the regime α>γmin\alpha>\gamma_{\textrm{min}} for γmin<1\gamma_{\textrm{min}}<1, it is easy to see that ϵRF\epsilon_{\textrm{RF}} is a monotonically decreasing function of γmin∈[0,1)\gamma_{\textrm{min}}\in[0,1) if α>1\alpha>1, while if α<1\alpha<1, it is a monotonically increasing function of γmin∈[0,α)\gamma_{\textrm{min}}\in[0,\alpha). However, in this regime, it is important to keep track of crossings in the ordering of different layer widths.

F.2 Optimal depth for RF models

which is bounded as 0<ψ<10<\psi<1 in the regime of interest. This gives

Using the lower bound log⁡(ψ)>1−1/ψ\log(\psi)>1-1/\psi, which is strict for all 0<ψ<10<\psi<1, we have

F.3 Optimal width for NN models

For a two-layer NN in the regime α<1\alpha<1, we have

F.4 Difference in generalization in two-layer NN and RF models

For two-layer networks, we have the RF-NN generalization gap

Appendix G Numerical methods

Below, we elaborate on the numerical methods used to validate the replica-symmetric learning curves. In all of the numerical simulations, we set the input dimensionality d=100d=100, and sample with a resolution of around 50 - 100 estimates per dimension. To produce the standard error bars, we sample 10 values per estimate. Numerical procedures were written with NumPy and SciPy . Plots were generated with Matplotlib .

Theoretical predictions for the generalization error in Bayesian random feature models can be computed directly from equation (20). Additionally, after sampling a set of initial weights, we use the results from Appendix C to directly compute the posterior expectations for the RF model. By then averaging the resulting error across multiple samples of weights, we numerically verify our theoretical curves.

G.2 Neural network model

Theoretical predictions for the generalization error in a Bayesian Neural Network can be computed directly from equation (28). We then use the results from Appendix D to directly compute the error for particular instantiations of weights, numerically verifying our theoretical results.

References