The neuron

Every neural network, from a spam filter to a frontier LLM, is built from one tiny unit repeated billions of times. Understand this one and the rest is stacking.

Learn

What a neuron computes

A neuron takes some numbers in, multiplies each by a weight, adds them up with a bias, and squashes the total into a probability with an activation function.

z = w₁·x₁ + w₂·x₂ + b   →   p = sigmoid(z) = 1 / (1 + e−z)

Our neuron is a spam filter. Each email becomes two numbers: x₁ = how many links it has, and x₂ = how much of it is in CAPITAL LETTERS (both scaled from 0 to 1). If p > 0.5 the neuron says spam.

The weights say how much each clue matters. The bias says how suspicious to be before seeing any clues. Together they draw a straight line through the space of emails: one side is spam, the other is not. That line is the whole "intelligence" of a single neuron.

Build

Set the weights yourself

Mission A · classify every email

Red dots are spam, blue are real mail. Move the sliders until the neuron gets all 20 emails right. The shaded background shows what the neuron thinks of every possible email.

spamreal mailx → links · y → CAPS
accuracy line:
0 / 20 right so far
Break

Fool a trained filter

You just found weights that get all 20 emails right by hand. Here's a filter trained the same way, already deployed — and the line it drew is thinner than it looks.

Mission B · adversarial example

Here is a properly trained filter (w₁ = 6, w₂ = 5, b = −5.5) with 100% accuracy. The ringed email is spam and the filter catches it. Edit that email, changing each feature by at most 0.10, so the filter lets it through.

filter says: spam
Caught as spam

What just happened: the same line that scored 20/20 let a 10%-smaller email through as something else entirely.

Defend

Why this works, and the fix

Why it works: the neuron only knows one line. Any email just past that line gets the opposite answer, and the gradient (the direction of the weights) tells an attacker exactly which way is "past". You removed a link and lowercased a few words. In images the same trick needs pixel changes too small for a human to see (Szegedy et al. 2013; Goodfellow et al. 2014, the FGSM attack).

The fix: train on attacked examples too (adversarial training), want a wide margin between classes, and never trust one model on features an attacker fully controls. Spam filters combine many signals the sender cannot easily change, such as reputation and sending history.