TL;DR
A classifier learns from every pattern in its training data that helps predict the label, including patterns that are useful but fragile. A robust feature is one that still points to the right label after a small, deliberately chosen change to the input. A non-robust feature helps on ordinary test data but can be flipped by that same kind of change. Ilyas and colleagues argued that adversarial examples come from non-robust features, not from a flaw that only exists in neural networks.
Builds on: Adversarial Examples, Linear Classifier, Representation Learning · Leads to: Adversarial Training, Adversarial Examples Are Not Bugs, They Are Features
Where it's used
Testing vision systems before deployment. Teams that build image classifiers for cars, factories and medical screening attack their models with small pixel changes, known as adversarial examples, before shipping them. A model that is accurate on clean photos but breaks under a change too small to see is a safety problem. Knowing which features the model relies on tells the team where to look for failures.
Training robust models. The most common defence, adversarial training, feeds the model attacked versions of its training images with their correct labels (see Adversarial Training). Its success depends on the idea in this lesson: the training signal has to rule out reliance on fragile patterns, not just ask for accuracy on clean images.
Explaining what a model learned. The paper behind this lesson rebuilt the CIFAR-10 training set so that each image kept only the non-robust patterns a standard model relies on, and was relabelled to match them. The labels on the rebuilt images look wrong to a person, yet a model trained on the deterministic version still reaches 43.7 percent accuracy on the normal CIFAR-10 test set, where chance with ten classes is 10 percent. Accuracy that high from images that look mislabeled is evidence that the model is using real, if fragile, signal.
Deciding how much accuracy to trade for robustness. A robust model may score a little lower on clean data than a standard one. Teams choosing a model for a medical or safety setting weigh that loss against how the model behaves when the input is perturbed.
How it works
Take two numbers per example, and , and a label that is or . Our whole dataset has two examples, each equally likely. We will check two features and then train two classifiers on the same data.
-
The data. Example A has and . Example B has and . Check: the sign of matches the label in both examples.
-
Two features. A feature is one number computed from the input. Use and . To measure how useful a feature is, multiply it by the label and average. For : example A gives and example B gives , so the average is . For : both examples give , so the average is . Check: both are positive, so both point the right way on clean data. is strong and is weak but still useful.
-
A budget for the attacker. Let the attacker change each number by at most , in either direction, and choose the changes that do the most harm. For , the worst change in example A moves from to , so drops to . Example B drops the same way, to . For , the worst change in example A moves from to , so falls to . Example B also falls to . Check: the worst-case values are for and for .
-
Robust or not. A feature is robust when its worst-case value stays above zero. stays at , so it is a robust feature. drops to . It is useful (step 2) and not robust, so it is a non-robust feature. Under attack, its sign relative to the label flips.
-
Two classifiers. A linear classifier scores each input as and predicts the sign of . The robust classifier uses , so it relies only on . The standard classifier uses , so it leans heavily on . Check on clean data: for A, the robust score is and the standard score is ; for B, the scores are and . Both classifiers label both examples correctly, so ordinary training cannot tell them apart.
-
The attack. For each example, move every number by in the direction that lowers , which is . For the standard classifier, example A moves to , with score . Its label is , so it is wrong. Example B moves to , with score , but its label is , so it is wrong too. For the robust classifier, the scores are for A and for B, and both stay correct.
-
What came out. The standard classifier was perfect on clean data and failed after changes of to each number. It was leaning on the non-robust feature . Its failure is an adversarial example: an input changed by a small amount that flips the answer. The robust classifier ignored and survived.
- standard, w = (1, 10)
- robust, w = (1, 0)
The math
The definitions
Let a feature be any function from inputs to numbers. The paper also shifts and scales each feature to mean zero and variance one. That changes the numbers but not the argument, so we skip it here. Labels are , and examples come from a distribution . denotes the expected value over that distribution.
These definitions match the walkthrough. Here is the box (see Vector Norm), so each number can move by at most .
Step 2 in symbols: usefulness
With labels balanced () and features normalised, equals the correlation between and . That is why it measures usefulness. In the example,
Step 3 in symbols: the worst case for a linear feature
Take a linear feature , where is the dot product. Its worst case over the box is
where is the sum of the absolute weights. The derivation: is smallest when each takes the sign that makes as negative as possible, that is . Then each term contributes , and the total is . Check with , where : . With , where : . Both match step 3.
Step 5 in symbols: the margin under attack
The margin of a classifier on an example is . A positive margin means a correct answer. Under the budget, the worst-case margin is . For the standard classifier , we have , and example A has margin , so
The margin reaches zero at . For the robust classifier , the margin is , which reaches zero only at . The plot above draws both lines.
The training loss does not see the difference
Standard training minimises a loss that gets better as grows on clean data. A simple version is . Every useful feature increases this, robust or not. The loss never asks whether a feature survives a change to the input. That is why the paper says there is "no distinction" between robust and non-robust features under ordinary training. Robust training changes the objective to a worst case, , so the non-robust feature stops paying off (see Adversarial Training and Minimax Game).
Worked examples
Take a single example with , and budget .
- Feature . Its usefulness: .
- Worst case for : the attacker moves down by , so .
- , so is robust with . Interpretation: no change of size can make point the wrong way.
- Feature . Its usefulness: .
- Worst case for : the attacker moves down by , so .
- , so is useful but not robust. Interpretation: is a non-robust feature. It is correct on the clean example and wrong after a change of .
Use the standard classifier on example A, , . Its clean margin is .
- Write the worst-case margin: , from the formula in the math section.
- Try . The margin is . Since , the classifier still answers .
- Try . The margin is . Since , the answer flips to .
- Find the cut-off: gives . Interpretation: an attacker who can move each number by can flip this example. The robust classifier needs of about for the same flip.
Suppose a linear classifier looks at a colour image. Each image has pixel values scaled to . A common budget for natural images is . Suppose the weights have average absolute size , so . The clean score for this image is .
- The largest change in score under the attack is .
- The attacked score is . The sign flips, so the answer changes.
- Interpretation: each pixel moved by about out of levels, a change most people cannot see, and the answer flipped. The arithmetic is exact for a linear model. A deep network is not linear, but its gradient plays the same role, which is why attacks use gradients.
Try it: the same image, but the average weight size is instead of . Work out the new change in score and the attacked score, and say whether the answer flips.
Answer: , so the change is . The attacked score is . It is still positive, so the answer does not flip. Smaller weights make the model less sensitive to the same budget.
Common mistakes and tradeoffs
"Adversarial examples are bugs caused by overfitting." It is tempting to think an attack exploits noise in the training set, a form of overfitting. In fact, the paper's rebuilt datasets show that the useful non-robust patterns generalise to the normal test set (43.7 percent on CIFAR-10 for the deterministic set), because they reflect real structure in the data.
"A robust feature is one a person finds meaningful." Robustness is a precise property: a feature stays correlated with the label under the worst change in the budget. A feature can be easy for a person to read and still be non-robust. The paper describes non-robust features as highly predictive but brittle, and often incomprehensible to people.
"Robust models are just worse models." Robustness usually costs some accuracy on clean data. The tradeoff is real (Tsipras and colleagues study it directly), but a small clean-accuracy drop can be worth it when the input may be attacked. Choose by what the system must survive.
"Adversarial training removes non-robust features from the data." Adversarial training does not delete features from the dataset. It changes the training objective so that a classifier cannot profit from features that break under attack. Filtering the dataset is a separate method. The paper uses it as an experiment, keeping only the features a robust model relies on.
When to use this view: when you need to know why a model is brittle, or when you are choosing a training method for a setting where inputs may be attacked. When not to: the framework describes linear features and an budget. Real threat models can be different (for example, a budget on the number of changed pixels rather than their size). Alternatives: test the model on realistic perturbations such as blur or compression, and use input-level checks, which catch some attacks without changing training.
History
Szegedy and colleagues showed in 2013 that a small, carefully computed change to an image could flip the answer of a state-of-the-art image classifier, even though the change was hard to see. These are the adversarial examples of this lesson. People at first treated this as a strange property of high-dimensional input spaces. In 2015, Goodfellow, Shlens and Szegedy argued that a simple linear explanation accounted for much of it, and introduced the gradient-sign attack. Madry and colleagues in 2018 trained models on attacked inputs, which became the standard defence (adversarial training). In 2019, Ilyas and colleagues proposed the feature view in this lesson and tested it by rebuilding the training data. Their result changed the question from "why do networks have blind spots?" to "which features is the network using, and which of them survive a small change?"
Recap
- A feature is one number computed from the input. A useful feature is positively correlated with the label on average.
- A robust feature stays useful under the worst change in a budget. A non-robust feature is useful but not robust.
- For a linear feature with an budget, the worst-case drop is , which is why large weights make a model fragile.
- Standard training rewards every useful feature, so it cannot tell robust from non-robust ones. Robust training changes the objective to a worst case.
- Adversarial examples come from non-robust features. Next, read Adversarial Training for the defence, and Adversarial Examples Are Not Bugs, They Are Features for the paper that makes this argument.
Check yourself
QuestionRecall: what is the difference between a useful feature and a robust feature?Show answer
QuestionComputation: the standard classifier w = (1, 10) has clean margin 3 on the example x = (2, 0.1), y = +1. What is its margin after the attack with budget 0.5? Is the example still correct?Show answer
QuestionWhy: why does ordinary training not prefer the robust classifier w = (1, 0) over the standard classifier w = (1, 10)?Show answer
QuestionApplied: a vision model reaches 95 percent accuracy on clean photos but 40 percent when each pixel changes by at most 8/255. A saliency check shows that it relies on a fine texture pattern that is very predictive on clean data. Which kind of feature is the texture, and what training change would you try first?Show answer
Sources
- Ilyas, Santurkar, Tsipras, Engstrom, Tran and Madry, Adversarial Examples Are Not Bugs, They Are Features, 2019: https://arxiv.org/abs/1905.02175
- Tsipras, Santurkar, Engstrom, Turner and Madry, Robustness May Be at Odds with Accuracy, 2019: https://arxiv.org/abs/1805.12152
- Goodfellow, Shlens and Szegedy, Explaining and Harnessing Adversarial Examples, 2015: https://arxiv.org/abs/1412.6572