Training a Deep Net
A loop that walks downhill
Training a deep net is a loop: make a prediction, measure how wrong it is, then move the weights a little to be less wrong. The three pieces have ordinary names.
The loss is a single number for “how wrong.” For a line, that is often the mean squared error, as on ANN: Gradient. For a classifier it is often a cross-entropy. Smaller is better.
The update is gradient descent, or a close cousin. The gradient of the loss points uphill; we subtract a small step \(\eta\) (the learning rate) and walk the other way. SGD (stochastic gradient descent) does not wait to see the whole dataset: it uses a small batch of examples, takes a step, then takes another batch. Adam is a popular variant that also keeps a short memory of recent slopes, so the step size can adapt. You do not need the Adam formulae to use the idea: it is still “move opposite the gradient,” with a slightly smarter step.
An epoch is one pass through the training set. A batch is the handful of examples in one update (16, 32, 128 are common sizes). Think of tasting the soup with a spoon, not drinking the whole pot, before you add a pinch of salt. The spoon is the batch; cooking the pot all the way through once is an epoch.
The shower-tap picture from ANN: Gradient still holds. If the learning rate is huge, you slam the tap and overshoot. If it is tiny, you wait forever. Batches add a little noise, which often helps the walk not get stuck, and they fit in memory. How to stop the net memorising the training set, instead of learning the pattern, is the next page: Overfitting and Regularization.
See also
- ANN: Gradient — the walk downhill, the learning rate, and a live linear-regression example
- Why Depth
- Overfitting and Regularization
- Lab#DL01-4: From neuron to MLP and training
- Optimization essentials