Edexcel International Advanced Level Computer Science, point 16.1.4
Definition
Deep learning is a type of machine learning (6.2.2) that uses artificial neural networks with many layers (hence "deep") to learn patterns directly from large amounts of data. It is behind modern image and speech recognition, translation and large language models (6.2.3).
Function and why needed
Traditional programs need people to write rules, and simple machine learning needs people to choose which features to look at. Deep networks learn useful features by themselves from raw data (pixels, sound, text), which is how they achieve results on problems that were previously too hard (recognising faces, driving, translating speech).
a. Neural networks
A neural network is a model inspired by the brain, made of simple processing units (neurons) arranged in layers and joined by weighted connections.
Layers
| Layer | Job |
|---|---|
| Input layer | One neuron per input value (for example one per pixel). It passes the data in |
| Hidden layers | Do the learning: each layer finds more complex patterns than the one before (edges, then shapes, then objects). "Deep" networks have many hidden layers |
| Output layer | Gives the result: a category (cat, dog) or a number |
Every neuron in a layer is usually connected to every neuron in the next (fully connected).
A single neuron
- Multiply each input by its weight.
- Add them up, and add the bias.
- Pass the result through an activation function.
Weights
A weight is a number on each connection that sets how strongly one neuron influences the next. A large positive weight means a strong positive influence, a negative weight means the input discourages the neuron, and a weight near zero means little effect. The weights are what the network learns. Large networks have billions.
Bias
A bias is an extra number added to each neuron's sum, which shifts when the neuron "fires" (like an adjustable threshold). Without it, a neuron with all-zero inputs would always give zero. Biases are learned too.
Activation function
An activation function is applied to the neuron's sum to decide its output, and adds the non-linearity that lets the network learn complex patterns. Without it, a stack of layers would behave like one simple linear calculation.
| Function | Rule | Output range | Use |
|---|---|---|---|
| Step | 1 if , else 0 | 0 or 1 | Simple examples |
| Sigmoid | 0 to 1 | Probabilities, output layers | |
| ReLU | 0 upwards | Hidden layers (fast, widely used) | |
| Tanh | -1 to 1 | Hidden layers |
Forward propagation
Forward propagation is passing the input through the network, layer by layer, to get an output (a prediction).
Worked calculation (one neuron, sigmoid): inputs , weights , bias .
- .
- Sigmoid: .
- ReLU would give: .
Back propagation
Back propagation is how the network learns from its mistakes.
- Forward propagation gives a prediction.
- Compare it with the correct answer (the label) using a loss (error) function: how wrong was it?
- Work backwards from the output through the layers, calculating how much each weight and bias contributed to the error (the gradient, using calculus: the chain rule).
- Adjust every weight and bias a little in the direction that reduces the error (gradient descent), by an amount set by the learning rate.
- Repeat over many examples, many times (epochs), until the error is small.
Continuing the example: the target is 1 but the output was 0.455, so the error is large. One update (learning rate 0.5) changes the weights from to about and the bias from 0.1 to about 0.168. The output for the same input rises from 0.455 to about 0.487: closer to 1. Many repeats would push it further.
The training process
Overfitting: the network memorises the training data and does badly on new data. Tested on separate data (6.2.2), and reduced by more data, simpler networks, and regularisation.
Types of deep network (for interest)
- Convolutional (CNN): images.
- Recurrent (RNN) / LSTM: sequences (speech, text).
- Transformers: text and language models (6.2.3).
Benefits
- Learns features automatically, so needs little manual design.
- Very high accuracy on complex tasks (images, speech, language).
- Improves with more data.
- Handles unstructured data (images, audio, text).
- One approach applies to many problems.
Drawbacks
- Needs huge amounts of data (often labelled) and computing power (GPUs, 11.1.4).
- Slow, expensive and energy-hungry to train.
- A "black box": hard to explain why it made a decision.
- Can inherit bias from the training data (6.2.2).
- Can be fooled by small changes to the input (adversarial examples).
- Overfitting and a need for tuning.
- Raises ethical concerns (deepfakes, surveillance, jobs, 16.2.1).
Worked example
Task: a hospital trains a deep neural network to spot tumours in scans. Describe how it learns, and one issue.
- The input layer gets the pixel values of a scan.
- Hidden layers find patterns (edges, textures, shapes), and the output layer gives a probability of "tumour".
- Training: thousands of scans labelled by doctors are fed through (forward propagation). For each, the output is compared with the doctor's label. Back propagation adjusts the weights and biases to reduce the error. This repeats for many epochs.
- Testing: the network is checked on scans it hasn't seen, to measure its real accuracy and check for overfitting.
- Issues: if the training data came mostly from one hospital or group of patients, the network may be less accurate for others (bias), and doctors need to trust a decision that the network can't explain. It should support, not replace, a doctor's judgement.
Exam tip: define each term (layers, weights, bias, activation function) and describe forward propagation (input to output) and back propagation (the error is passed backwards to adjust weights). You may be asked to calculate a neuron's output: multiply, add, add the bias, then apply the activation. Mention that training needs lots of data and computing power, and the black-box problem.
Check yourself
What do the weights in a neural network represent?
How strongly each connection influences the next neuron; they are the values that the network learns.
What does an activation function do?
It is applied to a neuron's weighted sum to decide its output, adding the non-linearity needed to learn complex patterns.
What is the difference between forward propagation and back propagation?
Forward propagation passes the input through the layers to give a prediction. Back propagation passes the error backwards to work out how to adjust the weights and biases.
Calculate the output of a neuron with inputs 1 and 2, weights 0.5 and 0.25, bias 0 and ReLU
z = 1 × 0.5 + 2 × 0.25 + 0 = 1.0; ReLU(1.0) = 1.0.
Give two drawbacks of deep learning
Any two of: needs huge amounts of data and computing power; hard to explain (black box); can inherit bias; expensive and energy-hungry to train; can be fooled by small input changes.