Best on a larger screen — the animation and controls have more room to breathe.
Inputs

Forward Propagation

Forward propagation is the computation a neural network runs to turn an input into a prediction: each layer multiplies the incoming values by its weights, adds a bias, and applies a nonlinearity, passing the result left to right until the output layer reports a score for every possible answer. Once training ends, inference consists of running this forward pass.

Think of each layer as a panel of judges. Every judge reads all incoming evidence using a fixed scoring sheet (its weights), totals the score, and passes the result to the next panel. The network here recognizes handwritten digits: 784 pixel brightnesses go in, ten digit scores come out, and the largest score is the prediction.

How Forward Propagation Works

The architecture is 784 → 25 → 25 → 10: the flattened 28×28 image, two hidden panels of 25 judges each, and a final panel of 10, one per digit.

Each judge performs a two-part computation, which the animation separates into two steps. First comes the weighted sum, or pre-activation z = w·a + b: multiply each input by its weight, sum the products, and add a bias. Nothing prevents z from coming out negative when negative weights outweigh positive ones. Next comes the ReLU nonlinearity, max(0, z): negative values are clamped to zero so the judge goes silent, while positive ones pass through unchanged. Each weight sets the strength of one connection: positive weights (drawn green) excite the next judge, and negative weights (drawn magenta) inhibit it.

The output panel skips ReLU. Its ten raw scores, called logits, pass through softmax, pᵢ = exp(zᵢ) / Σⱼ exp(zⱼ), which exponentiates every score and normalizes the results so they sum to 1. Because exponentiation turns a logit gap into a probability ratio of e^gap, a large lead concentrates nearly all of the probability mass on one class. The prediction is the argmax: whichever digit holds the most probability.

The whole pass costs 784·25 + 25·25 + 25·10 = 20,475 multiply-adds, one per connection, in a single layer-by-layer sweep (this counts connections, excluding bias additions and activation or softmax work; the implementation still uses loops or matrix operations). Connection count supplies capacity, while the trained weight values supply digit recognition: random values in the same 20,475 connections provide no learned recognition (chance-level accuracy on average, varying across random draws). Because the 19,600 connections into the first hidden layer are too dense to draw legibly, the canvas shows a representative subset between the later layers.

Forward Propagation Step by Step

The default input is a real MNIST test image of a handwritten 7, evaluated by a real trained network, so every number on screen comes from a live forward pass.

  1. Input. The 28×28 image flattens into 784 pixel values. Ink is high; background is near zero.
  2. Layer 1 (weighted sum). Each of the 25 judges computes z₁ = x·W₁ + b₁ over all 784 pixels. Ten of the 25 come out negative (drawn blue); the rest are positive (dark).
  3. Layer 1 (ReLU). max(0, z₁) zeroes the ten negative judges (they fade to empty), while the positive ones keep their values as the activations a₁.
  4. Layer 2 (weighted sum). The drawn connections light up and each layer-2 judge shows z₂ = a₁·W₂ + b₂. Nine of 25 are negative.
  5. Layer 2 (ReLU). Negatives are zeroed again, giving a₂.
  6. Output (logits). Ten raw scores z₃ = a₂·W₃ + b₃ appear. The judge for 7 posts about 19.0; the runner-up, digit 2, reaches roughly 1.2; most of the rest are negative.
  7. Predict. Softmax exponentiates that 17.9-point gap until almost all of the probability mass lands on one digit. The network predicts 7 at ~100%.

As the animation plays, blue marks a negative pre-activation, and the ReLU steps fade blue cells to empty. The same two-step pattern (raw sum, then nonlinearity) repeats twice in the hidden layers and once more as logits followed by softmax at the output.

Why a Confident Network Can Still Be Wrong

Softmax confidence measures decisiveness, not truth. The exponential rewards whichever logit leads, however the lead was earned. Because the judges' scoring sheets stay frozen after training, an unusual image that excites the wrong judges produces a confident wrong verdict through the same arithmetic that classified the 7 correctly.

The Misclassified variant loads, for each digit, the test image this exact network gets wrong with the highest confidence: real images with predictions above 90% on the wrong answer. The seven beats are identical; only the input changes. The Ambiguous variant sits in between: correctly classified at ~75%, so softmax leaves a visible runner-up. Running all three variants for one digit shows that with the network fixed, where the probability lands is a property of the input-network pair. This network gets about 3.7% of the MNIST test set wrong, and some of those wrong answers carry high confidence.

Where the scoring sheets came from is covered next: Gradient Descent shows the update rule and Backpropagation shows how every weight learns its share of the blame.

Edge Cases

  • Dead-quiet judges. ReLU outputs zero whenever a weighted sum is negative, so many hidden neurons stay dark for any given image. This is expected behavior, because different images activate different subsets.
  • Saturated vs split softmax. A clean digit collapses the distribution to ~100% on one class; an ambiguous one leaves substantial mass on a runner-up. Both are valid forward passes differing only in the logit gap.
  • The all-zero input. With no ink, the first layer's weighted sums reduce to its biases, and later layers receive the activations those biases produce. The network still outputs a full probability distribution even on a blank image.

Common Mistakes

  • Confusing logits with probabilities. Logits are unbounded raw scores, so 19.0 is not "1900% sure." Only after softmax do the numbers form a distribution you can read as confidence.
  • Reading meaning into hidden neurons. Individual hidden judges rarely correspond to human-named features such as "loop detectors"; only the output layer has assigned meanings.
  • Dropping the nonlinearity. Without ReLU between them, two linear layers multiply out to one linear layer, so the hidden panels add no extra capacity.
  • Treating confidence as accuracy. As the Misclassified variant shows,

    90% softmax confidence on a wrong answer happens whenever one logit leads by a wide margin, whether that lead is deserved or not.