Single Neurons, Multi-Layer Networks, and Backpropagation
Learning objectives
- Write a neuron as a weighted sum through a squashing function, and say why one neuron draws a straight boundary as logistic regression does
- Explain why the boundary of pay on the neutron log and log10 RT bends with porosity, and how a layer of hidden units lets a network's boundary bend
- Follow backpropagation from the output's error back through a tanh layer, and check its gradient by central differences
- Read a network's loss as it trains, from its random first weights through a plateau, and say what a training score measures
A Neuron, Then a Layer of Them
A neuron takes a weighted sum of its inputs and squashes it; with a sigmoid it is logistic regression, and its boundary is a straight line. A network puts a layer of such units between the logs and the output, and each hidden unit adds a line the boundary can bend along. On the Ogbon field's nine wells the log10 RT that marks oil depends on the porosity, since a wet rock reads more resistive the less porous it is: on the neutron log and log10 RT, pay's boundary sits high at the limestone's low neutron reading and low at the sand's. On these two logs logistic regression calls 0.963 of the 10809 samples right, a network with one hidden unit 0.964 and one with two hidden units 0.982, each on the samples it learned from. Backpropagation computes the gradient that trains them, for every weight, in one pass backward through the network.
The Data
The data are the book's own learning set: Ogbon-1, the Petrophysics book's well, and eight hypothetical appraisal wells of the book's field, each 1201 samples every 0.5 ft, logged by Ogbon-1's own build and the book's own tool model, all synthetic. The class is pay, the Petrophysics book's net-pay rule on the generator's truth. Two logs are used so the network's decision can be drawn: the neutron log (v/v) and log10 RT, each scaled to zero mean and unit variance. The networks are trained on all 10809 samples and scored on them, which shows the mechanism and flatters the score; Section 13.2 holds wells out. Training takes seconds in node and far longer on a phone, so the weights at each epoch shown are precomputed in the book's network table; the field, the hidden units' lines and the gradient check are computed on the page from them.
A Neuron
A hidden unit computes from the scaled logs : a weighted sum, squashed between and . The output layer takes weighted sums of the for not pay and for pay, and a softmax turns them into two probabilities. With two classes the softmax is the sigmoid of the difference of the two sums, so a network with no hidden layer is logistic regression. With one hidden unit the probability of pay still rises or falls with one weighted sum of the logs, and its boundary is still a straight line: 0.964 against logistic regression's 0.963.
Why the Boundary Bends
By Archie's law a rock full of water reads more resistive the less porous it is. Over the nine wells, as the book's tool model records them, the sand with oil reads a median neutron porosity of 0.264 v/v and log10 RT of 1.25, the wet sand 0.275 v/v and β0.16; the limestone with oil 0.105 v/v and 2.11, the wet limestone, all of it in Ogbon-8, 0.113 v/v and 0.63; the shale, never pay, 0.348 v/v and 0.34. The wet limestone reads more resistive than some of the oil sand, so the log10 RT that parts pay from the rest is higher at the limestone's neutron than at the sand's. A straight line cannot follow it. Logistic regression keeps the wet limestone out by drawing its line high, and misses 262 samples of pay sand: 398 samples wrong in all. One hidden unit draws its line low, and calls all 224 samples of limestone that are not pay pay. Two hidden units bend the boundary: 196 samples wrong, 68 of them limestone with oil but too tight to be pay, below the Petrophysics book's porosity cutoff, which these two logs cannot tell from the pay limestone.
Training
Each network starts from weights drawn at random from the kernel's generator and is trained by full-batch Adam, a learning rate of 0.05, for 400 epochs, to the mean cross-entropy of its calls. Before any step the network with two hidden units calls 0.343 of the samples right and its loss is 0.818: random weights give a random field, and a loss of zero would mean every sample called right with certainty. For the first hundred epochs its two units act as one line, and its loss sits on a plateau, 0.127 at epoch 100 and 0.123 at epoch 150, close to the 0.127 where the one-unit network ends. Then the second unit turns, the boundary rises at the limestone's neutron, and the loss falls to 0.081 at epoch 200 and 0.071 at epoch 400. Four hidden units reach 0.062 and 0.981: more lines, little more to cut.
Backpropagation
The gradient of the loss for a weight says how the loss moves when the weight does. Backpropagation gets all of them from the chain rule: the output's error, the probability of pay less the truth, is sent back through the output weights and multiplied at each tanh unit by , its slope. One forward pass and one backward pass give every weight's gradient. Central differences nudge each weight up and down by a small step and difference the loss: two passes per weight, and the check that backpropagation is right. Plate (c) does both on 433 of the samples, every 25th; at every epoch shown and every size they agree to within .
What Comes Next
Section 13.2, the chapter's workshop, trains networks on all the porosity logs and log10 RT, on eight wells at a time, and scores them on the ninth.