Implicit Regularization of Random Feature Models
Arthur Jacot, Berfin Şimşek, Francesco Spadaro, Clément Hongler, Franck Gabriel
Introduction
In this paper, we consider the Random Feature (RF) model which is an approximation of Kernel Methods (Rahimi & Recht, 2008) which has seen many recent theoretical developements.
The conventional wisdom suggests that to ensure good generalization performance, one should choose a model class that is complex enough to learn the signal from the training data, yet simple enough to avoid fitting spurious patterns therein (Bishop, 2006). This view has been questioned by recent developments in machine learning. First, Zhang et al. (2016) observed that modern neural network models can perfectly fit randomly labeled training data, while still generalizing well. Second, the test error as a function of parameters exhibits a so-called ‘double-descent’ curve for many models including neural networks, random forests, and random feature models (Advani & Saxe, 2017; Spigler et al., 2018; Belkin et al., 2018; Mei & Montanari, 2019; Belkin et al., 2019; Nakkiran et al., 2019).
The above models share the feature that for fixed input, the learned predictor is random: for neural networks, this is due to the random initialization of the parameters and/or to the stochasticity of the training algorithm; for random forests, to the random branching; for random feature models, to the sampling of random features. The somehow surprising generalization behavior of these models has recently been the subject of increasing attention. In general, the risk (i.e. test error) is a random variable with two sources of randomness: the usual one due to the sampling of the training set, and the second one due to the randomness of the model itself.
We consider the Random Feature (RF) model (Rahimi & Recht, 2008) with features sampled from a Gaussian Process (GP) and study the RF predictor minimizing the regularized least squares error, isolating the randomness of the model by considering fixed training data points. RF models have been the subject of intense research activity: they are (randomized) approximations of Kernel Methods aimed at easing the computational challenges of Kernel Methods while being asymptotically equivalent to them (Rahimi & Recht, 2008; Yang et al., 2012; Sriperumbudur & Szabó, 2015; Yu et al., 2016). Unlike the asymptotic behavior, which is well studied, RF models with a finite number of features are much less understood.
We consider a model of Random Features (RF) approximating a kernel method with kernel . This model consists of Gaussian features, sampled i.i.d. from a (centered) Gaussian process with covariance kernel . For a given training set of size , we study the distribution of the RF predictor with ridge parameter ( penalty on the parameters) and denote it by -RF. We show the following:
The distribution of is that of a mixture of Gaussian processes.
2 Related works
Generalization of Random Features. The generalization behavior of Random Feature models has seen intense study in the Statistical Learning Theory framework. Rahimi & Recht (2009) find that features are sufficient to ensure the decay of the generalization error of Kernel Ridge Regression (KRR). Rudi & Rosasco (2017) improve on their result and show that features is actually enough to obtain the decay of the KRR error.
Hastie et al. (2019) use random matrix theory tools to compute the asymptotic risk when both with . When the training data is sampled i.i.d. from a Gaussian distribution, the variance is shown to explode at . In the same linear regression setup, Bartlett et al. (2019) establish general upper and lower bounds on the excess risk. Mei & Montanari (2019) prove that the double-descent (DD) curve also arises for random ReLU features, and adding a ridge suppresses the explosion around .
Double-descent and the effect of regularization. For the cross-entropy loss, Neyshabur et al. (2014) observed that for two-layer neural networks the test error exhibits the double-descent (DD) curve as the network width increases (without regularizers, without early stopping). For MSE and hinge losses, the DD curve was observed also in multilayer networks on the MNIST dataset (Advani & Saxe, 2017; Spigler et al., 2018). Neal et al. (2018) study the variance due to stochastic training in neural networks and find that it increases until a certain width, but then decreases down to . Nakkiran et al. (2019) establish the DD phenomenon across various models including convolutional and recurrent networks on more complex datasets (e.g. CIFAR-10, CIFAR-100).
Belkin et al. (2018, 2019) find that the DD curve is not peculiar to neural networks and observe the same for random Fourier features and decision trees. In Geiger et al. (2019), the DD curve for neural networks is related to the variance associated with the random initialization of the Neural Tangent Kernel (Jacot et al., 2018); as a result, ensembling is shown to suppress the DD phenomenon in this case, and the test error stays constant in the overparameterized regime. Recent theoretical work (d’Ascoli et al., 2020) study the same setting and derive formulas for the asymptotic error, relying on the so-called replica method.
3 Outline
The rest of this paper is organized as follows:
In Section 2, the setup (linear regression, Gaussian RF model, -RF predictor, and -KRR predictor) is introduced.
In Section 3, preliminary results on the distribution of the -RF model are provided: the RF predictors are Gaussian mixtures (Proposition 3.1) and the -RF model is unbiased in the overparameterized regime (Corollary 3.2). Graphical illustrations of the RF predictors in various regimes are presented (Figure 1).
In Section 6, we summarize our results and discuss potential implications and extensions.
Setup
Linear regression is a parametric model consisting of linear combinations
The data matrix is defined as the matrix with entries . The minimization of (1) can be rewritten in terms of as
The optimal solution is then given by
and the optimal predictor by
The -RF can be viewed as an approximation of kernel ridge predictors: observing from (4) that only depends on the scalar product between datapoints, we see that as , and hence converges (Rahimi & Recht, 2008) to a kernel predictor with ridge (Schölkopf et al., 1998), which we call -KRR predictor.
Let denote the joint distribution of the i.i.d. sample from the centered Gaussian process with covariance kernel . The risk of can be decomposed into a bias-variance form as
This decomposition into the risk of the average RF predictor and of the -expectation of its variance will play a crucial role in the next sections. This is in contrast with the classical bias-variance decomposition in Geman et al. (1992)
where denotes the joint distribution on , sampled i.i.d. from . Note that in our decomposition no probabilistic assumption is made on the data, which is fixed.
2 Additional Notation
We will denote by the parameter-to-datapoint ratio: the underparameterized regime corresponds to , while the overparameterized regime corresponds to . In order to stress the dependence on the ratio parameter , we write instead of .
First Observations
The distribution of the RF predictor features a variety of behaviors depending on and , as displayed in Figure 1. In the underparameterized regime , sample RF predictors induce some implicit regularization and do not interpolate the dataset (1a); at the interpolation threshold , RF predictors interpolate the dataset but the variance explodes when there is no ridge (1b), however adding some ridge suppresses variance explosion (1c); in the overparameterized regime with large , the variance vanishes thus the RF predictor converges to its average (1d). We will investigate the average RF predictor (solid lines) in detail in Section 4 and study its variance in Section 5.
We start by characterizing the distribution of the RF predictor as a Gaussian mixture:
Let be the random features predictor as in (5) and let be the prediction vector on training data, i.e. . The process is a mixture of Gaussians: conditioned on , we have that is a Gaussian process. The mean and covariance of conditioned on are given by
The proof of Proposition 3.1 relies on the fact that conditioned on is a Gaussian Process.
Note that (6) and (7) depend on and through and ; in fact, as the proof shows, these identities extend to the ridgeless case . For the ridgeless case, when one is in the overparameterized regime (), one can (with probability one) fit the labels and hence :
When , the average ridgeless RF predictor is equivalent to the ridgeless KRR predictor
This corollary shows that in the overparameterized case, the ridgeless RF predictor is an unbiased estimator of the ridgeless kernel predictor. The difference between the expected loss of ridgeless RF predictor and that of the ridgeless KRR predictor is hence equal to the variance of the RF predictor. As will be demonstrated in this article, outside of this specific regime, a systematic bias appears, which reveals an implicit regularizing effect of random features.
Average Predictor
(Sketch; see Supp. Mat. for details) Set . The vector of the predictions on the training set is given by and the expected predictor is given by
with denoting the -th column of and being obtained by removing the -th row of . The ’s are all within distance to the Stieltjes transform
(The detailed proof in the Supp. Mat. uses non-asymptotic variants of arguments found in (Bai & Wang, 2008); the constants in the bounds are in particular made explicit).
As a consequence, from the above results, we obtain
Note that asymptotic forms of equations similar to the ones in the above proof appear in different settings (Dobriban & Wager, 2018; Mei & Montanari, 2019; Liu & Dobriban, 2020), related to the study of the Stieltjes transform of the product of asymptotically free random matrices.
The boundedness of is guaranteed for kernels that are translation-invariant, i.e. of the form : in this case, one has .
For , under the assumption that the labels are of the form for a true regression function lying in Reproducing Kernel Hilbert Space (RKHS) of the kernel (Schölkopf et al., 1998), we have .
2 Risk of the Average Predictor
Variance
The following theorem allows us to bound both terms:
There are constants depending on only such that
where depends on .
2 Double Descent Curve
We now investigate the neighborhood of the frontier between the under- and overparameterized regimes, known empirically to exhibit a double descent curve, where the test error explodes at (i.e. when ) as exhibited in Figure 3.
Thanks to Theorem C.3.3, we get a lower bound on the variance of :
Conclusion
Both theorems are proven using tools from random matrix theory, in particular finite-size results on the concentration of the Stieltjes transform of general Wishart matrix models. While our current proofs require the assumption that the RF model is Gaussian, it seems natural to postulate that the results and the proofs extend to more general setups, along the lines of (Louart et al., 2017; Benigni & Péché, 2019).
Finally, we investigate the ridgeless limit case . In this case, we see a sharp transition at : in the overparameterized regime , the effective ridge goes to zero, while in the underparameterized regime , it converges to a positive value. At the interpolation threshold , the variance of the -RF explodes, leading to the double descent curve emphasized in (Advani & Saxe, 2017; Spigler et al., 2018; Belkin et al., 2018; Nakkiran et al., 2019). We investigate this numerically and prove a lower bound yielding a plausible explanation for this phenomenon.
Thanks and Acknowledgements
The authors would like to thank Andrea Montanari, Song Mei, Lénaïc Chizat and Alessandro Rudi for the helpful discussions. Clément Hongler acknowledges support from the ERC SG CONSTAMIS grant, the NCCR SwissMAP grant, the Minerva Foundation, the Blavatnik Family Foundation, and the Latsis foundation.
References
Appendix A Experimental Details
Using the procedure above, we performed the following experiments:
A.2 MNIST experiments
A.3 Random Fourier Features
Appendix B Additional Experiments
We present the following complementary simulations:
In Section B.1, we present the distribution of the -RF predictor for the selected and .
In Section B.4, we present numerical experiments on MNIST using random Fourier features.
B.4 Average Fourier Features Predictor
The difference of the test errors of the two predictors decreases as increases.
For , strong agreement between the two test errors is observed already for . We also observe that Gaussian features achieve lower (or equal) test error than the Fourier features for all in our experiments.
Appendix C Proofs
Let be the -RF predictor and let be the prediction vector on training data, i.e. . The process is a mixture of Gaussians: conditioned on , we have that is a Gaussian process. The mean and covariance of conditioned on are given by
Let be the matrix of values of the random features on the training set. By definition, . Conditioned on the matrix , the optimal parameters are not random and is still Gaussian, hence, conditioned on the matrix , the process is a mixture of Gaussians. Moreover, conditioned on the matrix , for any , and remain independent, hence
C.2 Generalized Wishart Matrix
Setup. In this section, we consider a fixed deterministic matrix of size which is diagonal positive semi-definite, with eigenvalues . We also consider a random matrix with i.i.d. standard Gaussian entries.
where is a fixed positive semi-definite matrix.
Our first lemma implies that the Stieljes transform concentrates around its mean as and go to infinity with fixed.
where depends on , , and only.
is a rank one perturbation of the matrix , by the Sherman–Morrison’s formula, the inverse of is given by:
where we used the cyclic property of the trace. We can now bound this difference:
where are the eigenvalues of .
is a martingale difference sequence. Hence, by Burkholder’s inequality, there exists a positive constant such that
The following lemma, which is reminiscent of Lemma 4.5 in (Au et al., 2018), is a consequence of Wick’s formula for Gaussian random variables and is key to prove Lemma C.4.
If are square random matrices of size independent from a standard Gaussian vector of size ,
where is the subset of partitions in for which is not a block of for any .
Expanding the left-hand side of Equation (12), we obtain:
hence, interchanging the order of summation, we recover the left-hand side of Equation (12):
We now prove Equation (13). Expanding the product, the left-hand side is equal to:
Expanding the product and the trace, and using Wick’s equation, we obtain: a
where is the partition composed of blocks of size given by with and the rest of the indices contained in a single block. Interchanging the order of summation, we get:
Since and if and only if , interchanging a last time the order of summation, we recover the left-hand side of Equation (13):
The random function satisfies:
where , , , and depend on and only.
Thus, the variance of is given by:
We bound the second term using the concentration of the Stieljes transform (Lemma C.2): it is bounded by . The first term is bounded using the second assertion of Lemma C.3. Using the symmetry of , the partitions in yield two different terms, namely:
In the next proposition we show that the Stieltjes transform is close in expectation to the solution of a fixed point equation.
From the proof of Lemma C.2, recall that hence:
Thus, the Stieljes transform satisfies the following equation or equivalently
To prove that we proceed with a geometrical reasoning: the image is (one of) the region of the plane confined by , so we only need to “draw” and show that belongs to the “good” connected component confined by it.
We observe that, for every , the derivative of has negative real part:
where we concluded the last inequality by using that , , and . Thus, since for no point has , any fixed point of is a simple fixed point.
We now proceed to show the uniqueness of the fixed point in the region . Suppose there are two fixed points and , then
We provide a lower bound on the norm of the fixed point:
C.3 Ridge
Note that the matrix defined in the proof sketch of Theorem 4.1 in the main text is given by .
Since the distribution of is invariant under orthogonal transformations, by applying a change of basis, in order to prove Inequality (17), we may assume that is diagonal with diagonal entries . Denoting the columns of , for any ,
Consider a diagonal term . From Equation (15), we get
For the second term, using the same arguments as for the proof of Proposition C.5, we have:
For a general vector , the -norm is equal to the norm mininum Hilbert norm (for the RKHS associated to the kernel ) interpolating function:
Indeed the minimal interpolating function is the kernel regression given by which has norm (writing ):
We can now bound the two norms and . For , we have
since is an interpolating function for .
Hence, if is the true function, by the triangular inequality,
C.3.2 Properties of the effective ridge
Differentiating both sides of Equation (20),
C.3.3 Variance of the predictor
This section is dedicated to the proof of the variance bound of Theorem 5.1 of the paper:
Theorem 5.1 There are constants depending on only such that
where depends on .
Let us now consider the second term in the r.h.s. of (23) . Using the fact that , we get
where we have used the fact that the second moment of a distribution is Together, we obtain
There exists a constant (depending on only) such that the variance of the estimator is bounded by
As in the proof of Theorem C.8, with the right change of basis, we may assume the Gram matrix to be diagonal.
We first express the covariances of . Using Proposition Proposition C.12, for we have
and let the diagonal matrix with entries
which implies that . As a result
where we used Inequality (21). This yields the result with .∎
For there exists a constant depending on only such that
As in the proof of Theorem C.8, with the right change of basis, we may assume the Gram matrix to be diagonal. Recall that , thus we have:
where is the derivative of
with respect to evaluated at . Let
where depends on .
Using the bias/variance decomposition, Corollary C.9, and the bound on the variance of the predictor, we obtain