Lion Cipher Lab
Fool an image classifier with FGSM (adversarial examples)
- AI Security
- Intermediate
- ~75 min
- Free · no account required
Why it matters
Everyone has been told that AI 'sees' images. In this lab you will personally break that claim: you will take a photo a well-known model classifies correctly with high confidence, add a change so small that your own eyes cannot detect it, and watch the same model report a completely different object with equal confidence. This is not a bug in one model — it is a general property of the neural networks now sitting inside content moderation, malware classification, medical triage, fraud scoring and self-driving perception. Once you have made it happen with your own hands, two things become…
What you'll learn
- adversarial examples
- the Fast Gradient Sign Method (FGSM)
- reading gradients of a loss with respect to an input
- PyTorch and torchvision basics
- measuring attack success rate against epsilon
- input-preprocessing defences and their limits
- adversarial training (concept)
- why model confidence is not evidence
Steps in this lab
- What you are about to do, in plain language
- The ethics line — 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
- Make the model name your photo
- Three words you need: logit, loss, gradient
- The FGSM formula — English first, then symbols
- Craft your first adversarial example
- Now look at the two pictures
- If it did not work: the four things that go wrong
- Sweep epsilon — see the trade-off with your own eyes
- Measure it: attack success rate across your whole folder
- Why does such a tiny change work at all?
- Defence 1: squeeze the input before the model ever sees it
- Defence 2, and the honest caveat that matters most
- Where this bites in the real world
- What you just did