Lesson 7 of 14 7 min · 144 words
Loss functions for networks
MSE for regression, cross-entropy for classification.
The loss turns the network's output into a single number to minimise. It must match the output layer:
- Regression — linear output, mean squared error: . MAE or Huber if there are outliers.\n- Binary classification — sigmoid output, binary cross-entropy: .\n- Multiclass — softmax output, categorical cross-entropy: .
Why cross-entropy rather than MSE for classification? Combined with a sigmoid or softmax, its gradient with respect to the scores is simply — large when the network is confidently wrong. MSE through a sigmoid has a gradient that vanishes exactly when the network is confidently wrong, so learning stalls.
Formula to remember
Convolution output size
Slides
Input n, padding p, kernel k, stride s.
Quick check · +5 XP