Chapter 3
Which way to turn
Learning means finding the bottom of the valley. But a machine cannot see the valley. This chapter shows how it finds the bottom anyway, and then lets it set knobs with no help from you.
- Find the bottom of a valley you cannot see.
- Say what a slope tells you: which way is down, and how far you have to go.
- Work out one step: step size × slope, downhill.
- Say what goes wrong when steps are too small or too big.
- Explain how a machine sets its own knobs, in three words: feel, step, repeat.
Walking in fog
Here is the valley from chapter 2, with one change. It is covered in fog. This is how a machine sees it. It knows how wrong it is right now, and nothing else.
You are at wrongness 1.49. Which way is down? You cannot tell yet. Try a step.
You got there by trying. Take a step. If the wrongness goes up, come back. You even had to walk past the lowest point and see the wrongness rise, just to be sure it was the lowest. It works, but it wastes steps. And with many knobs it gets much worse, because there are many more wrong ways to go.
It would be far better to know which way is down before taking the step.
Feel the ground
Think about real fog on a real hill. You cannot see the bottom. But you can feel the ground under your feet. If it tilts down to the right, you walk right.
The tilt of the ground has a name you already know from chapter 1: steepness. There, the steepness of a line was the speed of the ghost. Here, it is the steepness of the valley floor. We will call it the slope.
Slope −13.2. A minus sign means the ground goes down to the right, so the bottom is to the right. The slope is big, so you are far from the bottom.
The slope is one number, and it tells you two things.
Its sign tells you which way is down. Minus means down is to the right. Plus means down is to the left.
Its size tells you how far you are from the bottom. A big slope means you are high on the valley wall. A small slope means you are nearly there. A slope of zero means you have arrived.
How does a machine feel the slope without seeing the valley? It works out its wrongness where it stands. Then it nudges the knob a tiny bit and works out the wrongness again. If the number went down, that way is downhill. How much it went down tells it how steep the ground is. Two checks, and it knows the slope.
The slope under your feet tells you which way to turn the knob, and how much.
Take a step
Now we can write the rule for a step. It is short:
The step size is a small number we choose. For now it is 0.004. Because the step is multiplied by the slope, steep ground gives a long step and flat ground gives a short one.
Step 1. The steeper the ground, the longer the arrow. Watch it shrink as the point gets close.
Compare this with your walk in the fog. No step was wasted. And the steps slowed down by themselves near the bottom, because the ground there is nearly flat.
Feel the slope. Take a step downhill. Repeat. That is how a machine learns.
How big a step?
We chose a step size of 0.004. Was that a good choice? Try some others.
Pick a step size to start.
If the step size is too small, learning is slow. If it is too big, each step jumps over the bottom. If it is much too big, the machine jumps further away every time and never learns at all.
The step size has to be chosen with care. It is one of the first things people set when they train a machine.
Two knobs, no hands
Remember the rider with a head start, at the end of chapter 1? It needed two knobs, and they were fiddly to set by hand. Fixing one spoiled the other.
A machine does not mind. It feels a slope for each knob: “if I turn only this knob, does the wrongness go up or down?” Then it turns every knob a little, each one downhill. Then it does it again.
The knobs are set badly, and the wrongness is 5.85. In chapter 1 you fixed this by hand. Let the machine do it.
Look at what you just watched. Nobody told the machine the speed or the head start. It found them. All it had was the dots, a way to measure its wrongness, and the habit of stepping downhill.
With one knob, the valley was a curve. With two knobs it is a real valley, with a floor and two walls, like the one in the picture. Every spot on it is one pair of settings. With a billion knobs, it is a shape nobody can picture. It does not matter. The method is the same: one slope for each knob, one small step for each knob, again and again.
This is the engine of the whole article. Every machine from here on, up to attention, learns in exactly this way.
What is missing
So far the rule has had one thing going in: time. Most things in life depend on more than one thing. The price of a house depends on its size, its age and where it is. The next word in a sentence depends on all the words before it.
The next chapter gives the rule many things to look at at once, and a knob for each.
- Find the bottom of a valley you cannot see.
- Say what a slope tells you: which way is down, and how far you have to go.
- Work out one step: step size × slope, downhill.
- Say what goes wrong when steps are too small or too big.
- Explain how a machine sets its own knobs, in three words: feel, step, repeat.