TL;DR
Jacot, Gabriel and Hongler show that a very wide, fully connected neural network trained by plain gradient descent can be described by one fixed kernel, the neural tangent kernel (NTK). The kernel is built from the network's depth, its nonlinearity and the scale of its starting weights. Because it stays fixed during training, the network's training becomes a kernel regression, and the question of what the network predicts on new inputs becomes a question about that kernel.
Builds on: Feedforward Neural Network, Gradient Descent, Kernel Function, Jacobian Matrix, Mean Squared Error · Leads to: Early Stopping, Kernel Ridge Regression
Why it mattered
Before 2018 two facts sat side by side with no bridge between them. A wide network at the start of training is a random function that behaves like a Gaussian process, and kernel methods such as kernel ridge regression were well understood. Training a network, however, was studied as a hard non-convex problem in weight space, and the authors said the dynamics of deep networks was still open.
The paper built the bridge. It showed that gradient descent on a wide network is a gradient descent in function space with respect to a kernel that is fixed in the limit. That gave researchers a set of tools that already worked for kernels, such as eigen-decompositions of Gram matrices, to study convergence and generalization of deep networks. Later work used the same picture to ask when gradient descent reaches zero training error in very wide networks, and why such networks predict well on test data. Its experiments include a batch of MNIST digits, where each image is a vector of 784 pixel values.
History
In 1994 Radford Neal showed that a one-hidden-layer network with random weights tends to a Gaussian process as its hidden layer grows. Around 2017 and 2018, follow-up work extended this to deep networks, including Lee and co-authors, whose "deep networks as Gaussian processes" paper describes the infinite-width limit at initialization. Jacot, Gabriel and Hongler then asked what happens during training, and showed that the kernel that governs the start also governs the whole trajectory. The paper was published at NeurIPS in 2018. It caught on because it turned a hard question about training into a question about kernels that researchers already knew how to analyse.
The problem
A network with two hidden layers of width 10,000 has about a hundred million parameters, since each pair of adjacent layers contributes their product in weights. Call the network function , where collects all weights and biases. The training cost depends on through a composition, and even when the cost is convex in the function itself, the composite cost is in general highly non-convex in . This is why the usual proofs of convergence for gradient descent do not apply directly.
Two questions follow. First, what does gradient descent do to the function values, both on the training inputs and at new inputs? Second, why do such over-parametrized networks fit random labels and still generalize on real data? The paper answers both by changing the coordinate system: it studies itself, in the space of functions, instead of .
How it works
-
Fix the network. Use layers to , with widths , a smooth nonlinearity , and weights and biases drawn independently from . The forward pass scales each weight matrix by and adds a bias scaled by a constant (the worked examples below use ). These scalings are what make the infinite-width limit well behaved.
-
A gradient step moves the output, and the size of the move depends on the pair of inputs. Changing parameter by a small amount changes the output at input by about times that amount. Adding up over all parameters, the change at caused by a training signal at is governed by
This is the NTK: a number for every pair of inputs. Tiny instance: take a network with no hidden layer, two inputs, , and . The derivatives are for each weight and for the bias, so . For this gives . Check: .
-
Make the network wide, and the kernel stops being random. The sum in step 2 has one term per parameter. In a wide layer there are many terms, each depending on a different random weight, and by the law of large numbers the sum settles to a fixed value. The NTK at initialization therefore converges to a deterministic kernel . This limit depends only on the depth, the nonlinearity and the variance of the starting weights, not on which random weights were drawn.
-
Compute the limit one layer at a time. A recursion gives for any depth. Each new layer adds the covariance of the outputs of that layer and multiplies the previous kernel by a derivative term. For a one-layer network the limit is exactly the kernel from step 2, so and for the two inputs above.
-
The kernel does not move during training. The paper proves that, as widths grow, stays equal to for all times in a window , as long as the total size of the training push over that window stays bounded. For least-squares training this bound holds. So the kernel frozen at initialization describes the whole run.
-
Training is kernel gradient descent. With a fixed kernel, the change in the function at any input is a weighted sum of the residuals at the training inputs, with weights given by the kernel. This is exactly the update of kernel regression trained by gradient flow. The network's function therefore moves along a straight, known path in function space.
-
Solve for least squares. Write the residual on the training inputs as . It decays along the eigen-directions of the Gram matrix of at rates set by the eigenvalues. Directions with large eigenvalues are fit first. In the long run the network interpolates the training points, and between them it predicts the kernel interpolant, plus a leftover term that vanishes on the training data.
flowchart LR A["Random weights at initialization"] --> B["Network function f, a random function"] B --> C["Each step changes f at every input"] C --> D["Kernel Theta: how two inputs move together"] D --> E["Wide limit: Theta becomes fixed Theta-infinity"] E --> F["Training is kernel gradient descent on f"]
The rates in step 7 are easy to see. Take illustrative top eigenvalues , and , of the size a kernel on a batch of digits can have. These are not measured values from the paper. Each component of the residual along eigenvector shrinks like :
- lambda 1 = 0.0457
- lambda 2 = 0.00108
- lambda 3 = 0.00078
The math
Setup: the NTK and the training flow (step 2 in symbols)
Take a scalar output, so . Given training inputs with targets , the squared cost is
Gradient flow changes each parameter by . The chain rule gives the change of the function at any input :
The bracketed sum is the NTK, so
The paper divides the cost by the number of data points, which only rescales time. The structure is the same.
Step 3 in symbols: the limiting kernel
Let , and for each further layer
Here is a pair of values that are jointly Gaussian with covariance evaluated at , and is the derivative of . The limiting NTK is
The second summand is the learning done by the last layer. The first summand is the learning done by the layers below it. This matches the paper's remark that the two parts play different roles.
Step 4 in symbols: the frozen kernel
The paper's Theorem 2 says that the kernel stays close to over a window when the total size of the training push over that window stays bounded, where is the training direction. For the least-squares cost, is the residual, and its norm decreases during training, so the condition holds.
Step 5 in symbols: training with a fixed kernel and its solution (step 7 in words)
Let be the Gram matrix with entries , and let be the vector of residuals . Integrating the flow from step 2 with the frozen kernel gives
If with orthonormal eigenvectors , then the component of along is multiplied by . Large means fast fitting.
If is invertible, then . Integrating the function update over time gives the limit at any input , with :
The first term is the kernel interpolant of the targets. The second term is the leftover of the random initial function, and it vanishes on the training inputs. The paper shows that the first term is also the kernel ridge regression solution as the regularisation goes to zero.
Worked examples
Use the network from step 2: , , .
- Write the derivatives. and .
- Form the NTK as the sum over parameters: .
- Take and . The dot product is , so . The two inputs barely move each other.
- Take . The dot product is , so .
- Check against the limit: . It agrees with step 4.
Suppose the frozen kernel on two training inputs has Gram matrix , and the starting residual is . We want .
- Find the eigenvalues. Solving gives , so or .
- Find the eigenvectors. For , take . For , take .
- Expand the starting residual. . In normalised form that is .
- Apply the decay. The part is multiplied by and the part by . At the factors are and .
- Put the parts back together. .
- Compute the two entries. The first entry is . The second is . So .
- Interpret. The residual on the first point dropped from to about , and the second point moved away from to about . The fast direction has nearly died out; the slow direction is still doing most of the work. Since is invertible, the residual reaches as grows.
Take a batch of MNIST digits, each a vector of pixels, and a kernel whose top eigenvalues are the illustrative and . Suppose the residual starts exactly along the second eigen-direction with size , so the first direction starts at zero.
- Write the residual along the second component. It starts at and evolves as .
- Pick a time. Run for steps at learning rate , so one step is one unit of .
- Compute the exponent. .
- Compute the exponential. .
- Multiply by the starting size. .
- Interpret. After 1000 steps the component along the second principal direction has shrunk from to about . A direction with would shrink by a factor of about in the same time, which is zero for practical purposes. So the fast, large-eigenvalue directions are fitted first. This is the early-stopping picture.
Try it: how many steps at learning rate until the second-component residual is 1 percent of its starting size, ignoring the first component?
Answer: we need , so steps.
Results
The two theorems are the main results. Theorem 1 says that as the hidden widths grow, the NTK at initialization converges in probability to the deterministic kernel . Theorem 2 says the kernel stays at throughout training, for any training direction whose total size stays bounded. Proposition 2 says the restriction of to the unit sphere is positive definite when the network has at least two layers and the nonlinearity is not a polynomial, which is what makes gradient descent converge to a global minimum in this setting.
The experiments check these claims at finite width, with small networks and small datasets.
- Convergence of the NTK. Fully connected networks on low-dimensional inputs at several widths. The kernel changes during training at narrow widths and much less at wide ones.
- Kernel regression. A few training points, with the network's outputs compared with the Gaussian limit given by the kernels. The match improves with width.
- Convergence along a principal component. On a batch of MNIST digits, the kernel's top eigenvalues differ sharply, and wider networks follow the predicted trajectory along a secondary component more closely. The limits are important. The proofs take the widths to infinity one layer at a time. The positive-definiteness result is proved only on the sphere and only for at least two layers. The experiments are small: a two-dimensional toy dataset and a batch of 512 digits. At finite width the kernel drifts during training, so finite networks depart from the limit in ways the frozen-kernel theory does not describe.
Limits, common misreadings and tradeoffs
It is tempting to think the NTK is a property of a trained network. In fact, for a finite network it is random at initialization and changes during training. Only the infinite-width limit is fixed. The drift shrinks as the width grows, which is what the theory predicts.
It is tempting to think the kernel is learned from the data. In fact depends only on the depth, the nonlinearity and the variance of the initial weights. The data enter only when the kernel is evaluated on the training and test inputs. The features do not adapt the way a learned representation does.
It is tempting to think that comparing convergence speed by number of steps is fair across widths. In fact multiplying the kernel by a constant is the same as multiplying the learning rate by that constant. So a network with a larger kernel scale fits faster at the same learning rate, and convergence speeds have to be compared with the kernel scale taken into account.
When to use the NTK picture: to reason about convergence, about where early stopping helps, and about what a very wide network predicts. When not to use it: for finite networks whose hidden features change a lot during training, since the frozen-kernel picture cannot describe that change. Alternatives include analyses of finite-width corrections and the Gaussian-process view, which describes only the function at initialization.
Reading guide
- The introduction: the open problem and the infinite-width picture. Read it with Gaussian process regression in mind.
- The network setup: the architecture and the scaling. Needs Feedforward Neural Network, Activation Function and Xavier (Glorot) Initialization, which is the usual scale-control idea.
- The function-space view: needs Kernel Function, Gradient Descent and Positive Definite Matrix. Random-feature comparisons use Covariance Matrix.
- The neural tangent kernel: the definition and the limit. Needs Jacobian Matrix, Chain Rule, Backpropagation and Gaussian (Normal) Distribution. The positivity result uses Lipschitz Continuity and Positive Definite Matrix.
- The least-squares analysis: the training solution. Needs Mean Squared Error, Eigenvalues and Eigenvectors, Matrix Exponential, Ordinary Differential Equation and Kernel Ridge Regression.
- The experiments: read the figures with Principal Component Analysis and Early Stopping in mind.
- The proofs: they use the chain rule and the Law of Large Numbers for the width limit. Read them after the definition of the kernel.
Recap and what to read next
- A network's output moves during gradient descent in a direction set by the NTK, a kernel built from the derivatives of the output with respect to the parameters.
- As width grows, the NTK settles on a deterministic kernel that depends only on depth, nonlinearity and initial weight scale, and it stays fixed during training.
- So training is kernel gradient descent in function space, and residuals decay along the eigen-directions of the kernel, the largest first.
- Consequence: early stopping favours the large-eigenvalue, smooth components, and the limiting network is the kernel interpolant.
Read next: kernel ridge regression, which the paper identifies with the limit of its solution as regularisation goes to zero, and Gaussian process regression, the source of the infinite-width picture at initialization.
Check yourself
QuestionRecall: what is the NTK built from, and what does it measure?Show answer
QuestionComputation: a one-layer network has and . What is its NTK at with itself?Show answer
QuestionWhy: why are the factors in the forward pass needed?Show answer
QuestionApplied: a wide network is trained with a small number of steps and stopped early. Which part of the target does it fit first, the smooth large-eigenvalue part or the noisy small-eigenvalue part?Show answer
Sources
- Arthur Jacot, Franck Gabriel, Clément Hongler, "Neural Tangent Kernel: Convergence and Generalization in Neural Networks", arXiv:1806.07572. https://arxiv.org/abs/1806.07572
- Jaehoon Lee and co-authors, "Deep Neural Networks as Gaussian Processes", arXiv:1711.00165. https://arxiv.org/abs/1711.00165