Skip to content
BIASED

Training deep networks

Block 1 of 8~2 min

Exact gradients are not enough

The topic Backpropagation gave us exact gradients for a network of any depth, and ended with a warning: exact does not mean useful. Two things go wrong in practice.

The first is scale. The gradient that reaches the first layer is a product of one Jacobian per layer. If every factor shrinks a signal a little, thirty factors shrink it enormously. Here is an experiment on two moons, with classes {0,1}\{0, 1\}: an input layer 2→322 \to 32, then 30 ReLU layers of width 32, then one logit, trained with binary cross-entropy. All weights start at PyTorch's default initialization.

  • At the start, the gradient with respect to the first layer's weights has norm 3.2⋅10−133.2 \cdot 10^{-13}.
  • After 200 Adam steps the training loss is still 0.693=ln⁡20.693 = \ln 2, the loss of predicting probability 12\tfrac12 for every point, and the training accuracy is 0.50.5.

Nothing is wrong with the gradient: it is computed exactly. It is simply too small to move anything.

The second is capacity. A network flexible enough to fit any rule also fits the noise in its labels. This is overfitting from the topic Validation and overfitting, and a large network is very good at it.

This topic collects the standard remedies. Some make a deep network trainable at all: initialization that preserves the scale, residual connections, layer normalization and a learning-rate schedule. Others keep it from overfitting: dropout, weight decay, early stopping and data augmentation. The course Deep Learning takes each of them further. Here we see what each one does and why it works, mostly on the two-moons stack above and on the small digits from the topic From linear models to networks.

Answers are saved on the server and tied to this browser until you sign in.