TL;DR
A fully connected neural network with random weights computes a random function. Lee and colleagues showed that when every hidden layer is made infinitely wide, that random function becomes a Gaussian process, and they gave a recipe that computes its covariance (the kernel) one layer at a time. With that kernel, predicting new values is exact Bayesian regression, done with matrix algebra and no gradient training. On MNIST and CIFAR-10 the resulting Gaussian processes often matched or beat trained networks, and they gave an uncertainty estimate for every prediction.
Builds on: Gaussian Process Regression, Central Limit Theorem, Feedforward Neural Network · Leads to: Neural Tangent Kernel: Convergence and Generalization in Neural Networks, Bayesian Neural Network
Why it mattered
The equivalence was not new for a single hidden layer. Radford Neal had shown it in 1994, and Christopher Williams gave closed-form kernels for one-layer networks in 1997. The paper's contribution was the deep case, and it made the result usable. For a deep network, the kernel can be computed for any reasonable activation function, and the resulting Gaussian process is used for real prediction on image benchmarks, not just as a theory object.
The paper's numbers are the reason people kept reading it. The best Gaussian process on CIFAR-10 with 45,000 training images reached 0.5566 test accuracy with a ReLU kernel, above the best trained network at 0.5313 (Table 1 of the paper). The Gaussian process also reported an uncertainty for each test point, and that uncertainty tracked the actual error on those points (Figure 3). Later work on infinitely wide networks, including Neural Tangent Kernel: Convergence and Generalization in Neural Networks, built on the same idea that a wide network can be analysed as a kernel method.
The problem
Before this paper, a network trained by gradient descent had no tractable Bayesian treatment. Placing a prior over its weights and asking for the posterior over its outputs requires integrating over millions of parameters. A Gaussian process is different: it gives a prior over functions directly, and conditioning it on data is a short matrix calculation (see Gaussian Process Regression). So if a deep network could be shown to be a Gaussian process, Bayesian prediction would come for free.
Two things were missing. First, nobody had shown that the equivalence held for a deep stack of layers, where each layer's output feeds the next nonlinearity. Second, the kernels that existed for deep networks, such as the compositional kernels of Cho and Saul (2009) and Daniely and colleagues (2016), had been derived outside a Bayesian framework. They were not used as covariance functions of a Gaussian process for prediction. Deep Gaussian processes, which stack GPs, were a different object again: they are not the limit of a neural network.
How it works
The idea has two steps: a central limit argument for one layer, then an induction over layers. The walkthrough below uses one tiny instance, with two inputs in two dimensions and a ReLU activation.
- Set up the network. Take inputs . Each hidden unit computes a weighted sum of the previous layer's activations plus a bias, then applies a nonlinearity . Draw every weight and bias at random, with weight variance (where is the layer width) and bias variance . Check: with units feeding one output, each weight is small when the layer is wide.
- Let the width grow. One output of a layer is a sum of independent terms, so by the central limit theorem it becomes Gaussian as grows. Several inputs together give a joint Gaussian, which is exactly the definition of a Gaussian process. Check: the output at one input is a sum of many independent random pieces, the situation the theorem covers.
- Pass the covariance up one layer. The covariance of the next layer depends only on the covariance of the current one, through a fixed function. Tiny instance: take and , with , , , and ReLU. The input covariance is , and . Check: the two inputs are orthogonal, so their covariance is zero.
- Compute the next layer. The first hidden layer's pre-activations at the two inputs are independent Gaussians with variance 1. Their ReLU outputs have mean each, so . Check: the covariance is no longer zero, so the nonlinearity has created a link between the inputs.
- Repeat for every layer. Each layer's kernel is computed from the previous one, giving . The network's output, at any set of inputs, is then a Gaussian process with covariance .
- Predict. Condition the Gaussian process on training data with the standard GP regression formulas. For a test input, this gives a predicted mean and a predicted variance, which is the Bayesian answer for the infinitely wide network.
flowchart LR A[Inputs] --> B[Base kernel from inner products] B --> C[Layer kernel from previous layer] C --> D[Repeat for each layer] D --> E[Output kernel K at depth L] E --> F[GP regression on training data] F --> G[Mean and uncertainty at test inputs]
Two practical points follow from the walkthrough. The recursion is deterministic and differentiable, so the kernel depends only on the architecture and the variances and . And for some nonlinearities, such as ReLU, step 4 has a closed form; for others, the paper computes it numerically with a lookup table.
The math
A neural network Gaussian process is the distribution over functions that a fully connected network defines when its weights and biases are drawn independently from zero-mean Gaussians and every hidden layer width goes to infinity. For any finite set of inputs, the vector of outputs is multivariate Gaussian with mean zero and covariance , where is built by the recursion below.
Steps 1 and 2 in symbols
Write the network with pre-activations and post-activations . The layer map is
with drawn from a zero-mean Gaussian of variance and from one of variance . Here is the width of layer , and is the activation applied to each unit.
Since the and are independent across , the sum has independent terms. As the central limit theorem makes Gaussian, and jointly Gaussian across inputs. The covariance it has is
where is zero-mean Gaussian with variances and and covariance .
Step 3 in symbols: the recursion
Write for the expectation in step 2, so that
The base case uses the input inner product:
Step 4 in symbols: the ReLU closed form
For ReLU, , the expectation has a closed form, the arc-cosine kernel. With ,
Take , , , . Then .
- The inputs are identical, so and the cosine ratio is .
- So .
- Then and , so the bracket is .
- The prefactor is .
- Multiply: .
Interpretation: a ReLU layer with these variances keeps the squared norm of the input unchanged, so the diagonal of the kernel stays at 1.
Step 6 in symbols: the posterior
Let be the training inputs with targets , and let the observation noise have variance . Write for the training-by-training kernel matrix and for the row of test-to-training kernel values. Then the predictive distribution at a test input is Gaussian with
These are the same formulas as in Gaussian Process Regression, with the kernel of the deep network in place of a hand-picked one.
Suppose there is one training input with , a test input with and , noise , and target .
- The denominator is .
- The mean is .
- The variance is .
Interpretation: the prediction moves from the prior mean 0 to 1, which is a third of the way toward the target 3, because the noise variance of 1 is as large as the training kernel value and pulls the fit back. The variance drops from 2 to about 1.67, so the training point helps only a little.
Step 5 in symbols: depth
Applying the recursion times gives , the covariance of the network's output. Appendix C of the paper derives the same kernel by a different route, marginalising over the intermediate layers, and notes that the result does not depend on the order in which the widths go to infinity when the weights have Gaussian priors.
Results
Setup. The paper compares the NNGP with fully connected networks trained by gradient methods on MNIST and CIFAR-10. Training used mean squared error against one-hot targets, with the zero-mean encoding of for wrong classes and for the right class. The networks were trained with the Adam optimizer (Adam Optimizer, a variant of Stochastic Gradient Descent) and no dropout (Dropout). Their hyperparameters were chosen by random search, averaging about 250 trials for each choice of training size, depth, width and nonlinearity, and the Gaussian process hyperparameters were chosen from a grid of 900 points. MNIST used a 50,000/10,000/10,000 split (training, validation, test), and CIFAR-10 used 45,000/5,000/10,000.
Table 1 (selected rows, test accuracy). For the ReLU kernel:
| Training set | Best NNGP | Best trained network |
|---|---|---|
| MNIST, 1k | 0.9279 | 0.9252 |
| MNIST, 50k | 0.9875 | 0.9864 |
| CIFAR-10, 10k | 0.4780 | 0.4545 |
| CIFAR-10, 45k | 0.5566 | 0.5313 |
The paper's notation for the best settings is depth-width-- for networks and depth-- for Gaussian processes. The tanh columns follow the same pattern: the NNGP is ahead in all six tanh rows of the table, and in five of the six ReLU rows (the exception is MNIST with 10k training images, where the trained network leads, 0.9771 against 0.9765).
Uncertainty. The predicted variance at each test point was strongly correlated with the realised squared error (Figure 3), so the uncertainty is informative about where the model is wrong.
Width. Among 180 five-hidden-layer networks on CIFAR-10 (125 tanh and 55 ReLU after filtering for full training accuracy), the best generalising networks were consistently the widest (Figure 2). These networks were trained with cross entropy rather than MSE, so the comparison is not a like-for-like replay of the main experiments. Finite networks trained with SGD moved toward the NNGP result as width grew.
Depth and signal propagation. The paper connects performance to the way a random network's kernel changes with depth. For tanh there are two regimes, called ordered and chaotic, separated by a critical line in space. Near that line the kernel decays slowly with depth, and the NNGP performed best there (Figure 4). Far from it, the kernel converges to a constant, and the information in the data survives only as a tiny difference that can be lost to numerical precision at large depth.
Limits and misreadings
- It is a limit, not the same model. A finite network is not a Gaussian process. The paper's evidence is that finite networks approach the NNGP as width grows, which is a different claim from "every deep network is a GP".
- It is not learned features. The NNGP uses fixed basis functions set by the architecture and two variances. The paper notes that it found no salient advantage for learned features on these tasks, which is a surprising empirical observation and not a general law.
- It is regression. Classification was treated as least-squares regression on labels. The paper notes that Gaussian processes can be extended to softmax classification with cross entropy, and leaves that to future work.
- Cost. The posterior needs solving with an matrix, where is the training set size, so the cost grows fast with data. The paper handled 50,000 points and names scaling to larger data as future work.
- Open question. Whether SGD approximately implements Bayesian inference is left open by the paper.
Reading guide
- Introduction (section 1). Needs Central Limit Theorem and a Feedforward Neural Network. The contrast drawn with deep Gaussian processes needs no more.
- Section 2.1 and 2.2 (notation and the one-layer case). Needs Multivariate Gaussian and the kernel form of Gaussian Process Regression. The notation and is the variance of the weights and biases.
- Section 2.3 (induction over layers). Needs Kernel Function and Activation Function. The recursion in the math section above is equation 5.
- Section 2.4 (Bayesian training). Needs Posterior Distribution and the posterior formulas in Gaussian Process Regression.
- Section 2.5 (efficient implementation). Needs Cholesky Decomposition for the linear solves and Rectified Linear Unit (ReLU) for the closed form. The lookup table is a numerical integration.
- Section 3 (experiments). Needs Mean Squared Error and the training ideas in Stochastic Gradient Descent and Adam Optimizer.
- Section 3.2 and Appendix B. Need the idea of a fixed point of a recursion: a value the kernel approaches as depth grows. Appendix B gives the closed form of the ReLU step used in the math section above.
Check yourself
QuestionRecall: what does the central limit theorem contribute to the NNGP argument?Show answer
Each unit's output in a layer is a sum of many independent terms, one per unit of the previous layer. As the width goes to infinity, the central limit theorem makes that sum Gaussian, and the joint distribution across several inputs is Gaussian too. That joint Gaussian is the definition of a Gaussian process, so the network's function is a draw from a GP.
QuestionComputation: with one training point, , , , and target , what is the predictive mean?Show answer
With no noise, the denominator is just . The mean is . The variance is . Answer: the mean is 1.
QuestionWhy: in the tiny ReLU example, why is rather than zero even though ?Show answer
The zero covariance at the input means the two first-layer pre-activations are independent. But ReLU outputs are never negative, so each has a positive mean, . The next layer's pre-activations are weighted sums of these outputs, and the covariance is the uncentred product . Independence at one layer does not stop the next layer from being correlated, because the nonzero mean of the activations is shared.
QuestionApplied: a researcher uses the NNGP for a dataset where the predicted variance is large for a set of test points. What does that tell them?Show answer
The model is uncertain about those points given its prior and the training data. The paper found that this predicted variance correlates with the realised error, so those points are the ones most likely to be wrong, and they are candidates for a new label in active learning. The uncertainty does not say the model is correct about the points where it is confident, and it depends on the prior chosen through , and depth.
Sources
- Lee, Bahri, Novak, Schoenholz, Pennington, Sohl-Dickstein, "Deep Neural Networks as Gaussian Processes", arXiv:1711.00165, https://arxiv.org/abs/1711.00165
- Rasmussen and Williams, Gaussian Processes for Machine Learning (MIT Press, 2006), https://gaussianprocess.org/gpml/
- Gaussian process, Wikipedia, https://en.wikipedia.org/wiki/Gaussian_process