Double Descent Network Anatomy
Interactive lesson · network view · 20 noisy points

Double descent in neural networks

Twenty noisy measurements of a hidden curve, one small neural network, and a result that surprised the field: making a model bigger can make it worse, and then better again.

What this lesson is about

The task

A hidden curve, y = 2.2x⁴ + 0.35x³ − 1.8x² + 0.4, is measured at a few x positions, and every measurement is off by a little random noise. A neural network sees only these noisy points and has to guess the whole curve. You see the true curve as a dashed line; the network never does.

The network

The input x passes through one to three hidden layers of tanh neurons and comes out as one number, the predicted y. Width is the number of neurons in each layer. More neurons and more layers mean more adjustable weights, so the network can draw more complicated curves.

What we measure

Training error is how far the network's curve is from the noisy points it learned from. Test error is how far it is from the true curve everywhere, which is what actually matters. A network can have zero training error and still be badly wrong.

The surprise

Classical statistics predicts a U: a network that is too small misses the shape, and one that is too big memorizes the noise, so test error should keep rising as the network grows. Instead it peaks exactly where the network has just enough weights to pass through every point, then falls again. That second fall is double descent.

How to use this page

The tabs choose what grows: the network, the amount of data, or the training time. Random features freezes the hidden layers at random values and trains only the output weights, which is exact and instant. Live training trains every weight in your browser after you press Train. Pick the number of hidden layers, drag either slider, press Play, or click a lesson step. You can fold this box away with its title.

Hidden layers
Width 8
fewer parameters
training points true quartic typical network other networks
0.20

The network

Hover or tap a neuron to see its part of the fit.

positive weight negative weight frozen thicker = bigger
fewer weights than pointsequalmore

Error vs. width

test error training error each network weight size (right axis) click to select

The network. One to three hidden layers of tanh neurons, all of the same width. The first layer computes hj = tanh(wjx + bj), each further layer computes tanh(Gh + c) from the layer before, and the output is Σ ajhj of the last layer. The data are noisy samples of y = 2.2x⁴ + 0.35x³ − 1.8x² + 0.4 at well-spread x; test error is the mean squared distance to the true curve over [−0.9, 0.9].

Random features. The hidden weights are random and frozen, so each neuron is a smooth step at a random place. Only the output weights aj are learned, by gradient descent from zero. That training has an exact formula, so every step count is computed instantly; fully trained, it ends at the smallest output weights that fit the data as well as possible. Five random networks per setting; the bold curve is their geometric mean.

Live training. Every weight, slope and offset is trained with Adam for 20,000 full-batch steps, three random starts per setting, in a background thread. Each neuron has three trainable numbers, so with one layer the peak sits near width 7–10 rather than near 20, and it is weaker and noisier than with random features. With 2 or 3 layers the width × width weights between layers dominate, so the peak moves to width 2–4; widths stop at 30 there to keep training time reasonable.

Network panel. The columns in the middle are the hidden layers; the first is sorted by where each neuron's step sits. Each box shows that neuron's activation as x runs from −1 to 1, so you can see the features get more complex layer by layer. Between hidden layers every neuron connects to every neuron in the next; above 12 neurons those connections are drawn as a band. Lines on the right are the output weights aj of the typical network, thickness on a log scale. The weight-size line on the error chart is ‖a‖, the length of the whole output-weight vector (geometric mean over networks).

More compute. This tab shows what training longer really does to this network: a first dip, then a rise as it memorizes the noise. The second dip seen in large deep networks (Nakkiran et al., 2019) does not appear here. With a frozen hidden layer, training longer only fits more of the same directions, so it cannot happen; it needs features that change during training, which a 20-point toy doesn't provide. Also see Belkin et al. (2019).