Quiz: learning

Short questions on losses, gradient descent, backpropagation and overfitting. Try each on paper first, then open the answer. Cross-entropy is -\ln p_\text{true class}; a gradient step is \mathbf w \leftarrow \mathbf w - \eta\nabla\mathcal L.


Q1. A network gives the true class probability 0.8 for one image and 0.05 for another. What is the cross-entropy of each?

-\ln p.

-\ln 0.8 = 0.22 and -\ln 0.05 = 3.00. The confident mistake costs about 13 times as much.


Q2. You train with full-batch gradient descent and the loss grows from step to step. What do you change first?

What sets the length of each step?

Lower the learning rate \eta: each step overshoots the valley and lands higher than it started.


Q3. 50,000 training images, mini-batches of 100. How many gradient steps is one epoch? What changes if you use batches of 10?

An epoch is one pass over all images.

500 steps. With batches of 10: 5,000 steps per epoch, each cheaper but noisier (the gradient estimate from 10 images varies more).


Q4. In the backward pass, a ReLU unit had z = -2 in the forward pass. What gradient does it pass back to its weights?

The local derivative of \max(0, z) at z < 0.

Zero: the ReLU’s local derivative is 0 for z < 0, so every gradient behind it is multiplied by 0. For this example the unit’s weights do not change. If that holds for every training example, the unit is dead.


Q5. Why is backpropagation so much cheaper than estimating each \partial\mathcal L/\partial w by changing w a little and recomputing the loss?

Count forward passes for a network with a million weights.

Finite differences need one extra forward pass per weight: a million forward passes. Backpropagation gets all million gradients from one forward and one backward pass, at about twice the cost of a forward pass, because it reuses the gradient of each node for everything behind it.


Q6. The training loss keeps falling, the validation loss has been rising for 50 epochs. What is happening, and which weights do you keep?

Learning curves.

The network is overfitting: it memorises the training examples, and gets worse on new ones. Keep the weights from the epoch with the lowest validation loss (early stopping), or regularise and train again.


Q7. Name three ways to reduce overfitting.

Penalty, noise, data.

Weight decay (a penalty on large weights), dropout (silence random units during training), more data or data augmentation. Also: a smaller network, early stopping.


Q8. (math) For softmax followed by cross-entropy, what is \partial\mathcal L/\partial z_k? Evaluate it for \mathbf p = (0.7, 0.2, 0.1) when the true class is the second.

Predicted minus wanted.

\partial\mathcal L/\partial z_k = p_k - y_k: (0.7, 0.2 - 1, 0.1) = (0.7, -0.8, 0.1). A step against it lowers z_1 and z_3 and raises z_2.