Search

Search papers and lessons

Robust and Non-Robust Features

Level 4 · 15 min read

Robust features still point to the right label after a small, deliberate nudge to the input; non-robust features help on ordinary data but break under such nudges, and adversarial examples exploit them.

On this page

  • Colour = topic mix
  • Discrete math
  • Calculus
  • Linear algebra
  • Neural network basics
  • Probability
  • Losses & regularization
  • ReadReady to readNot yet

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, x1x_1 and x2x_2, and a label yy that is +1+1 or −1-1. Our whole dataset has two examples, each equally likely. We will check two features and then train two classifiers on the same data.

  1. The data. Example A has x=(2,0.1)x = (2, 0.1) and y=+1y = +1. Example B has x=(−2,−0.1)x = (-2, -0.1) and y=−1y = -1. Check: the sign of x1x_1 matches the label in both examples.

  2. Two features. A feature is one number computed from the input. Use f1(x)=x1f_1(x) = x_1 and f2(x)=x2f_2(x) = x_2. To measure how useful a feature is, multiply it by the label and average. For f1f_1: example A gives (+1)(2)=2(+1)(2) = 2 and example B gives (−1)(−2)=2(-1)(-2) = 2, so the average is 22. For f2f_2: both examples give 0.10.1, so the average is 0.10.1. Check: both are positive, so both point the right way on clean data. f1f_1 is strong and f2f_2 is weak but still useful.

  3. A budget for the attacker. Let the attacker change each number by at most ε=0.5\varepsilon = 0.5, in either direction, and choose the changes that do the most harm. For f1f_1, the worst change in example A moves x1x_1 from 22 to 1.51.5, so y⋅f1y \cdot f_1 drops to 1.51.5. Example B drops the same way, to 1.51.5. For f2f_2, the worst change in example A moves x2x_2 from 0.10.1 to −0.4-0.4, so y⋅f2y \cdot f_2 falls to −0.4-0.4. Example B also falls to −0.4-0.4. Check: the worst-case values are 1.51.5 for f1f_1 and −0.4-0.4 for f2f_2.

  4. Robust or not. A feature is robust when its worst-case value stays above zero. f1f_1 stays at 1.51.5, so it is a robust feature. f2f_2 drops to −0.4-0.4. It is useful (step 2) and not robust, so it is a non-robust feature. Under attack, its sign relative to the label flips.

  5. Two classifiers. A linear classifier scores each input as s(x)=w1x1+w2x2s(x) = w_1 x_1 + w_2 x_2 and predicts the sign of ss. The robust classifier uses w=(1,0)w = (1, 0), so it relies only on f1f_1. The standard classifier uses w=(1,10)w = (1, 10), so it leans heavily on f2f_2. Check on clean data: for A, the robust score is 22 and the standard score is 2+1=32 + 1 = 3; for B, the scores are −2-2 and −3-3. Both classifiers label both examples correctly, so ordinary training cannot tell them apart.

  6. The attack. For each example, move every number by 0.50.5 in the direction that lowers y⋅s(x)y \cdot s(x), which is δ=−0.5⋅y⋅sign(w)\delta = -0.5 \cdot y \cdot \mathrm{sign}(w). For the standard classifier, example A moves to x′=(1.5,−0.4)x' = (1.5, -0.4), with score 1.5+10⋅(−0.4)=−2.51.5 + 10 \cdot (-0.4) = -2.5. Its label is +1+1, so it is wrong. Example B moves to x′=(−1.5,0.4)x' = (-1.5, 0.4), with score −1.5+4=2.5-1.5 + 4 = 2.5, but its label is −1-1, so it is wrong too. For the robust classifier, the scores are 1.51.5 for A and −1.5-1.5 for B, and both stay correct.

  7. What came out. The standard classifier was perfect on clean data and failed after changes of 0.50.5 to each number. It was leaning on the non-robust feature f2f_2. Its failure is an adversarial example: an input changed by a small amount that flips the answer. The robust classifier ignored f2f_2 and survived.

00.10.20.30.40.50.6−3−2−10123budget εworst-case margin on A
  • standard, w = (1, 10)
  • robust, w = (1, 0)
The worst-case margin of each classifier on example A as the budget grows. The standard classifier crosses zero at ε = 3/11, about 0.27. The robust classifier is still positive across this range.

The math

The definitions

Let a feature be any function f:X→Rf : \mathcal{X} \to \mathbb{R} 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 y∈{+1,−1}y \in \{+1, -1\}, and examples come from a distribution D\mathcal{D}. E\mathbb{E} denotes the expected value over that distribution.

Definition: Useful feature
A feature ff is ρ\rho-useful, for some ρ>0\rho \gt 0, if E(x,y)∼D[ y⋅f(x) ]≥ρ\mathbb{E}_{(x,y)\sim\mathcal{D}}[\, y \cdot f(x) \,] \geq \rho. The largest such ρ\rho is the feature's usefulness.
Definition: Robust feature
Let Δ(x)\Delta(x) be the set of allowed changes to xx. A ρ\rho-useful feature is γ\gamma-robustly useful, for some γ>0\gamma \gt 0, if E(x,y)∼D[ inf⁡δ∈Δ(x)y⋅f(x+δ) ]≥γ\mathbb{E}_{(x,y)\sim\mathcal{D}}\big[\, \inf_{\delta \in \Delta(x)} y \cdot f(x+\delta) \,\big] \geq \gamma. Such a feature is called a robust feature.
Definition: Non-robust feature
A feature is useful but non-robust if it is ρ\rho-useful for some ρ>0\rho \gt 0, yet is not γ\gamma-robustly useful for any γ>0\gamma \gt 0.

These definitions match the walkthrough. Here Δ(x)\Delta(x) is the box ∥δ∥∞≤ε\|\delta\|_\infty \leq \varepsilon (see Vector Norm), so each number can move by at most ε\varepsilon.

Step 2 in symbols: usefulness

With labels balanced (E[y]=0\mathbb{E}[y] = 0) and features normalised, E[y⋅f(x)]\mathbb{E}[y \cdot f(x)] equals the correlation between yy and f(x)f(x). That is why it measures usefulness. In the example,

E[y⋅x1]=12((+1)(2)+(−1)(−2))=2,E[y⋅x2]=12(0.1+0.1)=0.1.\mathbb{E}[y \cdot x_1] = \tfrac{1}{2}\big((+1)(2) + (-1)(-2)\big) = 2, \qquad \mathbb{E}[y \cdot x_2] = \tfrac{1}{2}\big(0.1 + 0.1\big) = 0.1.

Step 3 in symbols: the worst case for a linear feature

Take a linear feature f(x)=w⋅x=∑iwixif(x) = w \cdot x = \sum_i w_i x_i, where w⋅xw \cdot x is the dot product. Its worst case over the box is

inf⁡∥δ∥∞≤εy⋅w⋅(x+δ)=y⋅w⋅x−ε ∥w∥1,\inf_{\|\delta\|_\infty \leq \varepsilon} y \cdot w \cdot (x + \delta) = y \cdot w \cdot x - \varepsilon \, \|w\|_1,

where ∥w∥1=∑i∣wi∣\|w\|_1 = \sum_i |w_i| is the sum of the absolute weights. The derivation: y⋅w⋅δ=∑i(ywi)δiy \cdot w \cdot \delta = \sum_i (y w_i)\delta_i is smallest when each δi\delta_i takes the sign that makes ywiδiy w_i \delta_i as negative as possible, that is δi=−ε⋅y⋅sign(wi)\delta_i = -\varepsilon \cdot y \cdot \mathrm{sign}(w_i). Then each term contributes −ε∣wi∣-\varepsilon |w_i|, and the total is −ε∥w∥1-\varepsilon \|w\|_1. Check with f1f_1, where w=(1,0)w = (1, 0): 2−0.5⋅1=1.52 - 0.5 \cdot 1 = 1.5. With f2f_2, where w=(0,1)w = (0, 1): 0.1−0.5⋅1=−0.40.1 - 0.5 \cdot 1 = -0.4. Both match step 3.

Step 5 in symbols: the margin under attack

The margin of a classifier s(x)=w⋅xs(x) = w \cdot x on an example is y⋅s(x)y \cdot s(x). A positive margin means a correct answer. Under the budget, the worst-case margin is y⋅s(x)−ε∥w∥1y \cdot s(x) - \varepsilon \|w\|_1. For the standard classifier w=(1,10)w = (1, 10), we have ∥w∥1=11\|w\|_1 = 11, and example A has margin 33, so

margin under attack=3−11ε.\text{margin under attack} = 3 - 11\varepsilon.

The margin reaches zero at ε∗=3/11≈0.27\varepsilon^\ast = 3/11 \approx 0.27. For the robust classifier w=(1,0)w = (1, 0), the margin is 2−ε2 - \varepsilon, which reaches zero only at ε=2\varepsilon = 2. The plot above draws both lines.

The training loss does not see the difference

Standard training minimises a loss that gets better as y⋅s(x)y \cdot s(x) grows on clean data. A simple version is −E[y⋅s(x)]-\mathbb{E}[y \cdot s(x)]. 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, max⁡δL(x+δ,y)\max_{\delta} \mathcal{L}(x + \delta, y), so the non-robust feature stops paying off (see Adversarial Training and Minimax Game).

Worked examples

Example
1. One example, one feature (tiny)

Take a single example x=(2,0.1)x = (2, 0.1) with y=+1y = +1, and budget ε=0.5\varepsilon = 0.5.

  1. Feature f1(x)=x1f_1(x) = x_1. Its usefulness: y⋅f1(x)=1⋅2=2y \cdot f_1(x) = 1 \cdot 2 = 2.
  2. Worst case for f1f_1: the attacker moves x1x_1 down by 0.50.5, so y⋅f1(x+δ)=2−0.5=1.5y \cdot f_1(x+\delta) = 2 - 0.5 = 1.5.
  3. 1.5>01.5 \gt 0, so f1f_1 is robust with γ=1.5\gamma = 1.5. Interpretation: no change of size 0.50.5 can make f1f_1 point the wrong way.
  4. Feature f2(x)=x2f_2(x) = x_2. Its usefulness: y⋅f2(x)=0.1y \cdot f_2(x) = 0.1.
  5. Worst case for f2f_2: the attacker moves x2x_2 down by 0.50.5, so y⋅f2(x+δ)=0.1−0.5=−0.4y \cdot f_2(x+\delta) = 0.1 - 0.5 = -0.4.
  6. −0.4<0-0.4 \lt 0, so f2f_2 is useful but not robust. Interpretation: f2f_2 is a non-robust feature. It is correct on the clean example and wrong after a change of 0.50.5.
Example
2. The standard classifier and the budget (standard)

Use the standard classifier w=(1,10)w = (1, 10) on example A, x=(2,0.1)x = (2, 0.1), y=+1y = +1. Its clean margin is 33.

  1. Write the worst-case margin: 3−11ε3 - 11\varepsilon, from the formula in the math section.
  2. Try ε=0.2\varepsilon = 0.2. The margin is 3−2.2=0.83 - 2.2 = 0.8. Since 0.8>00.8 \gt 0, the classifier still answers +1+1.
  3. Try ε=0.3\varepsilon = 0.3. The margin is 3−3.3=−0.33 - 3.3 = -0.3. Since −0.3<0-0.3 \lt 0, the answer flips to −1-1.
  4. Find the cut-off: 3−11ε=03 - 11\varepsilon = 0 gives ε=3/11≈0.27\varepsilon = 3/11 \approx 0.27. Interpretation: an attacker who can move each number by 0.270.27 can flip this example. The robust classifier w=(1,0)w = (1, 0) needs ε\varepsilon of about 22 for the same flip.
Example
3. A linear image model (realistic)

Suppose a linear classifier looks at a 32×3232 \times 32 colour image. Each image has n=32×32×3=3072n = 32 \times 32 \times 3 = 3072 pixel values scaled to [0,1][0, 1]. A common budget for natural images is ε=8/255≈0.0314\varepsilon = 8/255 \approx 0.0314. Suppose the weights have average absolute size 0.010.01, so ∥w∥1=3072×0.01=30.72\|w\|_1 = 3072 \times 0.01 = 30.72. The clean score for this image is 0.80.8.

  1. The largest change in score under the attack is ε∥w∥1=0.0314×30.72≈0.96\varepsilon \|w\|_1 = 0.0314 \times 30.72 \approx 0.96.
  2. The attacked score is 0.8−0.96≈−0.160.8 - 0.96 \approx -0.16. The sign flips, so the answer changes.
  3. Interpretation: each pixel moved by about 88 out of 255255 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 0.0050.005 instead of 0.010.01. Work out the new change in score and the attacked score, and say whether the answer flips.

Answer: ∥w∥1=3072×0.005=15.36\|w\|_1 = 3072 \times 0.005 = 15.36, so the change is 0.0314×15.36≈0.480.0314 \times 15.36 \approx 0.48. The attacked score is 0.8−0.48≈0.320.8 - 0.48 \approx 0.32. 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 ℓ∞\ell_\infty 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 ℓ∞\ell_\infty budget, the worst-case drop is ε∥w∥1\varepsilon \|w\|_1, 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
A useful feature has a positive average of y⋅f(x)y \cdot f(x) on clean data, so it is correlated with the label. A robust feature is useful even under the worst change in the allowed budget: the worst-case value of y⋅f(x+δ)y \cdot f(x+\delta), averaged over the data, stays at least some γ>0\gamma \gt 0. Every robust feature is useful, but a useful feature can fail to be robust.
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
The worst-case margin is 3−11⋅0.5=3−5.5=−2.53 - 11 \cdot 0.5 = 3 - 5.5 = -2.5. Since −2.5<0-2.5 \lt 0, the example is no longer correct. This matches the walkthrough, where the attacked point is x′=(1.5,−0.4)x' = (1.5, -0.4) with score −2.5-2.5.
QuestionWhy: why does ordinary training not prefer the robust classifier w = (1, 0) over the standard classifier w = (1, 10)?Show answer
Both classifiers label both clean examples correctly, and ordinary training measures how well the features correlate with the label on clean data. Both f1f_1 and f2f_2 are useful, so the loss rewards using both. The loss never checks whether a feature survives a change to the input, so it gives no reason to drop f2f_2.
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
The texture is a useful but non-robust feature: it predicts the label on clean photos but breaks under changes within the budget. The first change to try is adversarial training with the same budget, so the training objective penalises reliance on the texture. A second option is to filter the training data so the texture is less present, which the paper tests in its experiments. Accuracy under attack should improve, though clean accuracy may drop a little.

Sources

Robust and Non-Robust Features · ungoon.me