Lion Cipher Lab
Harden a model with adversarial training (defensive AI)
- AI Security
- Intermediate
- ~2 hours (about 25 minutes of that is your computer training, unattended)
- Free · no account required
Why it matters
Breaking a model is the easy half. Anyone can be shown that a classifier is fragile; the awkward question in a real meeting is 'so what do we do about it?', and the honest answer is uncomfortable — the one defence that reliably works costs money, costs accuracy, and only protects against the specific attack you paid to defend against. In this lab you will not be told that. You will produce it: train an ordinary model, watch a standard attack take it from ninety-something percent accurate down to a few percent, then retrain the same architecture on adversarial examples and watch the attacked…
What you'll learn
- adversarial training end to end
- training a small neural network in PyTorch
- FGSM and PGD as one parameterised attack
- measuring robust accuracy under a stated threat model
- the robustness / clean-accuracy trade-off
- costing a defence honestly (training time, accuracy, scope)
- evaluating a defence with the strongest attack rather than the kindest one
- reading and challenging a robustness claim
Steps in this lab
- What you are about to do, in plain language
- Why this lab is deliberately small — and the honest reason
- The honesty rule — read this before you run anything
- Open a terminal and install Python
- Make a project folder and a virtual environment
- Install PyTorch — the CPU build, no graphics card required
- File 1 of 3: common.py — the data, the model, and the attack
- File 2 of 3: train.py — and your baseline model
- File 3 of 3: evaluate.py — and the moment your model falls over
- Look at what the attack actually did to the pictures
- What adversarial training actually is — English first, then the formula
- Train the hardened model — and watch the clock
- The comparison table — the whole lab in six numbers
- If something went wrong: the five things that actually break
- Four honest caveats about what you just built
- Where this lands in the real world
- What you just did, and where the arc goes next