Training

Last level you dragged sliders until the line looked right. A real network never gets dragged — it learns the line from data. That process is training, and it has a weak spot: it trusts its data completely.

Learn

Loss and gradient descent

Loss is one number that says how wrong the neuron currently is across all the data. Training just means: nudge the weights to make that number smaller, over and over.

loss = average(−y·log(p) − (1−y)·log(1−p))   ·   w ← w − (learning rate) × (slope of loss)

The "slope of loss" is the gradient: it points toward higher loss, so training steps the opposite way. Do this thousands of times and the line finds its way to the data, with no human dragging a slider.

Build

Watch it learn

Mission A · run gradient descent

Press step, or play, and watch the line move on its own toward 100% accuracy. Try a learning rate that's too big, too.

spamreal mail
epoch loss accuracy
Not trained yet
Break

Poison the training set

The filter you just trained learned only from its data. It never asked where that data came from — so now you're the one supplying it.

Mission B · data poisoning

You're an attacker who can add fake "real mail" points to the training set before it's trained (a real attacker might compromise a shared spam-report feed). Place up to 4 fake points, train, and flip the filter's verdict on the ringed real spam email — drop it under 40% spam confidence — without touching it directly. Hint: the strongest poison doesn't sit next to the target. It sits right inside the real spam cluster.

fake points 0 / 4epoch target confidence spam
Click the canvas to place a fake "real mail" point

What just happened: four fake rows, planted before training even started, moved a verdict on an email the attacker never touched.

Defend

Why this works, and the fix

Why it works: gradient descent has no idea which points are genuine. A few fake points near the target quietly drag the whole decision line, so the attack doesn't touch the target email at all — it moves the boundary around it. This is data poisoning, the same family as attacks on recommendation systems and on LLM pretraining and fine-tuning data.

The fix: provenance on training data (know where every example came from), outlier and influence-function checks before training, and held-out validation sets an attacker can't reach. Never let one unreviewed feed train a production model directly.