The Feedforward Network
P6.nn-foundations.03 · Audience: Guest, Language professional, IT/ML learner · Prerequisites: Activation Functions
Where next?
Later in Neural-Network Foundations
This module unlocks
P6.nn-foundations.03 · Audience: Guest, Language professional, IT/ML learner · Prerequisites: Activation Functions
Later in Neural-Network Foundations
This module unlocks
A feedforward network (FFN) is a two-layer network with ReLU activation — the basic building block that appears inside every Transformer encoder layer. This module traces its forward pass numerically, from weight matrices through ReLU to the output vector, and then connects it, shape for shape, to the FFN sub-layer of the real Transformer.
In Module 01 you saw a single perceptron: n inputs → one output. A feedforward network (FFN) is a layer of perceptrons running in parallel:
The computation is: hidden = ReLU(W₁ · x + b₁), where W₁ is d_hidden × d_in, then output = W₂ · hidden + b₂, where W₂ is d_out × d_hidden. Everything is matrix multiplication plus activation — exactly what GPUs are built for.
Why it matters — The Transformer encoder uses this exact formula — often with d_hidden = 4 × d_model — applied independently to each token position at every encoder layer. In BERT-base: d_model = 768, d_hidden = 3072 (4×).
Self-check
Q1 — Network vs perceptron: how does a feedforward network differ structurally from a single perceptron?
Curated resources to explore feedforward networks further.
| Type | Resource |
|---|---|
| In-app | P10.transformer-architecture.01 — The Encoder Block — the same FFN as sub-layer 2, wrapped in residual connections and LayerNorm, applied to real token embeddings |
| Video | 3Blue1Brown — Gradient descent, how neural networks learn (Deep Learning, Chapter 2, YouTube) |
| Course | Coursera — Deep Learning Specialization, Course 1 Week 3–4: Shallow and Deep Neural Networks, Andrew Ng (free audit) |
| Course | fast.ai — Practical Deep Learning for Coders Lesson 1–2 (free, practical Python focus) |
| Reference | Michael Nielsen, Neural Networks and Deep Learning Ch. 1 (free online at neuralnetworksanddeeplearning.com) |
| Exercise | Karpathy — makemore series on YouTube: build character-level language models from scratch |
Practise this lesson's 5 self-checks
One per screen: you reveal each answer and mark it yourself. Nothing is recorded.
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
Off by default. The mentor always gets your file; this only decides whether your own copy stays here. Copies live in this browser only - they do not follow you to another device, and clearing site data removes them.
Three graded rungs: compute one neuron's output by hand, trace a two-layer forward pass with NumPy, then compute cross-entropy loss and its gradient on the network's output.
Loading exercise…
Loading exercise…
Loading exercise…
A scratch console for this page's ideas — ungraded, nothing you run here is recorded.
Scratch console
A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.
Output appears here.
Loading your notes...