The graph of one neuron 1.50 x 0.80 w −0.40 b u = w · x z = u + b ŷ = σ(z) L = ½(ŷ − t)²
The computation of a single neuron is split into four operations: multiply, add, sigmoid, loss. The inputs are x = 1.50, w = 0.80, b = −0.40; the target is t = 1. Tap an input node to type a value.
Multiply 1.50 x 0.80 w −0.40 b 1.20 u = w · x z = u + b ŷ = σ(z) L = ½(ŷ − t)²
u = w · x = 1.20. Each node does only its own job and hands the result to the node at the tip of the arrow.
Add 1.50 x 0.80 w −0.40 b 1.20 u = w · x 0.80 z = u + b ŷ = σ(z) L = ½(ŷ − t)²
z = u + b = 0.80.
Sigmoid 1.50 x 0.80 w −0.40 b 1.20 u = w · x 0.80 z = u + b 0.69 ŷ = σ(z) L = ½(ŷ − t)²
ŷ = σ(z) = 0.690.
Loss 1.50 x 0.80 w −0.40 b 1.20 u = w · x 0.80 z = u + b 0.69 ŷ = σ(z) 0.05 L = ½(ŷ − t)²
L = ½ (ŷ − t)² = 0.048. The forward pass is done. Now the question: if w changes a little, how much does L change?
The backward pass starts 1.50 x 0.80 w −0.40 b 1.20 u = w · x 0.80 z = u + b 0.69 ŷ = σ(z) 1 ∂L/∂L
The backward pass starts at the loss: ∂L/∂L = 1. The brass nodes now show not a value but the derivative of the loss with respect to that node.
From the loss to ŷ −0.310 1.50 x 0.80 w −0.40 b 1.20 u = w · x 0.80 z = u + b −0.31 ∂L/∂ŷ 1 ∂L/∂L
The local derivative of the loss node is ∂L/∂ŷ = ŷ − t = −0.310. The box on the arrow shows this local derivative.
From ŷ to z 0.214 −0.310 1.50 x 0.80 w −0.40 b 1.20 u = w · x −0.07 ∂L/∂z −0.31 ∂L/∂ŷ 1 ∂L/∂L
The local derivative of the sigmoid is ŷ(1 − ŷ) = 0.214. Chain rule: incoming derivative times local derivative, ∂L/∂z = −0.310 · 0.214 = −0.066.
Addition passes the derivative on 1 1 0.214 −0.310 1.50 x 0.80 w −0.07 ∂L/∂b −0.07 ∂L/∂u −0.07 ∂L/∂z −0.31 ∂L/∂ŷ 1 ∂L/∂L
The local derivative of addition with respect to both inputs is 1; the incoming derivative passes unchanged to both: ∂L/∂u = ∂L/∂b = −0.066.
Multiplication swaps 0.80 1.50 1 1 0.214 −0.310 −0.05 ∂L/∂x −0.10 ∂L/∂w −0.07 ∂L/∂b −0.07 ∂L/∂u −0.07 ∂L/∂z −0.31 ∂L/∂ŷ 1 ∂L/∂L
For u = w · x, ∂u/∂w = x and ∂u/∂x = w: each input gets the other's value. ∂L/∂w = −0.066 · 1.50 = −0.099, ∂L/∂x = −0.066 · 0.80 = −0.053.
Why it matters 0.80 1.50 1 1 0.214 −0.310 −0.05 ∂L/∂x −0.10 ∂L/∂w −0.07 ∂L/∂b −0.07 ∂L/∂u −0.07 ∂L/∂z −0.31 ∂L/∂ŷ 1 ∂L/∂L
However large, every network is such a graph. Libraries like PyTorch record the graph during the forward pass, and when backward is called they multiply these local derivatives from the end to the start to find every gradient.