Example 1 · one neuron · two inputs · every number checkable by hand

Fruit Stand Neuron

A stall sells apples and bananas and charges a small bag fee. We only have receipts. One neuron will work out the prices from the receipts alone, one small calculation at a time.

The network

1 apples x₁ 2 bananas x₂ 1 always 1 (for the bias) w₁ = 1 w₂ = 1 b = 0 Σ weighted sum z = 3 ReLU ŷ = 3 ŷ prediction loss 2 paid y = 5

Green = numbers flowing forward (left to right). Red dashed = blame flowing backward (right to left). Yellow = the thing being computed right now.

FORWARD

Keyboard: → or space for Next, ← for Back.

Ask the network

→ predicted total

The network was never shown this receipt. The true answer uses the hidden rule 2·apples + 1·bananas + 1, which the network never sees.

What the neuron has learned

w₁ · apple price
true 2
w₂ · banana price
true 1
b · bag fee
true 1

Start: w₁ = 1, w₂ = 1, b = 0. Learning rate η = 0.1. Parameters are rounded to 4 decimals after each update, so the numbers you see are exactly the numbers used.

The receipts

#applesbananaspaid

The network sees only these four rows. It cycles through them in order. One pass over all four is one epoch.

Training log

stepŷerrorlossw₁w₂b

Nothing trained yet. Weights shown are the values after each update.

Cheat sheet

Forward pass

z = w₁·x₁ + w₂·x₂ + b
ŷ = ReLU(z) = max(0, z)
L = ½ (ŷ − y)²

Backward pass (chain rule)

δ = (ŷ − y) · ReLU′(z)
∂L/∂w₁ = δ · x₁
∂L/∂w₂ = δ · x₂
∂L/∂b = δ · 1

Update (gradient descent)

w ← w − η · ∂L/∂w
η = 0.1

ReLU′(z) is 1 when z > 0 and 0 otherwise. With these receipts the neuron is always active, so the derivative is always 1.