Lecture 5

Neural networks 1

Introduction to Machine Learning
KU Leuven, campuses Diepenbeek and Geel
Academic year 2026–2027

The chessboard, again

Lecture 4 ended with a chessboard: two classes in alternating quadrants.

  • A line fails.
  • One greedy split achieves almost nothing.

Today

A model that builds its own features, and learns them by gradient descent.

Today in three choices

Model

composed nonlinear layers

layers of weighted sums and nonlinearities: only the model changes

Loss

cross-entropy, squared error

the losses of lectures 3 and 1

Optimiser

gradient descent

the same descent, now on minibatches

The plan

  1. From logistic regression to a layer
  2. Forward pass and backpropagation
  3. Making deep networks train

Exercise 3, after lecture 6, implements the forward pass and backpropagation of today in numpy.

Features, by hand

Lecture 2 fitted a curve by building the features \(x, x^2, \dots, x^p\) and then a line.

Someone chose powers as the family, and \(p\) had to be searched for.

Lecture 4 took the other road: a tree carves the space instead of transforming it.

Today

The features are weights like any other, and the same gradient descent finds them.

What a hidden unit computes is learned, not chosen.

Block 1

From logistic regression to a layer

Logistic regression is a neuron

\[ z = \vw\T\vx + b, \qquad p = \sigma(z) \]

Weights, a bias, a weighted sum and a nonlinear function.

Lecture 1 wrote the intercept as \(w_0\) with \(x_0 = 1\), and lecture 3 kept it. A neuron calls it the bias \(b\).

A diagram of a neuron. The inputs x1 and x2 are multiplied by the weights w1 and w2 and summed with the bias b into z, and a sigmoid turns z into the probability p.

Network vocabulary

  • Unit: one weighted sum and its activation
  • Layer: units that share an input
  • Width: units in a layer
  • Depth: layers that carry weights

Hidden: any layer that is not the input or the output. Its values are never compared with a target.

A network of 2 inputs, a hidden layer of 2 units and 1 output is written 2-2-1. Block 2 works that one by hand.

Counting the parameters

\[ d \text{ inputs} \to m \text{ units}: \quad dm + m \]

one weight per input per unit, plus one bias per unit

networkparameters
2-2-16 + 3 = 9
2-16-148 + 17 = 65
784-128-10101,770

The last one reads a 28 × 28 image and names one of ten classes. Every parameter is found by gradient descent.

What one unit does

Two panels. Left, the output of a single ReLU unit over the plane, zero on one side of a dashed line and rising steadily on the other. Right, a cut along x2 = 0, which is a flat line that bends upwards at x1 = 0.5.
A unit splits the plane with a line, is zero on one side and rises with a constant slope on the other. The weights turn the line, the bias slides it.

XOR

Four points at the corners of the unit square. The corners (0, 1) and (1, 0) are class 1, the corners (0, 0) and (1, 1) are class 0.
Class 1 where exactly one input is 1. No single line separates the two classes.

Two neurons, then one

\[ h_1 = \mathrm{ReLU}(x_1 + x_2) \] \[ h_2 = \mathrm{ReLU}(x_1 + x_2 - 1) \] \[ \yhat = h_1 - 2 h_2 \]

\(\mathrm{ReLU}(z) = \max(0, z)\)

The four corners give 0, 1, 1, 0: XOR, exactly.

The unit square with the four XOR points. Two dashed parallel lines mark where the hidden units switch on. The predicted class 1 region is a diagonal band between two parallel boundaries, containing the two class 1 corners.

XOR, corner by corner

\(s = x_1 + x_2\), \(\quad h_1 = \mathrm{ReLU}(s)\), \(\quad h_2 = \mathrm{ReLU}(s - 1)\), \(\quad \yhat = h_1 - 2h_2\)

\(x_1\)\(x_2\)\(s\)\(h_1\)\(h_2\)\(\yhat\)\(y\)
0000000
0111011
1011011
1122100

Both units read the same number \(s\). The second switches on one step later than the first.

Two ramps make a tent

Two panels against s = x1 + x2. Left, the ramp h1 rising from s = 0 and the ramp minus two h2 falling from s = 1. Right, their sum, a tent that rises to 1 at s = 1 and falls back through zero at s = 2, with the four XOR corners marked.
Subtracting a later, steeper ramp turns a rising ramp into a tent. Class 1 is the peak, class 0 is both feet.

Trained, not hand-picked

The same 2-2-1 network, weights started at random and trained on the four corners.

\[ h_1 = \mathrm{ReLU}(-3.27x_1 + 3.27x_2) \] \[ h_2 = \mathrm{ReLU}(3.37x_1 - 3.37x_2) \]

It found a different answer: \(h_1\) fires when \(x_2 > x_1\), \(h_2\) when \(x_1 > x_2\).

"The inputs differ", instead of "the sum is one". Both separate the classes.

It does not always work

Five random starts, same network, same 4,000 epochs.

One of the five solves XOR. The other four stop with at least one corner wrong.

Two hidden units is the smallest network that can solve XOR, and nothing promises that descent reaches it.

Block 3 explains what goes wrong and what to do about it.

A layer in matrix form

\[ \mH = g(\mX\mW + \vb) \]

For one example: \(\vh = g(\mW\T\vx + \vb)\)

  • \(\mX\): \(n \times d\), one example per row, as in lecture 1
  • \(\mW\): \(d \times m\), one column per unit
  • \(\vb\): \(m\) biases, added to every row
  • \(\mH\): \(n \times m\), the new features

Stacking without activation collapses

\[ \mH = \mX\mW_1 + \vb_1 \]
\[ \vyhat = \mH\mW_2 + \vb_2 = \mX\mW_1\mW_2 + (\vb_1\mW_2 + \vb_2) \]
\[ \vyhat = \mX\mW' + \vb' \]

Two linear layers are one linear layer. Depth adds nothing without a nonlinear \(g\) between the layers.

The output layer on learned features

The four XOR points drawn in the space of the two hidden units. The two class 1 points land on the same spot, (1, 0), and one straight line separates it from the class 0 points at (0, 0) and (2, 1).
In the space of \((h_1, h_2)\), one line separates the classes. The output layer is logistic regression on features the network builds itself. For more than two classes, a softmax output takes its place, as in lecture 3.

Bearings: line, boxes, network

Three panels of the training bearings. Left, logistic regression with one oblique straight boundary. Middle, the pruned tree of lecture 4 with axis-aligned steps. Right, a network with 16 ReLU units whose boundary is curved and bends at high temperature.
Test accuracy: 94.7% for logistic regression, 93.3% for the pruned tree, 94.7% for the network. On two features and a boundary close to a line, the line is enough.

The chessboard, solved

Three panels of the 400 chessboard points. Left, logistic regression, whose single near-vertical boundary leaves two quadrants wrong. Middle, the greedy tree of depth 3, whose boundaries are the two axes. Right, a network of four ReLU units, whose boundary follows the same two axes with slight bends.
Trained on the 400 points of lecture 4, tested on 2,000 fresh ones. The line reaches 48.8%, below chance; the tree of depth 3 99.2%; the network 98.5%.

Turbine: a sum of ramps

Three ReLU units, one input: the wind speed.

Each unit adds a ramp that starts at its own speed.

One ramp points down from 12.1 m/s and flattens the curve at the rated power.

Turbine power against wind speed with the training data, three dashed ramps starting at 4.3, 7.1 and 12.1 metres per second, the last one pointing downwards, and their sum, which follows the rise and the plateau of the power curve.

Reading the ramps

unitswitches onslopeat 6 m/sat 10 m/sat 14 m/s
14.3 m/s86 kW per m/s151496841
27.1 m/s236 kW per m/s06831,628
312.1 m/s−297 kW per m/s00−559
output bias: 34 kW1851,2131,944

Below 4.3 m/s every unit is off and the network predicts its bias alone.

More units, more flexibility

Three panels of turbine power against wind speed with fits of networks with 1, 3 and 10 hidden units. One unit gives a single ramp that misses the plateau, three and ten units follow the curve.
Test RMSE: 199 kW with one unit, 122 with three, 121 with ten. With enough units, one hidden layer approximates any continuous curve on a bounded range: the universal approximation theorem.

What universal approximation does not say

It says

For any continuous \(f\) on a bounded range and any \(\varepsilon\), there exist weights within \(\varepsilon\).

It does not say

  • how many units
  • that gradient descent finds them
  • anything about unseen data

Existence, not a method. The five XOR starts already showed the second gap.

One hidden layer or many

These data need one. Three units already come close to the noise floor of the turbine, and four solve the chessboard.

Depth earns its place when the features are raw and plentiful.

An image has no useful hand-made feature. Early layers find edges, later ones find parts, later still whole objects.

Lecture 7 builds such a stack. Block 3 is about keeping one trainable.

Checkpoint

What is the smallest number of hidden units that solves XOR, and why is one not enough?

Block 2

Forward pass and backpropagation

Training needs every gradient

\[ \vw \leftarrow \vw - \eta \, \nabla \loss(\vw) \]

Gradient descent, lecture 1

\(\nabla\loss\) needs \(\partial \loss / \partial w\) for every weight in every layer.

The 2-2-1 network of the next slide has 9 weights and biases. A network for images has millions.

The forward pass

A network with inputs x1 = 1.0 and x2 = 2.0, two ReLU hidden units h1 and h2 and a sigmoid output p. The first layer has weights w11 = 0.5, w12 = -0.3, w21 = 0.2, w22 = 0.4 and biases b1 = 0 and b2 = 0.1. The output has weights v1 = 0.8, v2 = -0.5 and bias c = 0.1.
  • \(z_1 = 1.0 \cdot 0.5 + 2.0 \cdot 0.2 + 0 = 0.9\)
  • \(z_2 = 1.0 \cdot (-0.3) + 2.0 \cdot 0.4 + 0.1 = 0.6\)
  • \(h_1 = 0.9, \; h_2 = 0.6\): both units active
  • \(z_3 = 0.9 \cdot 0.8 + 0.6 \cdot (-0.5) + 0.1 = 0.52\)
  • \(p = \sigma(0.52) = 0.627\), and with \(y = 1\): \(\loss = -\ln 0.627 = 0.467\)

A computation graph

A chain of operations from left to right: X, then multiply by W1 and add b1 to give Z1, ReLU to give H1, multiply by W2 and add b2 to give Z2, sigmoid to give P, and cross-entropy to give the loss L. A dashed arrow runs back from L to X for the backward pass.
The forward pass is a chain of simple operations, and each one knows its own local derivative.

The chain rule, on two stages

\[ u = 3w + 1, \qquad \loss = u^2, \qquad w = 2 \;\Rightarrow\; u = 7 \]
\[ \frac{d\loss}{du} = 2u = 14, \qquad \frac{du}{dw} = 3 \]
\[ \frac{d\loss}{dw} = \frac{d\loss}{du} \, \frac{du}{dw} = 14 \cdot 3 = 42 \]

Two stages, two factors, multiplied. Check it without the rule: \(\loss = 9w^2 + 6w + 1\), so \(d\loss/dw = 18w + 6 = 42\).

A weight's path to the loss

Two panels. Above, the worked network with the route from x1 through the first hidden unit to the output and the loss picked out, and the other connections faded. Below, the same route as a chain of five nodes, w11, z1, h1, z3 and the loss, with the local derivative on each of the four edges: x1, the ReLU derivative, v1 and p minus y.
\(w_{11}\) changes \(z_1\), which changes \(h_1\), which changes \(z_3\), which changes \(\loss\). Four stages where the warm-up had two, so four factors to multiply: that is the chain rule.

When a unit feeds many

Two panels. Left, one hidden unit with three arrows out to three output units, each labelled with its own weight. Right, the same picture with the arrows reversed and dashed, each carrying the derivative of its output times the same weight, and the sum of the three written beneath.
A hidden unit changes the loss through every output it feeds, so its derivative is the sum over them: \(\partial\loss/\partial h_j = \sum_k \partial\loss/\partial z_k \cdot w_{jk}\).

The graph, backwards

The backward chain of the worked network from right to left. From the loss, p minus y gives dZ2 = -0.373; multiplying by the transpose of W2 gives dH1 = (-0.298, 0.186); the ReLU mask leaves dZ1 the same; and each pre-activation hands its layer the weight and bias gradients.
One sweep, on the network of the forward pass. Each node receives a derivative, keeps what its own weights need and passes the rest on. A subscript numbers a layer here, so \(\mW_2\) and \(\vb_2\) are the output weights \((v_1, v_2)\) and the output bias \(c\).

The error of a layer

Read \(d\mZ\) as the error of a layer: how wrong its pre-activations are.

Output layer: \(p - y\), the error of lecture 3.

  • Turn its error into its own gradients
  • Hand a new error to the layer below
  • Repeat

Every layer does the same two things, whatever its depth. That is the whole algorithm.

Each piece computed once

\(-0.373\) was computed once and used four times: for both output weights, and for both hidden units.

Each node passes its derivative to the nodes before it: one sweep from the loss to the inputs.

One backward pass costs a small multiple of one forward pass, whatever the number of weights. This is backpropagation.

What backpropagation costs

Time

  • Forward: 2 matrix products
  • Backward: 3

For one hidden layer. The count does not grow with the weights, though each product does.

Memory

\(\mZ_1\), \(\mH_1\) and \(\mZ_2\) are kept until the backward pass has used them: \(n(2m + 1)\) numbers.

\(n = 32\), \(m = 16\): 1,056. \(n = 256\), \(m = 128\): 65,792.

Matrix form

\[ d\mZ = d\mH \odot g'(\mZ) \] \[ d\mW = \mH_{\text{in}}\T \, d\mZ \] \[ d\vb = \textstyle\sum_{\text{rows}} d\mZ \] \[ d\mH_{\text{in}} = d\mZ \, \mW\T \]
  • \(d\mZ\) has the shape of \(\mZ\): \(n \times m\)
  • \(d\mW\) has the shape of \(\mW\): \(d \times m\)
  • Every gradient has the shape of what it differentiates
  • \(d\mZ\) stands for \(\partial \loss / \partial \mZ\), and \(\odot\) is the entrywise product

Backpropagation in numpy

Pseudocode

forward, keep Z and H:
  Z1 ← X W1 + b1
  H1 ← ReLU(Z1)
  P  ← σ(H1 W2 + b2)
backward:
  dZ2 ← (P − y) / n
  dW2, db2 from H1, dZ2
  dZ1 ← dZ2 W2ᵀ ⊙ [Z1 > 0]
  dW1, db1 from X, dZ1

numpy

# forward
Z1 = X @ W1 + b1
H1 = np.maximum(Z1, 0)
Z2 = H1 @ W2 + b2
P = 1 / (1 + np.exp(-Z2))
# backward
dZ2 = (P - y) / len(y)
dW2 = H1.T @ dZ2
db2 = dZ2.sum(axis=0)
dH1 = dZ2 @ W2.T
dZ1 = dH1 * (Z1 > 0)
dW1 = X.T @ dZ1
db1 = dZ1.sum(axis=0)

\(\mX\) is \(n \times d\), and \(y\) a column of shape \(n \times 1\): y[:, None].

Checking a gradient

\[ \frac{\partial \loss}{\partial w} \approx \frac{\loss(w + \varepsilon) - \loss(w - \varepsilon)}{2\varepsilon} \]

\(\varepsilon = 10^{-6}\), one weight at a time

\[ \text{relative error} = \frac{\lVert \mathbf{g}_{\text{bp}} - \mathbf{g}_{\text{num}} \rVert}{\lVert \mathbf{g}_{\text{bp}} + \mathbf{g}_{\text{num}} \rVert} \]

Below \(10^{-6}\): the backward pass is right.

On the worked example: about \(10^{-10}\).

Exercise 3 checks its backpropagation this way.

Three ways to get it wrong

mistakesymptom
y is flat, not a columnP - y becomes \(n \times n\); shapes fail, or the loss is nonsense
no division by \(n\)gradients \(n\) times too large; the check fails by a factor of \(n\)
the ReLU mask forgottenrelative error of order one, only in the first layer

Run the gradient check first, on three examples and two hidden units. It finds all three in a second.

The frame holds

Model

composed layers

the only new part

Loss

cross-entropy

as in lecture 3

Optimiser

gradient descent

backpropagation computes the gradient, it is not an optimiser

Checkpoint

A network has N weights. How many forward passes does the numerical gradient need, and why is it not used for training?

Break

Ten minutes

Block 3

Making deep networks train

Activation functions

Three panels. The sigmoid rises from 0 to 1, and its derivative is a bump with a maximum of 0.25 at zero. The hyperbolic tangent rises from −1 to 1, and its derivative is a bump with a maximum of 1. The ReLU is zero for negative inputs and the identity for positive inputs, and its derivative is a step from 0 to 1.
Solid: the function. Dashed: its derivative. The derivative of the sigmoid is at most 0.25.

Choosing an activation

rangelargest derivativeuse
sigmoid(0, 1)0.25output, for a probability
tanh(−1, 1)1hidden, before 2010; still in the cells of lecture 8
ReLU[0, ∞)1hidden, the default
leaky ReLU(−∞, ∞)1hidden, when units die

tanh beats sigmoid as a hidden activation on both counts: it is centred on zero, and its derivative reaches 1 rather than 0.25.

Vanishing gradients

Backward through \(L\) sigmoid layers multiplies \(L\) factors \(\sigma'(z) \le 0.25\).

Eight hidden layers at initialisation: the gradient of the first layer is more than 100,000 times smaller than that of the last.

ReLU with He initialisation: a factor of about 3.5.

The size of the weight gradient against the hidden layer from 1 to 8, on a logarithmic axis. For sigmoid units it rises by more than five orders of magnitude from layer 1 to layer 8. For ReLU units it stays within one order of magnitude.

0.25 to the seventh

\[ \sigma'(z) \le 0.25 \quad \text{at every layer} \]
\[ \text{seven hops, layer 8 to layer 1}: \quad 0.25^7 = \frac{1}{16{,}384} \]
\[ \text{measured shrinkage: } \frac{1}{4.1 \times 10^{5}} \]

Worse than the bound, since \(\sigma'\) reaches 0.25 only at \(z = 0\), and the weights shrink the signal too.

ReLU as the default

\[ \mathrm{ReLU}(z) = \max(0, z) \] \[ \mathrm{ReLU}'(z) = \begin{cases} 1 & z > 0 \\ 0 & z < 0 \end{cases} \]

An active unit passes the gradient through unchanged.

A unit that is inactive for every example receives no gradient and stays dead. The initial weights and the learning rate decide how many die.

The other direction

The same product can grow instead of shrink.

Factors above one, raised to the depth, give a gradient too large to step with: the loss jumps, or becomes nan.

The cure is to cap the size of the whole gradient before the step.

Lecture 8 clips, where 48 time steps act like 48 layers.

Zero initialisation

Start every weight at the same value, for example zero.

Every hidden unit computes the same output, receives the same gradient and takes the same step.

After training, the units are still identical: the layer acts as one unit.

The initial weights are therefore random. Randomness breaks the symmetry.

Symmetry breaking, in numbers

Four hidden units, every weight started at 0.1, 20 epochs on the bearings.

\[ \mW_1 = \begin{pmatrix} 0.911 & 0.911 & 0.911 & 0.911 \\ 0.449 & 0.449 & 0.449 & 0.449 \end{pmatrix} \]

They moved, and they moved together. Four units, one distinct column.

Started at exactly 0: every unit is inactive, so nothing moves at all. Only the output bias learns.

Scale matters

A grid of histograms of the activations of a tanh network of width 100 in layers 1, 3, 5 and 8. Top row, weights with standard deviation 0.01: the activations collapse to zero from layer 3. Middle row, standard deviation 1: the activations pile up at minus one and plus one. Bottom row, the Glorot scale: the activations stay spread in every layer.
tanh units, 100 per layer. Too small: the signal dies out by layer 3. Too large: 78% of the units of layer 5 saturate at ±1, where the derivative is near zero. At the Glorot scale, the activations keep a spread.

Glorot and He

\[ \text{Glorot:} \quad \mathrm{Var}(w) = \frac{2}{n_{\text{in}} + n_{\text{out}}} \] \[ \text{He:} \quad \mathrm{Var}(w) = \frac{2}{n_{\text{in}}} \]

Glorot for sigmoid and tanh, He for ReLU. For layers of equal width, Glorot is \(1/n_{\text{in}}\).

shape = (n_in, n_out)
W = rng.standard_normal(shape)
W *= np.sqrt(2 / n_in)  # He

Scale the inputs

The bearings: vibration about 1.8 mm/s, temperature about 55 °C.

A sensible weight for one is a hopeless weight for the other.

after 50 epochstraining losstest
raw0.32590.0%
standardised0.13394.6%

90.0% is the constant healthy model of lecture 3. On raw features the network learned nothing in 50 epochs.

One example or all of them

All \(n\) examples

  • The exact gradient
  • One step costs \(n\) examples

One example

  • A noisy gradient
  • One step costs one example

A minibatch of \(B\) examples sits between: a gradient averaged over \(B\), and \(n / B\) steps per epoch.

One epoch, counted

1,000 training bearings, one pass:

\(B\)steps
11,000
3232
1,0001

Each row costs the same: 1,000 examples through the network, forward and backward.

Same cost, a thousandfold difference in how far the weights travel.

The noisy gradient, measured

Two panels. Left, box plots of the angle between a minibatch gradient and the full gradient for batch sizes 1, 8, 32, 128 and 1000, shrinking as the batch grows. Right, the median angle against the batch size on a logarithmic axis, falling from 46 degrees to 0.
The angle to the full-batch direction: 46° at \(B = 1\), 9° at \(B = 32\), 0° at \(B = n\). 200 draws each.

Minibatch SGD

Pseudocode

for each epoch:
  shuffle the n examples
  for each batch of B:
    g ← gradient on the batch
    W ← W − η g

numpy

for epoch in range(epochs):
    order = rng.permutation(n)
    for s in range(0, n, B):
        rows = order[s:s + B]
        g = grad(X[rows], y[rows])
        W = W - lr * g

Batch size

Training loss against epochs on the bearing data for batch sizes 1, 32 and 1000. The curve for batch size 1 is low from the first epoch and visibly noisy, the curve for 32 is smooth and reaches the same level after a few epochs, and the curve for 1000 is smooth but still above 0.3 after 20 epochs.
The same network and learning rate of 0.1 for 20 epochs. \(B = 1\): 1000 noisy steps per epoch. \(B = 1000\): one exact step per epoch, and a loss of 0.33 after 20 epochs.

The learning rate, again

Training loss on a logarithmic axis against epochs for learning rates 0.01, 0.3 and 10, with batches of 32. The loss for 0.01 falls slowly, the loss for 0.3 falls fast, and the loss for 10 jumps up and down with a peak above 7.
Batches of 32. \(\eta = 0.01\): slow. \(\eta = 0.3\): fast. \(\eta = 10\): the loss jumps, up to 7.3. Momentum and Adam, in lecture 6, adapt the steps.

Dead units, counted

2-16-1 on the bearings, 100 epochs, counting units that no training point switches on.

\(\eta\)deadloss
0.30 of 160.135
1.00 of 160.145
3.00 of 160.224
10.014 of 160.471

Oversized steps drive a unit below zero for every bearing, and the mask of block 2 keeps it there.

Rate and batch together

A three by three grid of the training loss after 20 epochs, for learning rates 0.01, 0.1 and 1.0 against batch sizes 8, 32 and 256. The best rate for each batch size rises with it: 0.1 for batch 8, and 1.0 for batches 32 and 256.
The best rate rises with the batch size: 0.1 at \(B = 8\), 1.0 at \(B = 32\) and \(B = 256\). At \(B = 256\), \(\eta = 0.01\) reaches only 0.562 against 0.138 at \(\eta = 1.0\).

A first recipe

  1. Standardise the inputs on the training set
  2. ReLU hidden units, He initialisation
  3. Batches of 32 to 256
  4. Try rates by factors of three, watch the training loss
  5. Check the gradient once, on a tiny network

Enough to train the networks of this course. Lecture 6 makes step 4 easier with Adam, which still has a rate to choose.

Checkpoint

You double the batch size and keep the number of epochs. What happens to the number of steps, and to the noise of each step?

Takeaways

  1. A network is logistic regression on features it learns itself.
  2. One ReLU unit is a ramp; a network is a sum of ramps.
  3. Depth needs a nonlinearity between the layers.
  4. Backpropagation is the chain rule, with every piece computed once.
  5. Activations and initialisation decide whether the gradients survive.
  6. Standardise the inputs, or the first layer cannot start.
  7. Minibatch SGD trades noise for cheaper steps.

What changed from lecture 3

Logistic regressionNetwork
Featuresgiven, or built by handlearned
Model\(\sigma(\vw\T\vx + b)\)\(\sigma(\mW_2\T g(\mW_1\T\vx + \vb_1) + b_2)\)
Parameters\(d + 1\)\(dm + m + m + 1\)
Gradientone formulabackpropagation
Loss, optimiserunchanged

When to reach for a network

Probably not

  • Few features, each meaningful
  • A boundary close to a line, or to boxes
  • Little data

The bearings: the line ties the network at 94.7%.

Yes

  • Raw signals: pixels, audio, text
  • Many features, no obvious one to build
  • Plenty of data

Lecture 7 onwards.

Lecture 5 in three choices

Model

composed nonlinear layers

the change from lecture 3: only the model

Loss

cross-entropy, squared error

unchanged since lectures 1 and 3

Optimiser

gradient descent

on minibatches, with gradients from backpropagation

Further reading

All three books are free to read online.

Next

Lecture 6

Optimisers and schedules, regularisation of networks, and PyTorch with its training loop.

Exercise 3

Two moons and Fashion-MNIST: the forward pass and backpropagation of today in numpy, checked against a numerical gradient, then PyTorch.

It follows lecture 6 and uses lectures 5 and 6.