From a Straight Line to Backpropagation
One Sweep Back Instead of Seven Chains
Last timeTwo Layers, Every Derivative by Hand
The seven derivatives of a two unit network are built out of the same two numbers, and computing those once and sweeping backwards costs about three forward passes.
Seven derivatives came out of the two unit network, one for each of its seven
parameters, and each was written as its own chain of factors. Laid out side by
side those chains repeat themselves. Two numbers appear over and over, and they
are not cheap numbers: one of them contains a squashing function and its
derivative.
That repetition is not an accident of a network with two hidden units. It is the
shape of every network, and deciding to pay for it once is the whole of the
method this lesson names.
The network, and the numbers the forward pass left behind
The model is the one from the previous two lessons. The input is scaled as
, two hidden units squash a line each, and the prediction is a
weighted sum of the two unit outputs plus an offset:
$$
Here and are the weight and offset inside unit , is that
unit's output, is the weight the prediction puts on it, and is the
prediction's own offset. That is seven parameters. For one measurement with
input and value the contribution to the total squared error is
, and is the miss.
The arithmetic is done at , where and , with the
starting weights , , , , ,
and . The forward pass gives
and , then
and , and so
$$
The miss is and the contribution to the error is
.
The same two numbers, seven times over
Differentiate the error contribution with respect to the prediction first, before
touching any parameter. Since ,
$$
Call that number . It is the quantity arriving at the prediction, and
every one of the seven derivatives is built on it.
Next, the quantity arriving at a hidden unit's sum . The error reaches
only through , and then only through the prediction, so two factors stand
between them: the weight , which says how much the prediction moves when
moves, and the local slope of the squashing function, which differentiating
the hyperbolic tangent gives as . Write for the product:
$$
With the first unit's local slope is
, and with the
second's is . So
$$
$$
Two levels of sharing, and they are different. The number is shared by
all seven parameters. The number is shared by exactly the two parameters
inside unit and by nothing else. Neither is a per-parameter quantity: both
belong to a place in the network rather than to a knob, which is why there are
three of them and not seven.
The lesson stops here
6 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