AI · 7.2
Backpropagation: How a Network Learns
Name
Class
Date
Mark / 22
Section A
Circle the letter of the correct answer. One mark each.
- 1What does backpropagation compute?1
- AThe best learning rate for the network
- BThe output of the network for a new input
- CThe gradient of the loss with respect to every weight
- DThe number of layers the network needs
- 2If dy/du = 3 and du/dx = 4, what is dy/dx?1
- A0.75
- B1
- C7
- D12
- 3In which direction does the backward pass travel through the network?1
- AFrom the loss back towards the inputs
- BFrom the inputs towards the loss
- CIn a random order each time
- DFrom the middle layer outwards
- 4In the graph u = w × x with x = 2, a gradient of 0.2 arrives at u. What is dL/dw?1
- A0.1
- B0.2
- C0.4
- D2.2
- 5What is the local derivative of a sigmoid node whose output is a?1
- Aa(1 − a)
- B1
- Ca²
- D1 − a
- 6Roughly how much does a backward pass cost compared with a forward pass?1
- ANothing: it is free
- BAbout a million times as much
- CExactly the same
- DAbout twice as much
- 7Why do networks start with random weights rather than all zeros?1
- ARandom weights mean no training is needed at all
- BIdentical weights would make every neuron learn the same thing
- CZero weights would make training far too fast to control
- DComputers cannot store a weight of exactly zero
- 8A training run's loss suddenly jumps to NaN. What is a likely cause?1
- AToo few epochs
- BThe test set being too small
- CVanishing gradients
- DExploding gradients
- 9What does loss.backward() do in PyTorch?1
- AResets every gradient back to zero
- BRuns backpropagation to compute every parameter's gradient
- CRuns the network's forward pass on new data
- DUpdates every weight using gradient descent
- 10With a sigmoid output and cross-entropy loss, what is the gradient of the loss with respect to the output's z?1
- Ay − p
- Bp − y
- Cp(1 − p)
- D2(p − y)
Section B
Answer in the space provided. The number of marks tells you how many separate points to make.
- 1ExplainExplain what backpropagation is and why it is needed to train neural networks.4
- 2CalculateA neuron computes z = wx + b and a = σ(z), with loss L = (a − y)². Given dL/da = −0.5 and a = 0.75, calculate dL/dw when x = 2.4
- 3DescribeDescribe the steps of the training loop used to train a neural network.4
Mark scheme
Section A
Section B
1 Explain what backpropagation is and why it is needed to train neural networks. 4
One mark for each of the following, to a maximum of 4.
- Training needs the gradient of the loss for every weight
- Calculating each separately / by nudging would be far too slow
- Backpropagation applies the chain rule backwards from the loss
- It gets all the gradients in one backward pass, about twice the cost of a forward pass
Model answer. Gradient descent needs the gradient of the loss with respect to every weight in the network, and a network can have millions of weights. Estimating each gradient separately, by nudging one weight at a time, would need millions of forward passes per step and be far too slow. Backpropagation applies the chain rule backwards through the network, from the loss towards the inputs, multiplying local derivatives at each layer. It produces every gradient in a single backward pass, costing only about twice a forward pass, which makes training large networks practical.
2 A neuron computes z = wx + b and a = σ(z), with loss L = (a − y)². Given dL/da = −0.5 and a = 0.75, calculate dL/dw when x = 2. 4
One mark for each of the following, to a maximum of 4.
- da/dz = a(1 − a) = 0.75 × 0.25 = 0.1875
- dL/dz = −0.5 × 0.1875 = −0.09375
- dz/dw = x = 2
- dL/dw = −0.1875
Model answer. The sigmoid's local derivative is da/dz = a(1 − a) = 0.75 × 0.25 = 0.1875. By the chain rule, dL/dz = dL/da × da/dz = −0.5 × 0.1875 = −0.09375. Since z = wx + b, dz/dw = x = 2, so dL/dw = −0.09375 × 2 = −0.1875.
3 Describe the steps of the training loop used to train a neural network. 4
One mark for each of the following, to a maximum of 4.
- Forward pass: compute the outputs for a batch
- Compute the loss by comparing outputs with targets
- Backward pass: backpropagation computes the gradients
- Update the weights with gradient descent / an optimiser, then repeat for batches and epochs
Model answer. For each batch of training examples, the network first does a forward pass, computing its outputs layer by layer. The loss is calculated by comparing those outputs with the targets. A backward pass then uses backpropagation to compute the gradient of the loss with respect to every weight and bias. Finally an optimiser such as gradient descent or Adam updates every parameter a small step against its gradient. The loop repeats for every batch, and the whole dataset is passed through many times, once per epoch.