Section 1
Choose the metric
A map with wrong house numbers misleads its reader, so the team that transcribed Street View house numbers set a high bar. The book's target was human-level accuracy of 98 percent. The system can only reach that bar by refusing the inputs it is unsure about. Refusal costs coverage, the share of inputs the system answers. The team therefore chose coverage as the main metric to push up, with accuracy held at 98 percent.
How to use this pageClick the colored symbols. A click explains the symbol and lights up the same symbol elsewhere on the page.
Move the controls before you read on. Each sentence below a demo describes what you have seen.
n, k counts and data
E errors
t, c chosen constants
coverage the main object
p probabilities
The system refuses an input when its confidence falls below a threshold . These two definitions are added here and are not printed in the book, which describes them in words:
Click any coloured symbol to see what it means.
Click any coloured symbol to see what it means.
A higher threshold refuses more inputs. Accuracy on the answered inputs tends to rise, and tends to fall. Your task is to find the threshold that gives 98 percent accuracy and keeps as much coverage as possible.
Move the threshold along the trade-off
Predict the coverage when accuracy first reaches 98 percent:
coverage and accuracy for each threshold98 percent goal
The toy population has 400 inputs, generated from a fixed seed. Most are easy, with high confidence and high accuracy. The rest are hard. The numbers describe this toy and are not the Street View data.
Challenge +8 XPMove the threshold until accuracy is at least 98% while coverage stays at 80% or more.
The book reports that as the convolutional network (a network that learns image filters) improved, the threshold could come down while accuracy held at 98 percent, and coverage eventually passed the goal of 95 percent.
Section 2
Score a whole address
An address has several digits, and each digit is one classification. The first design gave each position its own softmax output, which turns class scores into probabilities that add up to one. Each output was trained as a separate classifier. The book calls this a simple baseline. The system still needs one number for the whole sequence, because refusal applies to the whole address.
The book says its first definition of the sequence probability was ad hoc. It multiplied the softmax outputs of the digits together. The product is written below, with the same meaning as the book's words. The log form is added here and is not printed in the book.
Click any coloured symbol to see what it means.
Click any coloured symbol to see what it means.
The book then replaced that rule with a specialized output layer and a cost function that computes a proper log-likelihood. That change made the refusal rule work much more effectively. The refusal rule itself is the same idea as before:
Click any coloured symbol to see what it means.
Three digits, one threshold
Three digits are each 90 percent sure. At a threshold of 80 percent, what happens?
Challenge +8 XPMake every digit more than 90% sure, and set the threshold so that the address is refused.
Each digit below certainty multiplies the product by a number below one. Three digits at 90 percent give 72.9 percent, which is below 80 percent, even though every digit looks confident. This reading is added here and is not printed in the book.
Section 3
Compare train and test error
The book's first check is whether the problem is underfitting (the model is too simple for the data) or overfitting (the model fits its training examples but not new ones). When the team measured the system, training error and test error were nearly identical. The book reads this as underfitting or a problem in the training data, not overfitting.
The demo below uses a toy error curve. The training error is 30 × 0.7 percent, and the test error is half a point higher. The model size is the learner's control. A checkbox adds 8 points to both errors, which is what a fault shared by both sets would do.
Read the two errors together
Both errors are about 21 percent and nearly equal. What does the book suggest checking next?
training error (solid)test error (dashed)
Challenge +8 XPFind a model size where both errors are below 10%, with the Add 8 points to both errors box unticked.
The book's conclusion is that when training and test error are roughly equal, the remaining deficit is underfitting plus a few problems in the dataset. The next section looks at the worst errors, the check the book used to find the cropping problem.
When training error is low and test error is high, the pattern is overfitting. This toy does not produce that pattern.
Section 4
Read the worst mistakes
The book's debugging strategy is to visualize the model's worst errors. In this project those were the incorrect transcriptions the model gave the highest confidence. Most of them were addresses cropped so tightly that digits were lost. For example, a photo of the address 1849 might be cropped to show only 849, as in the book.
To measure how much of the first digit a crop removed, define the cut share. This definition is added here and is not printed in the book.
Click any coloured symbol to see what it means.
Confident mistakes, plotted by cut share
Among the mistakes at 90 percent confidence or more, what share have the first digit cut by more than a quarter?
mistakes at or above the chosen confidenceother mistakes
The toy has two kinds of mistake: tight crops that cut the first digit, and a smaller group of ambiguous digits with a clean crop. Both kinds can be confident, so the share of cut digits among the confident mistakes changes from draw to draw. The same plot made from real data is the check that matters, because only the data can say which cause dominates. The reading that a cause in the input explains a group of confident errors is added here and is not printed in the book.
The book notes that this could have been fixed by spending weeks improving the detector that chooses the crop. Instead, the team widened the crop. A pattern like this points to the input pipeline rather than the network. This reading is added here and is not printed in the book.
Section 5
Widen the crop, then tune the model
The fix was to make the crop systematically wider than the detector predicted. The book says this single change added ten percentage points to coverage. The crop margin is the extra width added on each side. In this toy a digit is kept when its offset from the crop center is within the margin plus half a digit width:
Click any coloured symbol to see what it means.
The rule above is added here and is not printed in the book. The offsets in the toy are spread evenly over 1.6 digit widths on each side. Move the margin and watch which addresses keep their first digit.
Widen the crop margin
first digit keptfirst digit cut
Challenge +8 XPWiden the crop until coverage reaches 90%.
The book's team also tuned hyperparameters, the settings chosen before training, such as the model size. The last few percentage points came from making the model larger while keeping its computational cost within a limit. Train and test error stayed roughly equal through this phase, so the remaining deficit was underfitting and a few dataset problems.
What the project achievedThe book reports that the system transcribed hundreds of millions of addresses, faster and at lower cost than human effort would have allowed. This project followed the chapter's method throughout: pick a metric that matches the goal, measure the errors, and read the worst of them before changing the model.
What to take away
- Choose the metric from the business goal. Here the goal was 98 percent accuracy, with coverage as the metric to push up.
- Score a whole sequence with one probability, and check how the refusal threshold behaves on long inputs.
- Read training and test error together. Nearly equal errors point to underfitting or a data problem.
- Plot the worst confident mistakes. A shared cause among them points to the input pipeline.
- Widen the crop, then tune the model size within a computational budget.
Final quizCheck yourself
Questions that mix the whole module. Each one is scored, and the score feeds your mastery of this module.
Source: Ian Goodfellow, Yoshua Bengio and Aaron Courville, Deep Learning, MIT Press, 2016, Section 11.6 (pages 440–442), free to read at deeplearningbook.org. Where the book prints equation numbers, the numbers here follow the book. The order of ideas follows the book. The explanations and all demos were written for this page.