How a network learns
Training is still gradient descent: work out how the loss changes with every weight and step against it. With hidden layers that takes backpropagation. The error at the output, p − y as in chapter 3, is passed back to the last hidden layer. Each neuron gets a share in proportion to its weight, scaled by its activation's slope. Then that layer's errors go one layer further back, and so on to the inputs. Libraries do this automatically, but knowing how it works helps when training goes wrong.
The board starts from random weights. Press the step buttons and watch the training and validation loss. It trains on the older 80% of matches and checks on the latest 20%.
When it goes wrong
- Vanishing gradients: in deep networks the error reaching the first layers is a product of many small slopes, so those layers barely learn. ReLU helps.
- Exploding gradients: with large weights the product grows instead and training blows up. Lower the learning rate. Batch normalization also helps. Try a learning rate of 3 on the board.
- Dead ReLUs: a neuron whose weighted sum drops below zero for every example outputs 0, passes no gradient back, and stays stuck. The board counts them. A lower learning rate or LeakyReLU helps.
- Dropout: a regularization for networks that ignores a random share of the neurons at each step. A rate of 0.5 drops half. At 0 nothing is dropped, and at 1 the network learns nothing.