Lessons › Chapter 8: Neural networks
The forward pass
A forward pass is how a network makes a prediction. It starts with the input: here, two numbers describing a photo.
Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.
Start the interactive lessonStep by step
How does it decide?
Maya asks Leo to walk her through exactly how the network turns a cheque scan into a number.
Numbers go in
A forward pass is how a network makes a prediction. It starts with the input: here, two numbers describing a photo.
Layer 1 lights up
Each neuron in layer 1 takes a weighted sum of the inputs and applies ReLU. One neuron’s sum was negative, so it outputs 0.
The output appears
Layer 2 does the same with layer 1’s outputs, then a sigmoid turns the result into a chance: 0.76, a 76% chance this photo is a cat.
It’s just multiply and add
Each layer is a matrix times a vector, plus a bias, plus a bend: exactly the dot products from the math chapter. Graphics chips are great at this, which is why AI runs on GPUs.
In real life: “Hey, lights on”
When you talk to a voice assistant, the sound of your voice is turned into numbers and pushed through a network in one forward pass, layer by layer, in a fraction of a second. Out comes the command: lights on.
Quick check: In a forward pass, data flows…
- From the input to the output, layer by layer (correct)
- From the output back to the input
- In a random order
The forward pass computes each layer from the previous one until it reaches the output.
Pseudocode
x = [0.8, 0.2] # input h = relu(W1 × x + b1) # layer 1 → [0.9, 0.0, 0.4] y = sigmoid(W2 × h + b2) # layer 2 → 0.76 prediction = y # a 76% chance it's a cat
Key terms
- forward pass
- Running an input through the network, layer by layer, to get a prediction.
Build it: A neural network that reads handwriting (35 min, runs in your browser)
See the projectIn the news
Recent models and papers that build on this idea: