Lion Cipher Lab

Harden a model with adversarial training (defensive AI)

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

Steps in this lab

  1. What you are about to do, in plain language
  2. Why this lab is deliberately small — and the honest reason
  3. The honesty rule — read this before you run anything
  4. Open a terminal and install Python
  5. Make a project folder and a virtual environment
  6. Install PyTorch — the CPU build, no graphics card required
  7. File 1 of 3: common.py — the data, the model, and the attack
  8. File 2 of 3: train.py — and your baseline model
  9. File 3 of 3: evaluate.py — and the moment your model falls over
  10. Look at what the attack actually did to the pictures
  11. What adversarial training actually is — English first, then the formula
  12. Train the hardened model — and watch the clock
  13. The comparison table — the whole lab in six numbers
  14. If something went wrong: the five things that actually break
  15. Four honest caveats about what you just built
  16. Where this lands in the real world
  17. What you just did, and where the arc goes next

Open the full interactive lab →