Neural Networks, lesson 10
Train a classifier on your own autograd
Put the pieces together and train a small network end to end.
"Autograd you can step through" (the Value class) and "Loss functions" (cross-entropy). "Diagnosing a network that won't train" helps with the last section.
Part 1. Two moons
This lesson puts the whole module into one run: a small network learns to tell two groups of points apart, trained with the Value class from "Autograd you can step through".
The points come from two half-circles hooked into each other, like two crescent moons. Each point has two numbers, its x and y position, and a label: 1 for the upper moon, 0 for the lower one. A little random noise blurs the edges.
Example 1.1
Making the data
- t=a random angle from 0 to π
Pick a random spot along a half-circle. π (about 3.14) is half a turn.
- upper moon(cos t, sin t)label 1lower moon(1 − cos t, 0.5 − sin t)label 0
The upper moon arcs over the top. The lower one is the same arc flipped and shifted, so each moon's tip pokes into the other's hollow.
- x, y+noise with spread 0.1
Blur each point a little, so the two moons nearly touch.
- 80 points→training200 points→testing
The network learns from 80 points. Another 200, made the same way, are kept aside to measure it.
Test set
Examples kept out of training and used only to measure. A network can score perfectly on the examples it trained on and still fail on new ones. Only unseen examples show whether it learned the shape.
Your turn
A network whose boundary can only be a straight line trains on the moons. What do you expect?
Part 2. The network and its loss
Keep going with Pro
You've done the first part. Pro opens the rest of this lesson, and every other one.
- The network and its loss
- One training step
- Reading the run
Neural Networks overviewSpotted a mistake? Tell us.