Backpropagation: How Neural Networks Learn via Gradient-Based Weight Adjustment
Backpropagation is the training method that makes a neural network learn by computing how each parameter (weight and bias) should change to reduce a chosen loss function. Concretely, backpropagation uses the chain rule to compute gradients of the loss with respect to each layer’s parameters efficiently, then applies an optimization step such as gradient descent.
A typical training iteration has two phases:
- Forward pass: compute predictions and the loss.
- Backward pass: propagate “blame” (error signal) from the loss back through layers to get gradients.
- Parameter update: update weights so the loss decreases.
How backpropagation connects “error” to “weight updates”
For parameters (e.g., all weights and biases), training tries to reduce a scalar objective . Gradient-based learning updates parameters in the opposite direction of the gradient:
where is the learning rate. Backpropagation is the mechanism that efficiently computes for multi-layer networks by reusing intermediate derivatives from the forward pass.
Mini example setup (2 layers + loss)
We’ll build a minimal network with:
- Layer 1: affine transform + nonlinearity
- Layer 2: affine transform to produce a scalar prediction
- Loss: mean squared error (MSE) for simplicity
This keeps the math small while still showing the core idea: gradients flow backward, determining exactly how weights change.
Key terms introduced here:
- Activation function
- Backpropagation
- Gradient
Backpropagation Intuition (Chain Rule + Gradient Descent)
Two-layer backpropagation with a concrete weight-update example
- 1Step 1
Let be the input and the target be . Use a 1-hidden-unit, 2-layer network:
Layer 1: where
Layer 2: where
Choose sigmoid .
Initialize: .
- 2Step 2
Use mean squared error (single example):
- 3Step 3
Compute:
-
- 4Step 4
First derivative of loss w.r.t. prediction:
Numerically:
- 5Step 5
Since :
Numerically:
- 6Step 6
Compute derivative of loss w.r.t. hidden activation :
So:
- 7Step 7
For sigmoid, .
Numerically:
- 8Step 8
Since :
Numerically:
- 9Step 9
Choose learning rate .
Gradient descent update:
Updates:
Interpretation: because the prediction is too low (), the gradients push weights in the direction that increases in the next iteration.
Weight-adjustment interpretation (why signs make sense)
In our example, , so we want to increase the prediction. The key quantity is
A negative gradient means increasing would decrease the loss. Because
- is also negative, gradient descent increases .
- the error then backpropagates through to influence and .
This is the core mechanism: backpropagation turns the mismatch at the output into a layer-by-layer gradient signal, which the optimizer converts into weight adjustments.
loss function and gradient descent together form the learning loop.
Pro Tip: Track gradients through the computational graph
Write the forward computation as a small graph (like Layer 1 → Layer 2 → Loss). Then in the backward pass, multiply derivatives using the chain rule. This prevents sign mistakes and clarifies how each parameter affects the loss.
Beware of vanishing gradients with saturating activations
If you use sigmoid/tanh, their derivatives can become small when the units saturate. Backpropagated gradients can shrink across many layers, slowing or stopping learning.
Backpropagation training workflow
Forward pass
Step ACompute layer outputs and the loss for the current mini-batch."
Compute output gradient
Step BDifferentiate the loss with respect to predictions."
Backpropagate through layers
Step CUse the chain rule to get gradients for each weight/bias."
Update parameters
Step DApply ."
Repeat until convergence
Step ERepeat over batches/epochs to reduce loss and improve accuracy."
Numerical gradients in the two-layer example
Negative gradients imply gradient descent increases the corresponding parameter.
Common questions about backpropagation
Backpropagation quick recall
Knowledge Check
In backpropagation, what is the main mathematical idea used to compute gradients?