One neuron
An artificial neuron is a very small function. It takes some numbers in, multiplies each by a weight, adds them up, adds one more number called the bias, and passes the result through a simple bend called the activation function.
sum = w₁×x₁ + w₂×x₂ + … + bA dot product of the inputs with the weights, plus the bias. You met both in the vectors lesson.
output = ReLU(sum) = max(0, sum)ReLU, the most common bend: keep a positive sum as it is, turn a negative one into zero.
x = [1, 0.5], w = [0.8, −1.2], b = 0.3An example.
sum = 0.8 − 0.6 + 0.3 = 0.5, output = 0.5The sum is positive, so ReLU lets it through unchanged.
These sliders start at the example above. Change the inputs, the weights and the bias, and watch the sum and the output. Find a setting where the output becomes zero.
This interactive part needs JavaScript.
Why the bend matters
Why not leave the bend out? Because without it, stacking neurons gains nothing. A layer without a bend is a matrix multiplication, and two matrix multiplications in a row are the same as one (you can multiply the two matrices together first). However many such layers you stack, the result is still a straight-line function, and a straight line cannot learn a curve.
Add a bend after each layer and everything changes. Each ReLU neuron contributes one “hinge”: flat on one side, sloped on the other. Add up enough hinges, placed at different points with different slopes, and you can trace any curve you like, as closely as you want.
| Name | What it does | Where |
|---|---|---|
| ReLU | max(0, x): zero for negatives, unchanged for positives | The default for many years; simple and fast |
| GELU | A smooth version of ReLU that lets small negative values through | BERT and many GPT-style models |
| SiLU (Swish) | x times a smooth step between 0 and 1; also smooth | Inside SwiGLU, used by Llama, Qwen, DeepSeek and most open models |
Layers: wide and deep
A layer is many neurons side by side, all reading the same inputs, each with its own weights. A whole layer is computed at once as one matrix times the input vector, plus a vector of biases, then the bend applied to every number. A network is layers in sequence: each layer’s outputs are the next layer’s inputs.
- 784 inputsThe brightness of each pixel in a 28 × 28 image
- Hidden layer128 neurons with ReLU; they learn useful strokes and shapes
- 10 outputsOne score per digit, 0 to 9, turned into chances by softmax
784 × 128 + 128 = 100,480Every input connects to every hidden neuron, plus one bias each.
128 × 10 + 10 = 1,290Every hidden neuron connects to every output.
total = 101,770 parametersEnough to read handwritten digits about 98 % correctly. Llama 3.1 8B has about 80,000 times as many.
The number of neurons in a layer is its width; the number of layers is the network’s depth. The layers between input and output are called hidden layers, because you never see their values directly. Deep learning just means learning with networks of many layers. Llama 3.1 8B has 32 layers; DeepSeek-V3 has 61.
Quick check
What the hidden layers learn
Nobody tells the hidden neurons what to look for. Training adjusts their weights, and useful detectors appear by themselves. In 2013, researchers looked inside an image network trained to recognise objects and found a clear ladder: neurons in the first layers responded to edges and colours, the middle layers to textures and parts like eyes or wheels, and the last layers to whole objects such as faces and dogs.
Language models build features too, though they are harder to see, because each idea is spread across many neurons and each neuron takes part in many ideas. In 2024, Anthropic researchers used a second, helper network to pull millions of separate features out of a production model, and found ones that switch on for famous landmarks, for bugs in code, or for an idea expressed in any language. The study of what is going on inside models is called interpretability.
Which part of a neuron does each job?
-
Decides how strongly each input counts
Answer: Weights
-
Is added once, after the inputs are summed
Answer: Bias
-
Turns a negative sum into zero
Answer: Activation
-
Lets stacked layers learn curves instead of straight lines
Answer: Activation
-
Is multiplied by one of the inputs
Answer: Weights
-
Shifts the point where the neuron starts to switch on
Answer: Bias
The network inside every language-model layer
Every layer of a transformer contains a small two-layer neural network called the feed-forward block (or MLP, for multi-layer perceptron). It is applied to each token’s vector separately. In Llama 3.1 8B it widens each 4,096-number vector to 14,336 numbers, applies the bend, and narrows it back to 4,096.
h = SiLU(gate_proj · x) ⊙ (up_proj · x)Two matrices widen the vector. One goes through the bend and then acts as a “gate”: ⊙ means multiply number by number, so the gate decides how much of each of the 14,336 values gets through.
output = down_proj · hA third matrix narrows it back to 4,096 numbers, and the result is added to the token’s vector.
These three matrices are the gate_proj, up_proj and down_proj you counted in the matrices lesson: about 176 million of the 218 million weights in each Llama layer, or 81 %. Research suggests the feed-forward blocks hold much of a model’s stored knowledge: a 2020 study found their neurons acting like key–value memories, where a pattern in the text (the key) calls up a likely next word (the value).
Remember
- A neuron computes a dot product of inputs and weights, adds a bias, and applies an activation such as ReLU = max(0, x).
- Without the bend, stacked layers collapse into one straight-line function. With it, enough neurons can approximate any curve.
- A layer is a matrix multiplication plus biases plus the bend. Width is neurons per layer, depth is the number of layers.
- Hidden layers learn their own features, from edges to objects in images and concepts in language models.
- Each transformer layer has a feed-forward block (SwiGLU in most open models) holding about 80 % of its weights. Split into experts, it becomes a mixture of experts.
Words to know
- Neuron
- A small function: weighted sum of inputs, plus a bias, through a bend.
- Bias
- A number added to a neuron’s sum, shifting when it switches on.
- Activation function
- The bend applied after the sum, such as ReLU, GELU or SiLU. Without it, layers add nothing.
- ReLU
- max(0, x): keeps positive numbers, turns negative ones into zero.
- Layer
- Many neurons side by side, computed together as one matrix multiplication.
- Hidden layer
- A layer between the input and the output, whose values you never see directly.
- Deep learning
- Machine learning with neural networks of many layers.
- Feature
- Something a network has learned to detect, such as an edge, a face, or an idea in text.
- Feed-forward block (MLP)
- The small two-layer network inside every transformer layer.
- SwiGLU
- The gated feed-forward design used by most open models: three matrices and a SiLU gate.
Go to the source
This lesson is built on these papers and documents. Paper links open arxiv.org, a separate site.
-
Neural Networks (3Blue1Brown, videos)
The digit-reading network from this lesson, animated. Later chapters cover transformers too.
-
Approximation by Superpositions of a Sigmoidal Function (G. Cybenko)
The universal approximation theorem. Mathematical, but the main statement fits in one sentence.
-
Visualizing and Understanding Convolutional Networks
The pictures of what each layer of an image network responds to, from edges to faces.
-
GLU Variants Improve Transformer
Two pages that introduced SwiGLU. It ends with a famously honest line about not knowing why it works.
-
Transformer Feed-Forward Layers Are Key-Value Memories
Evidence that the feed-forward blocks store patterns and the words they predict.
-
Scaling Monosemanticity (Anthropic)
Millions of features pulled out of a real language model, with interactive examples.
Check yourself
5 questions. Tap the answer you think is right.
0 of 5 answered
Lesson complete
Answer every question above to complete this lesson.
Your progress is saved on this device only.
Next lessonBackpropagation: how billions of weights learn at once