VerifiedarXiv:1806.0757231 min
Theory · Training dynamics

Neural Tangent Kernel: Convergence and Generalization in Neural Networks

As a network gets wider, gradient descent moves its outputs through a kernel that stays fixed, so an infinitely wide network trains like kernel regression.

The paper defines the neural tangent kernel, the dot product of two inputs' parameter gradients, which sets how much a gradient step on one example changes the prediction on another. In the infinite-width limit this kernel is the same for every random initialization and does not change during training, so under a squared-error loss the network's outputs follow a linear equation that can be solved exactly.

Explaining the paperNeural Tangent Kernel: Convergence and Generalization in Neural NetworksJacot, Gabriel, Hongler · NeurIPS 2018 · arXiv:1806.07572 ↗

A 2018 theory paper from EPFL and Imperial College: two theorems about networks whose hidden layers grow without bound, checked on points of a circle and on 512 MNIST digits.

Arthur Jacot, Franck Gabriel and Clément Hongler study fully connected networks trained by gradient descent and ask what the trained network computes, which the non-convex loss surface had kept out of reach. Their answer holds in a limit, every hidden layer infinitely wide, and in that limit it is exact. The page covers, in order:

  1. the tangent kernel: how one gradient step on one example moves predictions on every other input;
  2. kernel gradient descent, the paper's way of describing training in function space;
  3. the 1/√n parametrization and the two theorems: the kernel becomes deterministic, then stops moving;
  4. the least-squares solution, which fits the kernel's top principal components first;
  5. what a trained infinitely wide network converges to, and what the result leaves unexplained.

What happens to the function during training

A network with parameter vector θ\theta computes a function fθf_\theta. Gradient descent moves θ\theta, but the quantity anyone cares about is the function: what the network outputs on a training example, and on inputs it has never seen. The map from θ\theta to fθf_\theta is highly nonlinear, so the loss as a function of θ\theta has saddle points and many minima, and nothing guarantees that gradient descent finds a good one.

The same loss written as a function of ff is simple. Least squares on NN examples is a convex bowl in the NN numbers f(x1),…,f(xN)f(x_1), \dots, f(x_N). The difficulty is that gradient descent cannot move those numbers directly; it can only move θ\theta, and each parameter step drags the whole function along with it, on training inputs and test inputs alike, by amounts the neural tangent kernel measures.

Earlier work describes the network before training. Neal (1996) showed that a one-hidden-layer network with random weights becomes a Gaussian process as its width goes to infinity: its output at any finite set of inputs is jointly Gaussian, with a covariance (a kernel) determined by the architecture. Lee et al. and Matthews et al. extended this to deep networks in 2018. This paper asks what happens to that random function once gradient descent starts moving it.

How the tangent kernel works

Take one gradient step on one training example (xj,yj)(x_j, y_j) with loss 12(f(xj)−yj)2\tfrac12 (f(x_j) - y_j)^2. Write r=f(xj)−yjr = f(x_j) - y_j for the residual. The step changes each parameter by Δθp=−η r ∂f(xj)/∂θp\Delta\theta_p = -\eta\, r\, \partial f(x_j)/\partial\theta_p, where η\eta is the learning rate. To first order in η\eta, the output at any other input xx changes by the sum over parameters of (how much f(x)f(x) depends on θp\theta_p) times (how much θp\theta_p moved):

Δf(x)≈∑p∂f(x)∂θp Δθp=−η r Θ(x,xj)\Delta f(x) \approx \sum_{p} \frac{\partial f(x)}{\partial \theta_p}\,\Delta\theta_p = -\eta\, r\, \Theta(x, x_j)Δf(x)≈∑p∂f(x)∂θp Δθp=−η r Θ(x,xj)\begin{aligned} \Delta f(x) &\approx \sum_{p} \frac{\partial f(x)}{\partial \theta_p}\,\Delta\theta_p \\ &= -\eta\, r\, \Theta(x, x_j) \end{aligned}
(1)

where

Θ(x,x′)=∑p=1P∂fθ(x)∂θp ∂fθ(x′)∂θp\Theta(x, x') = \sum_{p=1}^{P} \frac{\partial f_\theta(x)}{\partial \theta_p}\, \frac{\partial f_\theta(x')}{\partial \theta_p}
(2)

is the neural tangent kernel: the dot product of the two inputs' gradient vectors, each of length PP, the number of parameters. (For networks with several outputs it is an nL×nLn_L \times n_L matrix per pair of inputs; the paper writes it as a sum of tensor products ∂θpF⊗∂θpF\partial_{\theta_p} F \otimes \partial_{\theta_p} F. This page uses one output, as the paper's experiments do.) Read Θ(x,xj)\Theta(x, x_j) as how far the output at xx moves, per unit of learning rate and residual, when a step pushes the output at xjx_j. A large positive value means the two inputs share parameters that both outputs depend on in the same direction; a negative value means a push at xjx_j pulls xx down.

A linear model makes this exact. Take f(x)=θ1+θ2xf(x) = \theta_1 + \theta_2 x. The gradient with respect to the parameters is (1,x)(1, x), so Θ(x,x′)=1+xx′\Theta(x, x') = 1 + x x', the same for every θ\theta. Start at θ=(0,0)\theta = (0, 0), train on the single point xj=2x_j = 2, yj=3y_j = 3, with η=0.1\eta = 0.1. The residual is r=−3r = -3, the step is Δθ=0.1⋅3⋅(1,2)=(0.3,0.6)\Delta\theta = 0.1 \cdot 3 \cdot (1, 2) = (0.3, 0.6), and the new function is 0.3+0.6x0.3 + 0.6x. At x=2x = 2 it rose by 1.5, which is 0.1⋅3⋅Θ(2,2)0.1 \cdot 3 \cdot \Theta(2, 2) with Θ(2,2)=5\Theta(2,2) = 5. At x=−1x = -1 it fell by 0.3, which is 0.1⋅3⋅Θ(−1,2)0.1 \cdot 3 \cdot \Theta(-1, 2) with Θ(−1,2)=−1\Theta(-1, 2) = -1.

For a network, (1) holds only to first order, and the kernel itself depends on θ\theta: the gradients in (2) are evaluated at the current parameters, so every step changes them. Figure 1 runs this on a real network. Its inputs are points on the unit circle, x=(cos⁡γ,sin⁡γ)x = (\cos\gamma, \sin\gamma), so a function of xx can be drawn as a curve over the angle γ\gamma. The network has two ReLU hidden layers of width nn and one output; at n=100n = 100 it has 10,501 parameters, at n=1000n = 1000, 1,005,001. Watch the bottom panel, where the actual change in the function after one gradient step is drawn over the prediction of (1) computed from the network's own kernel.

Figure 1 · one gradient step, seen in function space
100
1.0
Drag in the top panel to place the training target at any angle and height. The network takes one gradient step on that single point; the teal curves are the function after the step and the actual change, the dashed amber curve is the change predicted by (1). The step slider sets η·Θ(xⱼ, xⱼ): at 1 the linear prediction lands exactly on the target. Change the width and compare the gap readout.

At the default setting (width 100, training input at 46°, target 0.5 above the current output, step size chosen so that (1) predicts landing exactly on the target), the network's own kernel gives Θ(xj,xj)=0.401\Theta(x_j, x_j) = 0.401, the learning rate is η=1/0.401=2.49\eta = 1/0.401 = 2.49, and the output at xjx_j moves from 0.479 to 0.971 against a predicted 0.979. Across the circle the largest gap between the actual and predicted change is 5.3% of the largest predicted change. At width 10 the gap is 22%; at width 1000 it is 1.1%. Two things are visible. The change has the shape of the kernel column Θ(⋅,xj)\Theta(\cdot, x_j), a bump centred on the training input that decays with angular distance, so one example moves the network's output on nearby inputs most and on distant ones much less. And the first-order picture gets more accurate as the width grows, at a fixed step size. Pushing the step slider to 2 doubles the step and shows the second-order error growing with it.

Kernel gradient descent

Summing (1) over all training examples and letting the learning rate go to zero turns gradient descent into a differential equation in training time tt (with learning rate η\eta, step kk corresponds to t=ηkt = \eta k; the paper's experiments use η=1\eta = 1, so tt counts steps). For a cost CC that depends on the function only through its values at the training inputs, write d(xj)d(x_j) for NN times the derivative of the cost with respect to the output f(xj)f(x_j) (for a cost that averages over the NN examples, this cancels the average's 1/N1/N). The paper shows the network function then evolves as

∂tft(x)=−1N∑j=1NΘ(x,xj) dt(xj)\partial_t f_t(x) = -\frac{1}{N}\sum_{j=1}^{N} \Theta(x, x_j)\, d_t(x_j)
(3)

and calls the right-hand side, with any kernel KK in place of Θ\Theta, the kernel gradient −∇KC-\nabla_K C. For least squares, C(f)=12N∑j(f(xj)−yj)2C(f) = \frac{1}{2N}\sum_j (f(x_j) - y_j)^2 and dt(xj)=ft(xj)−yjd_t(x_j) = f_t(x_j) - y_j, the residual. Equation (3) says the training signal lives only on the NN training inputs, and the kernel spreads it to every other input. Predictions on test inputs are therefore whatever the kernel carries over from the training residuals.

Along this flow the cost falls at a rate set by the kernel:

∂tC(ft)=−1N2∑i,jdt(xi) Θ(xi,xj) dt(xj)=−∥dt∥Θ2\partial_t C(f_t) = -\frac{1}{N^2}\sum_{i,j} d_t(x_i)\, \Theta(x_i, x_j)\, d_t(x_j) = -\lVert d_t \rVert_\Theta^2∂tC(ft)=−1N2∑i,jdt(xi) Θ(xi,xj) dt(xj)=−∥dt∥Θ2\begin{aligned} \partial_t C(f_t) &= -\frac{1}{N^2}\sum_{i,j} d_t(x_i)\, \Theta(x_i, x_j)\, d_t(x_j) \\ &= -\lVert d_t \rVert_\Theta^2 \end{aligned}
(4)

If the N×NN \times N Gram matrix Θ(xi,xj)\Theta(x_i, x_j) is positive definite, the right side is strictly negative until the cost gradient on the data is zero. A convex cost bounded below, such as least squares, then converges to its global minimum. The non-convexity in parameter space does not enter, provided the kernel stays positive definite while training runs. For a finite network the proviso is not automatic, because Θ\Theta changes with θ\theta as training runs.

Section 3.1 of the paper gives a model where the kernel does not change. Draw PP random functions f(1),…,f(P)f^{(1)}, \dots, f^{(P)} whose covariance is a target kernel KK, and fit only their linear combination

fθ(x)=1P∑p=1Pθpf(p)(x)f_\theta(x) = \frac{1}{\sqrt{P}}\sum_{p=1}^{P} \theta_p f^{(p)}(x)
(5)

(the random-features model of Rahimi and Recht, 2007). The gradient with respect to θp\theta_p is f(p)(x)/Pf^{(p)}(x)/\sqrt{P}, independent of θ\theta, so the tangent kernel is K~(x,x′)=1P∑pf(p)(x)f(p)(x′)\tilde K(x, x') = \frac1P\sum_p f^{(p)}(x) f^{(p)}(x') for the whole of training. It is random, because the features are, but it is an average of PP independent terms, and by the law of large numbers it converges to KK as P→∞P \to \infty. Gradient descent on this model is kernel gradient descent with a kernel close to KK. The paper's main theorems say a deep network behaves like this model as its width grows, although its features are not fixed and its parameters enter nonlinearly.

The 1/√n parametrization

The paper uses layers numbered 0 (input) to LL (output) with widths n0,…,nLn_0, \dots, n_L, a nonlinearity σ\sigma applied entrywise, and writes each layer as

α~(ℓ+1)(x)=1nℓ W(ℓ)α(ℓ)(x)+β b(ℓ),α(ℓ)=σ(α~(ℓ))\tilde\alpha^{(\ell+1)}(x) = \frac{1}{\sqrt{n_\ell}}\, W^{(\ell)} \alpha^{(\ell)}(x) + \beta\, b^{(\ell)}, \qquad \alpha^{(\ell)} = \sigma(\tilde\alpha^{(\ell)})α~(ℓ+1)(x)=1nℓ W(ℓ)α(ℓ)(x)+β b(ℓ),α(ℓ)=σ(α~(ℓ))\begin{gathered} \tilde\alpha^{(\ell+1)}(x) = \frac{1}{\sqrt{n_\ell}}\, W^{(\ell)} \alpha^{(\ell)}(x) + \beta\, b^{(\ell)}, \\ \alpha^{(\ell)} = \sigma(\tilde\alpha^{(\ell)}) \end{gathered}
(6)

with α(0)(x)=x\alpha^{(0)}(x) = x and output fθ(x)=α~(L)(x)f_\theta(x) = \tilde\alpha^{(L)}(x). Every weight and bias is initialized from N(0,1)\mathcal N(0, 1). The usual parametrization (LeCun initialization) instead draws weights with variance 1/nℓ1/n_\ell and omits the 1/nℓ1/\sqrt{n_\ell} factor. The two give the same function at initialization and the same set of representable functions; they differ in the gradients. In (6), the derivative of the output with respect to a weight carries the factor 1/nℓ1/\sqrt{n_\ell}, so a hidden layer with nℓnℓ+1n_\ell n_{\ell+1} weights contributes a sum of nℓnℓ+1n_\ell n_{\ell+1} terms each of size about 1/(nℓnℓ+1)1/(n_\ell n_{\ell+1}) to the kernel (2), which stays finite as the width grows. Under LeCun initialization the same layer's contribution grows in proportion to the width, so the kernel has no finite limit. The 1/P1/\sqrt{P} in the random-features model (5) has the same role.

The paper notes a side effect: the factors put 1/n1/\sqrt{n} into every weight's gradient but not into the biases', which reduces the weights' influence on training relative to the biases. The scalar β\beta scales the biases down to balance the two. The experiments use β=0.1\beta = 0.1 and learning rate 1.0, which the paper equates to a width-100 network in the usual parametrization trained at learning rate 0.01. At width 100 a weight WW enters the layer as W/nW/\sqrt{n}. Its gradient carries one factor 1/n1/\sqrt{n}, and dividing the updated WW by n\sqrt{n} applies a second, so the effective weight W/nW/\sqrt{n} moves by 1/n=0.011/n = 0.01 times the step a usual-parametrization weight takes at the same learning rate.

Why the NTK stops changing as width grows

The paper's two theorems are statements about the kernel (2) of the network (6) as the hidden widths n1,…,nL−1n_1, \dots, n_{L-1} go to infinity. The first concerns initialization. Proposition 1 restates the Gaussian-process result in this parametrization: each output tends to a centred Gaussian process with covariance Σ(L)\Sigma^{(L)}, built layer by layer,

Σ(1)(x,x′)=1n0 x⊤x′+β2\Sigma^{(1)}(x, x') = \tfrac{1}{n_0}\, x^\top x' + \beta^2
(7)
Σ(ℓ+1)(x,x′)=Ef∼N(0,Σ(ℓ))[σ(f(x)) σ(f(x′))]+β2\Sigma^{(\ell+1)}(x, x') = \mathbb{E}_{f \sim \mathcal{N}(0, \Sigma^{(\ell)})}\big[\sigma(f(x))\,\sigma(f(x'))\big] + \beta^2Σ(ℓ+1)(x,x′)=Ef∼N(0,Σ(ℓ))[σ(f(x)) σ(f(x′))]+β2\begin{aligned} \Sigma^{(\ell+1)}(x, x') &= \mathbb{E}_{f \sim \mathcal{N}(0, \Sigma^{(\ell)})}\big[\sigma(f(x))\,\sigma(f(x'))\big] \\ &\quad + \beta^2 \end{aligned}
(8)

The expectation is over a pair of jointly Gaussian numbers (f(x),f(x′))(f(x), f(x')) with the previous layer's covariance: wide layers sum many independent terms, so each pre-activation is Gaussian by the central limit theorem, and the next layer's covariance is the average of σ\sigma applied to those Gaussians. Theorem 1 says the NTK converges in probability to a deterministic kernel Θ∞(L)\Theta^{(L)}_\infty (times the identity across outputs), given by

Θ∞(1)=Σ(1),Θ∞(ℓ+1)=Θ∞(ℓ) Σ˙(ℓ+1)+Σ(ℓ+1)\Theta^{(1)}_\infty = \Sigma^{(1)}, \qquad \Theta^{(\ell+1)}_\infty = \Theta^{(\ell)}_\infty\, \dot\Sigma^{(\ell+1)} + \Sigma^{(\ell+1)}Θ∞(1)=Σ(1),Θ∞(ℓ+1)=Θ∞(ℓ) Σ˙(ℓ+1)+Σ(ℓ+1)\begin{gathered} \Theta^{(1)}_\infty = \Sigma^{(1)}, \\ \Theta^{(\ell+1)}_\infty = \Theta^{(\ell)}_\infty\, \dot\Sigma^{(\ell+1)} + \Sigma^{(\ell+1)} \end{gathered}
(9)
Σ˙(ℓ+1)(x,x′)=Ef∼N(0,Σ(ℓ))[σ˙(f(x)) σ˙(f(x′))]\dot\Sigma^{(\ell+1)}(x, x') = \mathbb{E}_{f \sim \mathcal{N}(0, \Sigma^{(\ell)})}\big[\dot\sigma(f(x))\,\dot\sigma(f(x'))\big]Σ˙(ℓ+1)(x,x′)  =Ef∼N(0,Σ(ℓ))[σ˙(f(x)) σ˙(f(x′))]\begin{aligned} &\dot\Sigma^{(\ell+1)}(x, x') \\ &\;= \mathbb{E}_{f \sim \mathcal{N}(0, \Sigma^{(\ell)})}\big[\dot\sigma(f(x))\,\dot\sigma(f(x'))\big] \end{aligned}
(10)

with σ˙\dot\sigma the derivative of the nonlinearity. Read (9) as an accounting of parameters. The term Σ(ℓ+1)\Sigma^{(\ell+1)} is the contribution of layer ℓ\ell's own weights and biases: the gradient of α~(ℓ+1)\tilde\alpha^{(\ell+1)} with respect to them is the previous activation, and the dot product of activations averages to the covariance. The term Θ∞(ℓ)Σ˙(ℓ+1)\Theta^{(\ell)}_\infty \dot\Sigma^{(\ell+1)} carries the contributions of all earlier layers through one more nonlinearity, scaled by how often both inputs pass through it together (Σ˙\dot\Sigma). The limit depends only on the depth, the nonlinearity, β\beta and the initialization variance.

For ReLU both expectations have closed forms (the arc-cosine kernels of Cho and Saul, 2009). For a centred Gaussian pair with variances a,ba, b and correlation cos⁡ϕ\cos\phi,

E[σ(u)σ(v)]=ab2π(sin⁡ϕ+(π−ϕ)cos⁡ϕ),E[σ˙(u)σ˙(v)]=π−ϕ2π\mathbb{E}[\sigma(u)\sigma(v)] = \frac{\sqrt{ab}}{2\pi}\big(\sin\phi + (\pi - \phi)\cos\phi\big), \qquad \mathbb{E}[\dot\sigma(u)\dot\sigma(v)] = \frac{\pi - \phi}{2\pi}E[σ(u)σ(v)]=ab2π(sin⁡ϕ+(π−ϕ)cos⁡ϕ),E[σ˙(u)σ˙(v)]=π−ϕ2π\begin{gathered} \mathbb{E}[\sigma(u)\sigma(v)] = \frac{\sqrt{ab}}{2\pi}\big(\sin\phi + (\pi - \phi)\cos\phi\big), \\ \mathbb{E}[\dot\sigma(u)\dot\sigma(v)] = \frac{\pi - \phi}{2\pi} \end{gathered}
(11)

Work it through for the paper's setting: L=4L = 4, inputs on the unit circle (n0=2n_0 = 2), β=0.1\beta = 0.1, and x=x′=(1,0)x = x' = (1, 0), so ϕ=0\phi = 0. Layer 1: Σ(1)=1/2+0.01=0.51\Sigma^{(1)} = 1/2 + 0.01 = 0.51 and Θ∞(1)=0.51\Theta^{(1)}_\infty = 0.51. Each ReLU layer halves the variance (E[σ(u)2]=a/2\mathbb{E}[\sigma(u)^2] = a/2) and has Σ˙=1/2\dot\Sigma = 1/2, so Σ(2)=0.265\Sigma^{(2)} = 0.265 and Θ∞(2)=0.51⋅0.5+0.265=0.52\Theta^{(2)}_\infty = 0.51 \cdot 0.5 + 0.265 = 0.52; then Σ(3)=0.1425\Sigma^{(3)} = 0.1425, Θ∞(3)=0.4025\Theta^{(3)}_\infty = 0.4025; then Σ(4)=0.08125\Sigma^{(4)} = 0.08125, Θ∞(4)=0.2825\Theta^{(4)}_\infty = 0.2825. For an input at 90° the limit is 0.0927, and at 180°, 0.0644: pushing the output at (1,0)(1, 0) up moves the output at the opposite point of the circle up by less than a quarter as much.

Theorem 2 is about training. The parameters move along a training direction gtg_t in function space (for gradient descent, gt=−dtg_t = -d_t, minus the cost derivative from (3)); as long as ∫0T∥gt∥ dt\int_0^T \lVert g_t\rVert\,dt stays bounded as the width grows, which least squares guarantees because the residual only shrinks, the NTK stays equal to Θ∞(L)\Theta^{(L)}_\infty uniformly on [0,T][0, T]. The mechanism, in Remark 4: each individual activation in a hidden layer changes by an amount that shrinks with width, so the gradients in (2) barely change, yet the many small changes add up to an order-one change in the output, which is what lets the lower layers contribute to learning at all. With a fixed kernel, (3) becomes a linear equation in ff, and the network trains exactly as kernel gradient descent with Θ∞(L)\Theta^{(L)}_\infty.

Figure 2 re-runs the paper's first experiment: a depth-4 ReLU network, Θ(x0,x)\Theta(x_0, x) for x0=(1,0)x_0 = (1, 0) and xx around the unit circle, ten random initializations per width, before and after 200 gradient steps at learning rate 1.0 on the target f∗(x)=x1x2f^*(x) = x_1 x_2. Look at two things as the width grows: how far the ten t = 0 curves spread around the dashed limit, and how far the trained curves move away from them.

Figure 2 · the empirical NTK converges to a fixed kernel
500
Each curve is Θ(x₀, x) for one random initialization, against the angle between x and x₀ = (1, 0). The dashed white line is the infinite-width limit Θ∞ from (9). Slide the width from 20 to 2000 and switch between the kernel at initialization, after 200 training steps, or both. The readout gives the spread at angle 0 and how far training moved the kernel and the weights.

At initialization the ten kernels at angle 0 have a standard deviation of 0.170 at width 20, 0.095 at 100, 0.040 at 500 and 0.020 at 2000: every fourfold increase in width halves the spread, the 1/n1/\sqrt{n} rate of an average of independent terms. The mean is close to the limit 0.2825 at every width from 100 up. Training moves the kernel in the direction the paper calls inflation: the mean value at angle 0 rises from 0.21 to 1.21 at width 20, by 86% at width 100, 20% at 500 and 4.4% at 2000. Over the same 200 steps the full parameter vector moves by 14.9%, 3.2%, 0.69% and 0.17% of its length, roughly in proportion to 1/n1/n, because the distance travelled stays about the same while the length of θ\theta grows with the number of parameters. All four widths reach a similar training loss after 200 steps, 0.016 to 0.022.

Proposition 2 handles the positive definiteness that (4) needs. For a non-polynomial Lipschitz nonlinearity (one with bounded slope, such as ReLU or tanh) and depth L≥2L \ge 2, the limiting NTK restricted to the unit sphere is positive definite, so for distinct training inputs on the sphere the Gram matrix is invertible and least-squares training converges to zero training error. The paper motivates the sphere by high-dimensional data, where centred points tend to have nearly equal norms.

Least squares and early stopping

With the kernel fixed and the least-squares cost, (3) is a linear ordinary differential equation for the function. Define the operator Π\Pi by Π(g)(x)=1N∑iΘ(x,xi) g(xi)\Pi(g)(x) = \frac1N \sum_i \Theta(x, x_i)\, g(x_i), so (3) reads ∂tft=−Π(ft−f∗)\partial_t f_t = -\Pi(f_t - f^*). Its solution is a matrix exponential:

ft=f∗+e−tΠ (f0−f∗)f_t = f^* + e^{-t\Pi}\,(f_0 - f^*)
(12)

On the training inputs, Π\Pi is the Gram matrix divided by NN. Its eigenvectors are the kernel principal components of the data (kernel PCA, Schölkopf et al. 1998), and its eigenvalues λi\lambda_i are the variance each component captures. Split the initial error f0−f∗f_0 - f^* into a part Δ0\Delta^0 that the kernel cannot see (zero on every training input) and one part Δi\Delta^i along each component. Each component then decays at its own rate:

ft=f∗+Δ0+∑i=1Ne−tλi Δif_t = f^* + \Delta^0 + \sum_{i=1}^{N} e^{-t\lambda_i}\,\Delta^i
(13)

A component with eigenvalue λi\lambda_i loses a factor ee of its error every 1/λi1/\lambda_i time units. Large-eigenvalue components are fit first, and the paper reads this as a reason for early stopping: stopping at a moderate tt fits the top components and leaves the small-eigenvalue ones, which for smooth kernels are the high-frequency, noise-like directions, mostly unfit.

Evenly spaced points on a circle make the components easy to name. The limiting NTK depends only on the angle between two inputs, so with N=16N = 16 evenly spaced points the Gram matrix is circulant (each row is the previous row shifted by one), and its eigenvectors are the sines and cosines of frequency k=0,…,8k = 0, \dots, 8 sampled at the 16 points. For the depth-4 limit with β=0.1\beta = 0.1, the eigenvalues of Π\Pi are 0.124 for the constant (k=0k = 0), 0.0440 for k=1k = 1, 0.0183 for k=2k = 2, 0.00653 for k=3k = 3, falling to 0.00158 at k=8k = 8. At learning rate 1, an error at frequency 1 loses a factor ee every 23 steps; at frequency 8, every 633 steps.

Figure 3 runs (12) exactly for that kernel on a target f∗(γ)=0.6cos⁡γ+0.3sin⁡2γf^*(\gamma) = 0.6\cos\gamma + 0.3\sin 2\gamma with Gaussian label noise. It shows the mean network, starting from f0=0f_0 = 0; the random part of f0f_0 decays by the same formula and returns in the next section. Press play and watch the bars: frequencies 1 and 2 hold the signal, and by t=100t = 100 their residuals are down to 1% and 16% of their starting size, while bars 5 to 8, which hold only noise, still have 79% to 85% of theirs.

Figure 3 · training fits the top kernel principal components first
32
0.20
Kernel gradient descent with the infinite-width NTK on 16 evenly spaced points. Top: noisy labels, the true function (dashed) and the current fit f_t. Middle: training residual in each frequency, with its starting size outlined; teal bars (k ≤ 2) carry the signal. Bottom: training and test error against log time. Play or scrub the time, raise the noise, or draw new noise.

With the default noise level of 0.2, the test error against the clean target bottoms out at 0.0159 near t=74t = 74, when training error is still 0.029. After that the slow bars, which hold mostly noise, get fit too: training error goes to zero and test error climbs to 0.0388 by t=31,623t = 31{,}623, 2.4 times the best value. With no noise the test error keeps falling to 0.0001 and stopping early only costs accuracy. Raising the noise to 0.5 moves the best stopping time earlier, to t≈34t \approx 34 for the first noise draw.

The paper tests (13) on real data. It takes 512 MNIST digits, approximates the limiting kernel with a width-10,000 network, and finds the top three eigenvalues 0.0457, 0.00108 and 0.00078. The first component is nearly the constant function, because the kernel PCA is not centred, which explains the factor of 42 between the first two eigenvalues; with β=1\beta = 1 instead of 0.1 that gap is about ten times larger, which the paper reports makes training harder. It then sets the target to the initial network plus half the second component, f∗=fθ(0)+0.5f(2)f^* = f_{\theta(0)} + 0.5 f^{(2)}. In the limit the error decays as 0.5 e−λ2t0.5\,e^{-\lambda_2 t}, halving every ln⁡2/0.00108≈642\ln 2/0.00108 \approx 642 steps, along a straight line in function space. Networks of width 100, 1000 and 10,000 deviate from that line less as the width grows, and the narrower ones converge faster than the wider ones, which the paper attributes to the kernel inflation of Figure 2: multiplying the kernel by a factor has the same effect as multiplying the learning rate.

What a trained wide network converges to

Letting t→∞t \to \infty in (12) gives the trained network in closed form. Write ΘXX\Theta_{XX} for the N×NN \times N Gram matrix on the training inputs, ΘxX\Theta_{xX} for the row of kernel values between a test input xx and the training inputs, y∗y^* for the targets and y0y_0 for the initial network's outputs on the training inputs. With a positive-definite Gram matrix,

f∞(x)=ΘxX ΘXX−1 y∗+(f0(x)−ΘxX ΘXX−1 y0)f_\infty(x) = \Theta_{xX}\,\Theta_{XX}^{-1}\,y^* + \big(f_0(x) - \Theta_{xX}\,\Theta_{XX}^{-1}\,y_0\big)f∞(x)=ΘxX ΘXX−1 y∗+(f0(x)−ΘxX ΘXX−1 y0)\begin{aligned} f_\infty(x) &= \Theta_{xX}\,\Theta_{XX}^{-1}\,y^* \\ &\quad + \big(f_0(x) - \Theta_{xX}\,\Theta_{XX}^{-1}\,y_0\big) \end{aligned}
(14)

The first term is kernel regression with the NTK: it finds weights c=ΘXX−1y∗c = \Theta_{XX}^{-1} y^* for which the sum of kernel bumps ∑jcjΘ(x,xj)\sum_j c_j \Theta(x, x_j) hits every training target exactly, and predicts with that sum. It equals kernel ridge regression with the ridge penalty sent to zero, and the posterior mean of a Gaussian process with prior covariance Θ\Theta conditioned on noise-free observations. The second term is the part of the random initial function that training never removes. It equals zero at every training input, because there ΘxXΘXX−1\Theta_{xX}\Theta_{XX}^{-1} picks out that input's own value and the bracket cancels, and it is nonzero in between. Since f0f_0 is a Gaussian process at infinite width and (14) is linear in it, the trained network is Gaussian too, with mean given by the first term and a variance that vanishes on the training data.

Figure 4 re-runs the paper's second experiment: depth 4, four training points on the circle, 1000 steps at learning rate 1.0, ten networks each at widths 50 and 1000. The shaded band is the 10th to 90th percentile of the exact infinite-width Gaussian; its variance follows Lee et al. (2019, eq. 16), with Σ(4)\Sigma^{(4)} as the covariance of f0f_0.

Figure 4 · trained networks match the infinite-width Gaussian
Ten networks per width, before training (t = 0) and after 1000 steps (t = 1000), over the 10th-90th percentile band of the infinite-width prediction. The dashed line is the limit's median, which after training is kernel regression with Θ∞ on the four training points. Switch width and time.

Before training, the networks are random functions with a standard deviation of 0.285 at every input, the square root of Σ(4)(x,x)=0.08125\Sigma^{(4)}(x, x) = 0.08125. After training every network passes through all four points, where the band has zero width, and between the points the networks spread as the band predicts, at width 50 as well as at width 1000. The paper reports the same: even at width 50 the limit gives a good description of the distribution of trained networks. In our re-run the average of the ten networks differs from the limiting mean by 0.021 to 0.025 (root mean square over the circle), within the noise of averaging ten draws whose standard deviation is about 0.07.

The paper calls the first term of (14) the MAP (maximum a posteriori) estimate under a Gaussian prior with covariance Θ\Theta. That describes the mean only. The random network the training started from has covariance Σ\Sigma, not Θ\Theta, and Lee et al. (2019) show that the distribution of the trained network is the posterior of no probabilistic model, unless Σ\Sigma and Θ\Theta happen to be proportional. Training only the last layer would give the posterior of the Gaussian process with kernel Σ\Sigma; training all layers adds the lower-layer terms of (9) to the kernel without changing the prior.

What the NTK does not explain

Theorem 2 holds as the widths go to infinity and for a fixed training horizon TT. The proof in the appendix takes the widths to infinity one layer at a time, first n1n_1, then n2n_2, and assumes a twice-differentiable nonlinearity with bounded second derivative, while the experiments use ReLU (the paper notes the assumptions "do not seem to be strictly needed"). Yang (2019) proved convergence with the widths growing at equal rates, and Arora, Du, Hu, Li, Salakhutdinov and Wang (2019) gave a bound for ReLU networks that only needs every width to be large and covers infinite training time.

A constant kernel means the network's internal representations effectively do not change: the hidden activations move by amounts that vanish with width. Figure 2 shows the consequence at finite width, where the narrower networks' kernels moved by 20% to several hundred percent in 200 steps. Chizat, Oyallon and Bach (2019) named the frozen-kernel regime lazy training and showed that it comes from the choice of scaling: any model whose output is scaled up enough relative to its parameter changes trains this way. They also found that convolutional networks pushed into the lazy regime perform worse. The best convolutional NTK of Arora et al. (2019), an 11-layer architecture with global average pooling, reaches 77.43% on CIFAR-10, while the ResNet-110 of 2015 reached 93.57%. The μP explainer covers a parametrization chosen so that features keep changing as width grows, the alternative limit to this one.

Within its scope the NTK turns several observations about wide networks into theorems. Gradient descent on an over-parameterized network reaches zero training error despite the non-convex loss, because the kernel stays positive definite. Wide networks can fit any labels, including random ones as in the Rethinking Generalization experiments, because kernel regression with an invertible Gram matrix interpolates any targets; the paper's introduction makes the same comparison with kernel methods. And their predictions on new inputs are set by the kernel, so comparing limiting NTKs compares how architectures, depths and initializations generalize in this regime. The paper also notes that Theorem 2 allows training directions that come from another network, as in a GAN's generator update.

Computing the NTK

The limit (7)-(11) for ReLU takes a few lines. The listing computes Σ(L)\Sigma^{(L)} and Θ∞(L)\Theta^{(L)}_\infty for one pair of inputs and reproduces the worked example above; the comment at the end gives the empirical kernel of a finite network, which Figure 1 computes layer by layer and an autograd library computes as a product of Jacobians.

import numpy as np

def relu_moments(a, b, c):
    """E[relu(u)relu(v)] and E[step(u)step(v)] for var a, b and cov c."""
    s = np.sqrt(a * b)
    th = np.arccos(np.clip(c / s, -1.0, 1.0))
    e = s * (np.sin(th) + (np.pi - th) * np.cos(th)) / (2 * np.pi)
    return e, (np.pi - th) / (2 * np.pi)

def ntk_limit(x, y, L, beta=0.1):
    """Sigma^(L) and Theta^(L)_inf for one pair of inputs (Prop. 1, Thm 1)."""
    n0 = len(x)
    S = x @ y / n0 + beta**2           # Sigma^(1)(x, y)
    Sx = x @ x / n0 + beta**2          # Sigma^(1)(x, x)
    Sy = y @ y / n0 + beta**2          # Sigma^(1)(y, y)
    T = S                              # Theta^(1) = Sigma^(1)
    for _ in range(L - 1):
        e, edot = relu_moments(Sx, Sy, S)
        Sx = relu_moments(Sx, Sx, Sx)[0] + beta**2
        Sy = relu_moments(Sy, Sy, Sy)[0] + beta**2
        S = e + beta**2                # Sigma^(l+1)
        T = T * edot + S               # Theta^(l+1) = Theta^(l) Sdot + Sigma
    return S, T

x0 = np.array([1.0, 0.0])
print(ntk_limit(x0, x0, L=4))          # (0.08125, 0.2825)

# Empirical NTK of a finite net: sum over layers of
#   (a_l(x) . a_l(y) / n_l + beta^2) * (delta_{l+1}(x) . delta_{l+1}(y))
# where a_l are activations and delta_{l+1} = df/dz_{l+1} from backprop.
# With autograd: theta = J(x) @ J(y).T, J = df/dparams (one row per input).

For NN training inputs the limiting Gram matrix costs N2N^2 evaluations of this recursion, and (14) needs one N×NN \times N solve, the usual cost of kernel regression: cheap for the 4 to 512 points of the paper's experiments. The solve takes on the order of N3N^3 operations, about 101410^{14} for the 50,000 CIFAR-10 training images that Arora et al. used. The empirical NTK of a finite network costs a Jacobian of size N×PN \times P, which for a 1,005,001-parameter network and 1,000 inputs is a billion numbers.

Provenance Verified against primary literatureHow we verify
Jacot, Gabriel & Hongler (2018), Sec. 2 and Remark 1Network definition with 1/sqrt(n_l) factors and bias scale beta, all parameters N(0,1). Assumes a Lipschitz, twice-differentiable nonlinearity with bounded second derivative (footnote 1: "they do not seem to be strictly needed"). Experiments use beta = 0.1 and learning rate 1.0, which the paper says behaves like a standard width-100 network at learning rate 0.01.
Jacot et al., Sec. 3 and 3.1Kernel gradient, kernel gradient descent, and the cost derivative -||d||_K^2; the random-features model whose tangent kernel (1/P) sum f(p) x f(p) tends to K by the law of large numbers.
Jacot et al., Sec. 4 and App. AProposition 1 (Gaussian-process limit, Sigma recursion), Theorem 1 (NTK limit, Theta recursion), Theorem 2 (constant on [0, T] while the integral of ||d_t|| stays stochastically bounded), Remark 4, Proposition 2 (positive definite on the sphere for non-polynomial Lipschitz nonlinearity, L >= 2). Appendix A takes the widths to infinity sequentially, n_1 first.
Jacot et al., Sec. 5Least-squares solution f_t = f* + exp(-t Pi)(f_0 - f*), decomposition along kernel principal components, and the t -> infinity formula; the mean is described as the MAP estimate under the prior N(0, Theta) and as kernel ridge regression with the ridge sent to zero.
Jacot et al., Sec. 6Depth L = 4, ReLU, n_L = 1. Kernel experiment: widths 500 and 10000, 10 initializations, 200 steps at learning rate 1.0 on f*(x) = x1 x2. Regression experiment: widths 50 and 1000, 10 initializations, 4 points, 1000 steps. MNIST: N = 512 digits, width 10000, lambda_1 = 0.0457, lambda_2 = 0.00108, lambda_3 = 0.00078, target f_theta(0) + 0.5 f(2).
Arora, Du, Hu, Li, Salakhutdinov & Wang (2019), eqs. 37-38, Thm 3.1, Table 1Closed forms for ReLU: E[relu(u)relu(v)] = (lambda(pi - arccos lambda) + sqrt(1 - lambda^2))/(2 pi) times the scale, E[step(u)step(v)] = (pi - arccos lambda)/(2 pi). Their remark: Jacot et al. needed a sequential limit, Yang (2019) equal rates, Theorem 3.1 only a minimum width. Earlier training-time proofs (Jacot et al., Lee et al.) are asymptotic and cover finite training time. Best CNTK (11 layers, global average pooling) 77.43% on CIFAR-10.
Lee, Xiao, Schoenholz, Bahri, Novak, Sohl-Dickstein & Pennington (2019), eq. 16Mean Theta(x, X) Theta^-1 Y and variance K(x, x) + Theta(x, X) Theta^-1 K Theta^-1 Theta(X, x) - (Theta(x, X) Theta^-1 K(X, x) + h.c.) of the trained infinite-width network; this distribution does not correspond to the posterior of a probabilistic model (except when K and Theta are proportional).
Chizat, Oyallon & Bach (2019)Lazy training is "due to a choice of scaling" that makes a model behave like its linearization; deep convolutional networks trained in that regime perform worse.
CodeThe authors released no code. Google's Neural Tangents library (neural_tangents/_src/stax/linear.py, Dense) defaults to parameterization="ntk": weights and biases N(0,1), z = sigma_W/sqrt(N) sum W x + sigma_b b, the paper's form.
This page's runsFigures 2 and 4 are our numpy re-runs of the paper's Section 6.1 and 6.2 setups (the paper does not give the number of training inputs for 6.1; we used 64 draws from N(0, I); the 4 training points and targets of Figure 4 are ours). Figure 2 uses widths 20 to 2000 instead of 500 and 10000. Figures 1 and 3 compute in the browser: Figure 1 a width-n network with two hidden layers, Figure 3 the closed-form infinite-width kernel.
correctionTwo slips in the paper and one over-reading of it. The introduction calls the new object "the neural tangent network (NTK)"; everywhere else it is the neural tangent kernel. Section 2 writes the data distribution as (1/N) times a sum of point masses from i = 0 to N, which is N + 1 terms for a dataset x_1 ... x_N; the sum runs from i = 1. The common summary "neural networks are kernel machines" over-reads Theorem 2: the kernel is constant only in the infinite-width limit, under the 1/sqrt(n) parametrization, over a fixed training horizon T. Chizat, Oyallon and Bach (2019) trace the frozen kernel to that scaling and find that convolutional networks forced into this regime perform worse, and the best infinite-width convolutional kernel of Arora et al. (2019) reaches 77.43% on CIFAR-10, against 93.57% for the ResNet-110 of He et al. (2015). Two scope notes: the theorems assume a twice-differentiable nonlinearity and send the widths to infinity one layer at a time, while the experiments use ReLU (Arora et al. 2019 later proved the ReLU case with all widths finite but large); and Section 5's "MAP estimate" describes only the mean of the trained network, since Lee et al. (2019) show its full distribution is not the posterior of any probabilistic model.

Questions you might still have

?

Does the NTK explain why deep learning works?
It explains one regime precisely: a network so wide, under the 1/sqrt(n) parametrization, that its tangent kernel does not move during training. In that regime the network is a kernel method with a kernel fixed by depth, nonlinearity and initialization, and it learns no new features. Networks trained in practice move their kernel substantially, and forcing them into the frozen-kernel regime makes them worse: the best infinite-width convolutional kernel of Arora et al. (2019) reaches 77.43% on CIFAR-10, where a 2015 ResNet-110 reached 93.57%. The NTK is a solvable baseline that real networks beat, and the μP explainer covers the parametrization that keeps features learning at large width.

?

How wide does a network have to be before the kernel stays fixed?
There is no single number; it depends on depth, learning rate, training length and the parametrization. In this page's re-run of the paper's first experiment, 200 steps at learning rate 1.0 raised the kernel value at the reference input by 86% at width 100, 20% at width 500 and 4.4% at width 2000. Arora et al. (2019) give a sufficient width that grows polynomially in depth and in one over the tolerance, far beyond practical sizes, but empirical agreement often starts much earlier, as the width-50 networks in Figure 4 show.

?

How is the NTK different from the Gaussian-process kernel of an infinitely wide network?
The Gaussian-process kernel Sigma is the covariance of the network's outputs at random initialization: it describes the prior over functions. The NTK Theta describes how the outputs move under gradient descent. Theta^(L) = Theta^(L-1) Sdot^(L) + Sigma^(L), so Sigma is the part of Theta contributed by the last layer's weights and biases; training only the last layer would give Sigma as the tangent kernel. Training all layers adds the lower-layer terms, which is why the trained network is not a Gaussian-process posterior with either kernel.

?

Why does the paper divide by sqrt(n) instead of using the usual initialization?
With weights of variance 1 and a 1/sqrt(n) factor in the forward pass, each parameter's gradient carries the same factor, so the sum over all parameters that defines the NTK converges to a finite limit as n grows. With standard (LeCun) initialization the forward pass at initialization is identical, but the gradients of a hidden layer's n^2 weights are not scaled down, and the NTK grows in proportion to the width. The set of functions the network can represent is the same in both parametrizations; only the training dynamics differ.

?

Does the result cover cross-entropy, or optimizers like Adam?
Theorem 2 covers any training rule of the form: each parameter moves by the inner product of its gradient with some direction d_t in function space, as long as the integral of the size of d_t up to time T stays bounded. Gradient descent on cross-entropy fits that form over a finite horizon; only least squares gives the closed-form solution (12) and (14). Adam rescales each parameter's step by its own running statistics, which is not of that form, so the paper's theorem does not apply to it.

?

Can I compute the NTK of my own network?
For a finite network, yes: the empirical NTK between two inputs is the dot product of the gradients of the output with respect to all parameters, J(x) J(x')^T. For N inputs that is an N by N Gram matrix built from an N by P Jacobian, which is expensive for large P but routine for small datasets. Google's Neural Tangents library computes empirical NTKs from JAX models and the infinite-width kernels in closed form for fully connected, convolutional and attention layers.

?

What does the NTK say about early stopping?
Under least squares, the error along each kernel principal component decays like exp(-lambda_i t). Components with large eigenvalues, which for the kernels in the paper are the smooth, low-frequency functions, are fit first; components with small eigenvalues, where label noise mostly lives, are fit last. Stopping early keeps the fitted large-eigenvalue part and leaves out the small-eigenvalue part. In Figure 3 with label noise 0.2, test error is lowest near t = 74 and 2.4 times higher once the noise is fully fit.

?

Why did the smaller networks converge faster in the paper's MNIST experiment?
The paper attributes it to kernel inflation. Finite networks' NTKs grow during training, more for narrower networks, and multiplying the kernel by a factor speeds up kernel gradient descent by the same factor, like raising the learning rate. The paper adds that wider networks have more stable kernels and could take larger learning rates, so comparing convergence by step count without accounting for the learning rate is misleading.

Footnotes & further reading

  1. The paper: Jacot, Gabriel & Hongler, Neural Tangent Kernel: Convergence and Generalization in Neural Networks (arXiv June 2018; NeurIPS 2018). The authors released no code.
  2. Infinite-width networks as Gaussian processes: Neal, Bayesian Learning for Neural Networks (1996); Lee et al., Deep Neural Networks as Gaussian Processes (ICLR 2018); Matthews et al., Gaussian Process Behaviour in Wide Deep Neural Networks (ICLR 2018). ReLU kernels: Cho & Saul, Kernel Methods for Deep Learning (NeurIPS 2009).
  3. Wide networks as linear models, and the distribution of the trained network: Lee et al., Wide Neural Networks of Any Depth Evolve as Linear Models Under Gradient Descent (NeurIPS 2019).
  4. Non-asymptotic convergence and the convolutional NTK: Arora, Du, Hu, Li, Salakhutdinov & Wang, On Exact Computation with an Infinitely Wide Neural Net (NeurIPS 2019). Equal-rate limits: Yang, Scaling Limits of Wide Neural Networks with Weight Sharing (2019).
  5. Lazy training: Chizat, Oyallon & Bach, On Lazy Training in Differentiable Programming (NeurIPS 2019). Feature-learning parametrizations: the μP (Tensor Programs V) and Spectral Condition for Feature Learning explainers.
  6. Random features: Rahimi & Recht, Random Features for Large-Scale Kernel Machines (NeurIPS 2007). Kernel PCA: Schölkopf, Smola & Müller, Nonlinear Component Analysis as a Kernel Eigenvalue Problem (Neural Computation, 1998). Software: Google's Neural Tangents library.