Backpropagation: How Neural Networks Learn via Gradient-Based Weight Adjustment

Backpropagation: How Neural Networks Learn via Gradient-Based Weight Adjustment

Verified Sources
Nov 4, 2026

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:

  1. Forward pass: compute predictions and the loss.
  2. Backward pass: propagate “blame” (error signal) from the loss back through layers to get gradients.
  3. Parameter update: update weights so the loss decreases.

How backpropagation connects “error” to “weight updates”

For parameters θ\theta (e.g., all weights and biases), training tries to reduce a scalar objective L(θ)L(\theta). Gradient-based learning updates parameters in the opposite direction of the gradient:

θ←θ−η∇θL\theta \leftarrow \theta - \eta \nabla_{\theta} L

where η\eta is the learning rate. Backpropagation is the mechanism that efficiently computes ∇θL\nabla_{\theta}L 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

  1. 1
    Step 1

    Let x=1x=1 be the input and the target be y=1y=1. Use a 1-hidden-unit, 2-layer network:

    Layer 1: h=σ(z1)h = \sigma(z_1) where z1=w1x+b1z_1 = w_1 x + b_1

    Layer 2: y^=z2\hat{y} = z_2 where z2=w2h+b2z_2 = w_2 h + b_2

    Choose sigmoid σ(t)=11+e−t\sigma(t)=\frac{1}{1+e^{-t}}.

    Initialize: w1=0.5,  b1=0.0,  w2=1.0,  b2=0.0w_1=0.5,\; b_1=0.0,\; w_2=1.0,\; b_2=0.0.

  2. 2
    Step 2

    Use mean squared error (single example):

    L=(y^−y)2L = (\hat{y}-y)^2
  3. 3
    Step 3

    Compute:

    1. z1=w1x+b1=0.5⋅1+0=0.5z_1 = w_1x+b_1 = 0.5\cdot 1 + 0 = 0.5

    2. h=σ(0.5)≈0.622459h=\sigma(0.5)\approx 0.622459

    3. y^=w2h+b2=1.0⋅0.622459+0=0.622459\hat{y} = w_2h+b_2 = 1.0\cdot 0.622459 + 0 = 0.622459

    4. L=(0.622459−1)2≈0.14216L=(0.622459-1)^2\approx 0.14216

  4. 4
    Step 4

    First derivative of loss w.r.t. prediction:

    ∂L∂y^=2(y^−y)\frac{\partial L}{\partial \hat{y}} = 2(\hat{y}-y)

    Numerically:

    ∂L∂y^=2(0.622459−1)≈−0.755082\frac{\partial L}{\partial \hat{y}} = 2(0.622459-1) \approx -0.755082
  5. 5
    Step 5

    Since y^=w2h+b2\hat{y}=w_2h+b_2:

    ∂L∂w2=∂L∂y^⋅∂y^∂w2=∂L∂y^⋅h\frac{\partial L}{\partial w_2} = \frac{\partial L}{\partial \hat{y}}\cdot \frac{\partial \hat{y}}{\partial w_2} = \frac{\partial L}{\partial \hat{y}}\cdot h ∂L∂b2=∂L∂y^⋅1\frac{\partial L}{\partial b_2} = \frac{\partial L}{\partial \hat{y}}\cdot 1

    Numerically:

    ∂L∂w2≈(−0.755082)⋅0.622459≈−0.470007\frac{\partial L}{\partial w_2} \approx (-0.755082)\cdot 0.622459 \approx -0.470007 ∂L∂b2≈−0.755082\frac{\partial L}{\partial b_2} \approx -0.755082
  6. 6
    Step 6

    Compute derivative of loss w.r.t. hidden activation hh:

    ∂L∂h=∂L∂y^⋅∂y^∂h=∂L∂y^⋅w2\frac{\partial L}{\partial h} = \frac{\partial L}{\partial \hat{y}}\cdot \frac{\partial \hat{y}}{\partial h} = \frac{\partial L}{\partial \hat{y}}\cdot w_2

    So:

    ∂L∂h≈(−0.755082)⋅1.0=−0.755082\frac{\partial L}{\partial h} \approx (-0.755082)\cdot 1.0 = -0.755082
  7. 7
    Step 7

    For sigmoid, σ′(t)=σ(t)(1−σ(t))\sigma'(t)=\sigma(t)(1-\sigma(t)).

    ∂h∂z1=h(1−h)\frac{\partial h}{\partial z_1} = h(1-h)

    Numerically:

    ∂h∂z1≈0.622459(1−0.622459)≈0.235004\frac{\partial h}{\partial z_1} \approx 0.622459(1-0.622459) \approx 0.235004
  8. 8
    Step 8

    Since z1=w1x+b1z_1 = w_1x+b_1:

    ∂L∂z1=∂L∂h⋅∂h∂z1\frac{\partial L}{\partial z_1} = \frac{\partial L}{\partial h}\cdot \frac{\partial h}{\partial z_1} ∂L∂w1=∂L∂z1⋅x\frac{\partial L}{\partial w_1} = \frac{\partial L}{\partial z_1}\cdot x ∂L∂b1=∂L∂z1⋅1\frac{\partial L}{\partial b_1} = \frac{\partial L}{\partial z_1}\cdot 1

    Numerically:

    ∂L∂z1≈(−0.755082)⋅0.235004≈−0.177996\frac{\partial L}{\partial z_1} \approx (-0.755082)\cdot 0.235004 \approx -0.177996 ∂L∂w1≈−0.177996⋅1=−0.177996\frac{\partial L}{\partial w_1} \approx -0.177996\cdot 1 = -0.177996 ∂L∂b1≈−0.177996\frac{\partial L}{\partial b_1} \approx -0.177996
  9. 9
    Step 9

    Choose learning rate η=0.1\eta=0.1.

    Gradient descent update:

    θ←θ−η∂L∂θ\theta \leftarrow \theta - \eta \frac{\partial L}{\partial \theta}

    Updates:

    • w2←1.0−0.1(−0.470007)=1.0470007w_2 \leftarrow 1.0 - 0.1(-0.470007)=1.0470007
    • b2←0.0−0.1(−0.755082)=0.0755082b_2 \leftarrow 0.0 - 0.1(-0.755082)=0.0755082
    • w1←0.5−0.1(−0.177996)=0.5177996w_1 \leftarrow 0.5 - 0.1(-0.177996)=0.5177996
    • b1←0.0−0.1(−0.177996)=0.0177996b_1 \leftarrow 0.0 - 0.1(-0.177996)=0.0177996

    Interpretation: because the prediction is too low (y^<y\hat{y}<y), the gradients push weights in the direction that increases y^\hat{y} in the next iteration.

Weight-adjustment interpretation (why signs make sense)

In our example, haty=0.622<1\\hat{y}=0.622<1, so we want to increase the prediction. The key quantity is

fracpartialLpartialhaty=2(haty−y)<0\\frac{\\partial L}{\\partial \\hat{y}} = 2(\\hat{y}-y) < 0

A negative gradient means increasing haty\\hat{y} would decrease the loss. Because

  • partialL/partialw2=(partialL/partialhaty)cdoth\\partial L/\\partial w_2 = (\\partial L/\\partial \\hat{y})\\cdot h is also negative, gradient descent increases w2w_2.
  • the error then backpropagates through h=sigma(z1)h=\\sigma(z_1) to influence w1w_1 and b1b_1.

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 σ′(t)\sigma'(t) can become small when the units saturate. Backpropagated gradients can shrink across many layers, slowing or stopping learning.

Backpropagation training workflow

Forward pass

Step A

Compute layer outputs and the loss for the current mini-batch."

Compute output gradient

Step B

Differentiate the loss with respect to predictions."

Backpropagate through layers

Step C

Use the chain rule to get gradients for each weight/bias."

Update parameters

Step D

Apply θ←θ−η ablaθL\theta \leftarrow \theta - \eta \ abla_\theta L."

Repeat until convergence

Step E

Repeat 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

1 / 5
Question · Term

What does backpropagation compute?

Click to reveal
Answer · Definition

Gradients of the loss w.r.t. each parameter, using the chain rule through the network.

Knowledge Check

Question 1 of 4
Q1Single choice

In backpropagation, what is the main mathematical idea used to compute gradients?