From a Straight Line to Backpropagation
Putting a Bend in the Model, and Differentiating Through It
Last timeHow Far to Step
A squashing function after the line makes the model a composition, so the derivative becomes a product of four local slopes, worked here by hand on one measurement.
The twelve measurements have already been fitted exactly. Two derivatives set
to zero gave two equations, the two equations gave and , and at
that answer the total squared error is 12, a mean of 1 per measurement. Nothing
in it was approximate and nothing in it was iterative.
A line pays for that exactness by having one slope and using it everywhere.
Whatever it does at the left-hand end of the data it does again at the
right-hand end. Most measured quantities do not behave like that: a response
that grows and then levels off, a dose that stops helping, a queue that only
gets slower until the machine saturates and then goes vertical. A model that
cannot flatten will fit the middle and be wrong at both ends, and no amount of
solving rescues it, because the failure is in the shape of the model rather
than in the values of its parameters.
So the model gets a bend in it. The bill arrives immediately, because the
closed form goes and does not come back, and the only thing left is the slope
of the error where you happen to be standing. This page computes that slope,
slowly, on one measurement.
A bend you can control
The bent model itself is already established: the input scaled as ,
the old straight line rebuilt on the scaled input as , the squashed
value lying between minus one and one, and putting
that back on the scale of measurements running from 6 to 39. Two things about
it are settled and are not argued again here: that sits inside the
squashing function, so the twelve terms of a derivative cannot be collected and
there is no formula for the answer, and that dividing the input by twelve is
what keeps the arguments off the flat part of the curve. The one fact needed now
is the shape. Four steps separate the input from the prediction, each with one
input and one output, and that is what makes the derivative a product.
- the input scaled into the range from one twelfth to one, so the squashing function is not asked to work where it is flat
- the input weight, which sets how fast the squashing function is traversed as x grows
- the input offset, which decides which part of the squashing curve the data lands on
- the pre-activation, which is the old straight line in the scaled input
- the squashed value, somewhere between minus one and one
- the output weight, which scales the squashed value back up to the size of the measurements
- the output offset, which moves the whole curve up or down
- the squared error on measurement i on its own, so the total error is the sum of twelve of these
Where the scaling earns its place is in that product, and this is the first
page on which that can be shown rather than asserted. The slope of the
squashing function, derived in the next section as
, is at
, against about one near zero, and it is one of the four factors in the
derivative with respect to . Feed the raw in with near one and the
whole derivative is multiplied by a thousandth, so the parameter sits almost
still however wrong it is.
The lesson stops here
8 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents