3.1.9 · D1Neural Network Fundamentals

Foundations — Backpropagation algorithm derivation

1,896 words9 min readBack to topic

This page assumes nothing. Before you can read the parent derivation, you must be fluent in the little alphabet it speaks. We build every letter here, in order, each one leaning on the one before it.


0 · What a neural network physically is

Picture a row of light bulbs feeding wires into another row of bulbs, feeding into another row, ending in one final bulb whose brightness is the network's "answer."

Figure — Backpropagation algorithm derivation
  • Each circle is a neuron — a tiny number-holder (its brightness).
  • Each arrow is a weight — a dial that says "how strongly does this bulb influence that one."
  • Numbers flow left → right. This left-to-right flow is the forward pass.

Everything below is just names for the parts of this picture.


1 · The layer index which row are we in?

Picture: the vertical columns in the figure above, numbered left to right. Why the topic needs it: every quantity (, , , , ) lives in a specific row, so we tag it with a superscript to say which row. means "the dials feeding into row 2."


2 · The activation how bright is a bulb?

Picture: is the brightness of the -th bulb in row .

Two anchors the parent uses immediately:

  • — the input row's activations are the input data .
  • — the last row's activation is the network's prediction, written ("y-hat", the guessed ).

3 · Weights and biases the dials

Figure — Backpropagation algorithm derivation

Picture: each arrow between two bulbs carries one ; each destination bulb also has a little "+" tap. Why the topic needs it: these are the knobs training adjusts. The entire goal of backprop is to find and — how to turn each dial.


4 · The pre-activation and the activation function

Each bulb does its job in two steps.

Step A — mix the inputs (linear).

Step B — squash it (nonlinear).

Figure — Backpropagation algorithm derivation

Why two steps and not one? Without the curved , stacking rows would collapse into one big linear map (a line of lines is still a line). The bend is what makes a deep network more powerful than a shallow one. (More in Activation functions and their derivatives.)


5 · Why vectors and matrices at all? The dot product

Row 's raw score is — "walk across all sources , multiply dial × brightness, add them up." That summed-products pattern is the dot product, and stacking it for every destination is matrix multiplication.


6 · The loss how wrong are we?

Picture: a ruler measuring the distance between the final bulb's brightness and where we wanted it. Example used by the parent: MSE, . (See Loss functions (MSE, cross-entropy).) Why the topic needs it: is the mountain we descend. Every derivative in backprop is "how does change if I wiggle this?"


7 · The derivative and the gradient — the slope of the mountain

Picture: stand on a hillside (the loss surface); the gradient is the arrow pointing straight uphill. To lower loss we step the opposite way — that is Gradient descent.


8 · The chain rule — the engine of the whole topic

Suppose depends on , which depends on . How does respond to ?

When influences through several paths (because a neuron fans out to many neurons in the next row), you add up the contributions from every path:

Figure — Backpropagation algorithm derivation

Why the topic needs it: the entire parent derivation is repeated chain-rule. The sum-over-paths version is exactly the that produces BP2's transpose.


9 · The Hadamard product

Picture: two stacks of numbers side by side; multiply each pair, keep the stack the same height. Why the topic needs it: in BP1/BP2, the incoming blame vector must be "gated" by each neuron's own local slope — a per-neuron multiply, i.e. , not a matrix product.


10 · The error signal the star of backprop

Picture: the "blame packet" the parent's Feynman story passes backward from person to person. Why the topic needs it: is the reusable cache. Compute it once per row (back to front) and every weight/bias gradient falls out cheaply — this is the dynamic-programming saving. Chained naively you'd recompute shared paths (linked to Vanishing and exploding gradients behaviour too).


Prerequisite map

Neuron and layer picture

Activation a

Weights W and bias b

Pre-activation z = Wa + b

Activation function sigma

Loss L measures wrongness

Derivative and gradient

Chain rule multi-path

Hadamard product gate

Error signal delta

Backprop four equations

Each block must be solid before the next makes sense; the final block is the parent topic.


Equipment checklist

Superscript means what?
A layer label, NOT a power — "the quantity living in row ."
What is and what shape?
The vector of neuron brightnesses (activations) in row .
What does compute?
The pre-activation: weighted sum of previous activations plus bias, before squashing.
In , which index is the destination?
is the destination neuron; is the source — "into , from ."
Difference between and ?
= raw pre-activation score; = squashed post-activation brightness.
Why do we need the nonlinear at all?
Without it, stacked layers collapse into one linear map; the bend enables curved patterns.
What is the gradient ?
The bundle of partial derivatives of w.r.t. each entry of — the uphill arrow.
State the single-path chain rule.
.
Why does a appear in the multi-path chain rule?
One knob influences through several neurons; add each path's contribution.
What does do?
Elementwise multiply — slot-by-slot, no summation (unlike a dot product).
Define in words and symbols.
— blame on row 's pre-activations, the cached backprop signal.
Why is worth caching?
Later-layer deltas are reused for earlier gradients — dynamic programming avoids recomputing shared paths.