A Level · Topic 18.1
A-Level Computer Science 9618 / Topic 18 / A2

Networks that learn.

An artificial neural network is a web of very simple units, each just multiplying, adding and passing on a number. Arrange enough of them in layers, adjust their weights by back propagation of errors, and the network can learn to recognise faces, translate speech or drive a car.

The key idea

An artificial neural network (ANN) is made of nodes (artificial neurons) arranged in an input layer, one or more hidden layers and an output layer. Each connection has a weight. A node calculates the weighted sum of its inputs plus a bias and passes it through an activation function. Deep learning uses ANNs with many hidden layers that learn features from raw data by themselves. The network is trained by back propagation of errors: compare the output with the target, pass the error backwards through the layers, and adjust every weight a little to reduce the error.

Input layerHidden layer (ReLU)Output layer 0.4−0.60.30.8 1.5−1.0 10.50.20.50.2 x1x2 b = 0.1b = −0.2b = 0.4 each node: weighted sum of inputs + bias, then activation
Fig. 1: a small neural network with weights and biases; the values in the nodes are a forward pass for inputs 1 and 0.5
Section 01

From neuron to network.

An artificial neuron is loosely modelled on a brain cell: it receives signals, combines them, and fires a signal of its own. Its behaviour is set entirely by its weights and bias, which are the numbers the network learns.

Worked example A forward pass
Use the weights and biases in Fig. 1 to calculate the output of the network for inputs x1 = 1 and x2 = 0.5. The hidden nodes use ReLU; the output node uses no activation.
  1. Top hidden node: 0.4 × 1 + (−0.6) × 0.5 + 0.1 = 0.4 − 0.3 + 0.1 = 0.2. ReLU(0.2) = 0.2.
  2. Bottom hidden node: 0.3 × 1 + 0.8 × 0.5 + (−0.2) = 0.3 + 0.4 − 0.2 = 0.5. ReLU(0.5) = 0.5.
  3. Output node: 1.5 × 0.2 + (−1.0) × 0.5 + 0.4 = 0.3 − 0.5 + 0.4 = 0.2.
Answer: The network outputs 0.2
Your turn
A single neuron has weights 0.6 and 0.6, bias −1 and a step activation (output 1 if the sum is at least 0). For which pair of binary inputs does it output 1?
Examiner trap

Do not forget the bias. It is added to the weighted sum before the activation function, and leaving it out changes the answer.

Section 02

Deep learning.

Older machine learning methods needed people to decide which features to measure (the length of an email, the number of links). Neural networks with many layers can learn useful features straight from raw data, which is why they transformed machine learning.

Machine learning (classical)Deep learning
Featureschosen by peoplelearned automatically by the layers
Data neededcan work with smaller data setsvery large data sets
Hardware and timemodestheavy: GPUs, long training
Explaining decisionsoften easier (e.g. a regression line)hard: a black box
Examiner trap

Deep learning is not a separate fourth category alongside supervised, unsupervised and reinforcement learning. It is a technique (deep neural networks) that can be used within any of them.

Stage 1 · Learn

Check what the sim just showed you

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

What does a node in a hidden layer calculate before applying its activation function?

Quick check+10 XP

What makes a neural network a deep learning network?

Quick check+10 XP

During back propagation, in which direction is the error passed through the network?

Quick check+10 XP

Using Fig. 1, what is the value of the top hidden node?

Section 03

Back propagation of errors.

A new network starts with random weights, so its first predictions are poor. Back propagation is how it learns: each mistake is used to work out how much each weight was to blame, and every weight is nudged in the direction that reduces the error.

Worked example One weight update
A single neuron with no bias outputs y = w × x. For x = 2 the target is 3, and w = 0.5. The error is E = ½(y − target)2, whose gradient with respect to w is (y − target) × x. Carry out one update with learning rate 0.1.
  1. Forward pass: y = 0.5 × 2 = 1.
  2. Error: y − target = 1 − 3 = −2, so E = ½ × 4 = 2.
  3. Gradient: (−2) × 2 = −4.
  4. Update: w = 0.5 − 0.1 × (−4) = 0.5 + 0.4 = 0.9.
  5. Check: new y = 0.9 × 2 = 1.8, error −1.2, E = 0.72. The error has fallen from 2 to 0.72.
Answer: w becomes 0.9
Your turn
Carry out the next update from w = 0.9 (same x, target and learning rate).
Examiner trap

"The error is sent back and the weights are changed" is too vague for full marks. Say that the error is calculated at the output, propagated backwards layer by layer, and each weight is adjusted in proportion to its contribution to the error.

Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to A Level Paper 3 and Paper 4 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

A neuron has inputs 1 and 0, weights 0.7 and 0.4, a bias of −0.5 and a step activation (output 1 if the sum is at least 0). What is the weighted sum and the output?

Exam style+20 XP

A weight is 0.8, its gradient is 2.5 and the learning rate is 0.2. What is the weight after one gradient descent update?

Exam style+20 XP

Which is the best reason to use deep learning rather than a simple regression model?

Exam style+20 XP

What is the likely effect of setting the learning rate too high during training?

Skill unlocked

Neural networks and back propagation, mastered.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
The structure of artificial neural networks, forward passes, deep learning and why it is used, and back propagation of errors with weight updates.