Inside a neural network / 3 of 7

Forward propagation

8 minOpening your notebook…

What you’ll learn

  • Explain the main idea of “Forward propagation” in your own words.
  • Trace a concrete example and identify the assumptions behind it.
  • Apply the principle in a practice problem and recognize a common failure.

The idea, intuitively

A forward pass computes a prediction by moving inputs through the network. It records intermediate activations that can later be used to calculate gradients. No weights need to change during a forward pass.

Treat a neural network as a computation graph, not a mysterious black box. Follow a tiny input through each operation and keep track of tensor shapes. Distinguish the forward pass, gradient computation, and optimizer update. These three stages are connected but solve different parts of the learning problem.

Under the hood

For each layer, calculate z=Wx+b and then h=σ(z). At training time, compare the final prediction with a target using a loss function. Batch dimensions allow many examples to share the same parameters.

z(l)=W(l)h(l−1)+b(l)z^{(l)}=W^{(l)}h^{(l-1)}+b^{(l)}
In layer l, multiply the previous activation h by the current weights, then add the current biases. This z is passed through an activation to produce the next h.
A useful caution

Computing a prediction and updating parameters are separate operations.

A worked example

With x=2, w=3, b=−1, and ReLU, z=5 and h=5. The result follows directly from the current parameters.

How to use this way of thinking

Build intuition with a small calculation before scaling dimensions. Check whether the architecture can represent the desired relationship, then whether optimization can learn it, then whether the learned solution generalizes. A failure in any one of these stages needs a different response.

Try it yourself

Compute ReLU(2×(−3)+1).

Key takeaways

  • Activations and a prediction
  • Computing a prediction and updating parameters are separate operations.
  • Check the assumptions with a small example before applying this idea to a larger system.

Check your understanding

0/2 checked

Use feedback to learn. Quiz scores and lesson completion are tracked separately.

1What does a forward pass produce?
2True or false: A forward pass necessarily updates the network’s weights.
Go to lesson completion

Further reading

Original papers and reference material for this school. External resources may be in English and require internet access.

Dive into Deep Learning (opens a new tab)PyTorch: automatic differentiation (opens a new tab)

Finish this lesson

Mark this lesson complete when you’re ready to continue.

Start with a question

Introduction to AIAI FoundationsA brief history of AIAI FoundationsTypes of AIAI FoundationsAI, ML, and deep learningAI FoundationsUnderstanding generative AIAI FoundationsEthics, limitations, and responsibilityAI FoundationsLinear algebra for learning systemsMathematics for AIVectors, matrices, and similarityMathematics for AICalculus: measuring changeMathematics for AIDerivatives and gradientsMathematics for AIProbability and statisticsMathematics for AIOptimization and objectivesMathematics for AI
K to open · Escape to close