Algorithm Search⌘K

Definitionintro

Adversarial example

Also called adversarial perturbation.

An input in an allowed small set around a correctly classified input, such as an l_p ball, to which the model gives a wrong label. The set is part of the threat model.

An adversarial example is an input x′x' that is close to a correctly classified input xx, in a set of allowed changes fixed in advance, and that the model labels wrongly. The changes are often too small for a person to see, yet they move the input across the decision boundary of the model. Biggio et al. (2013) and Szegedy et al. (2014) found such inputs for trained classifiers with gradient steps, and Goodfellow, Shlens and Szegedy (2015) explained them by the near-linear behavior of the models in high dimension. An evasion attack is a method that finds them; adversarial training and certified methods are the defenses. "Close" has no meaning without a threat model, so the definition below names the set of allowed changes explicitly.

Definition

A classifier with KK classes has logits z(x)∈RKz(x) \in \mathbb{R}^K and predicts f(x)=arg⁡max⁡kzk(x)f(x) = \arg\max_k z_k(x), with ties going to the smallest index. Inputs are in [0,1]d[0,1]^d. For p∈{0,1,2,∞}p \in \{0, 1, 2, \infty\} and a radius ϵ≥0\epsilon \ge 0, the set of allowed inputs around xx is

Sp(x,ϵ)=Bp(x,ϵ)∩[0,1]d,Bp(x,ϵ)={x′:∥x′−x∥p≤ϵ}.S_p(x, \epsilon) = B_p(x, \epsilon) \cap [0,1]^d, \qquad B_p(x, \epsilon) = \{x' : \lVert x' - x \rVert_p \le \epsilon\}.

Here ∥v∥0\lVert v \rVert_0 counts the nonzero coordinates of vv; it is not a norm, since ∥2v∥0=∥v∥0\lVert 2v \rVert_0 = \lVert v \rVert_0.

Definition (untargeted). Let x∈[0,1]dx \in [0,1]^d have the true label yy and let f(x)=yf(x) = y. An input x′x' is an adversarial example for xx at radius ϵ\epsilon in ℓp\ell_p if x′∈Sp(x,ϵ)x' \in S_p(x, \epsilon) and f(x′)≠yf(x') \ne y. The vector η=x′−x\eta = x' - x is its perturbation.

Definition (targeted). For a target class t≠yt \ne y, x′x' is a targeted adversarial example if x′∈Sp(x,ϵ)x' \in S_p(x, \epsilon) and f(x′)=tf(x') = t.

Definition (robustness). The point xx is robust at radius ϵ\epsilon in ℓp\ell_p if no adversarial example for xx exists in Sp(x,ϵ)S_p(x, \epsilon). The minimal adversarial distance is ρp(x)=inf⁡{∥x′−x∥p:x′∈[0,1]d, f(x′)≠y}\rho_p(x) = \inf\{\lVert x' - x \rVert_p : x' \in [0,1]^d,\ f(x') \ne y\}. If ϵ<ρp(x)\epsilon < \rho_p(x), then xx is robust at radius ϵ\epsilon. The robust accuracy of ff at radius ϵ\epsilon on a test set is the fraction of test points (x,y)(x, y) with f(x′)=yf(x') = y for every x′∈Sp(x,ϵ)x' \in S_p(x, \epsilon).

Three remarks fix the reading of the definition:

  • The threat model is part of the definition. The norm pp, the radius ϵ\epsilon and the box [0,1]d[0,1]^d define what counts. An input is an adversarial example only relative to a stated set. Biggio and Roli (2018) put this set in the capability of the attacker, next to the goal (untargeted or targeted) and the knowledge (white box, gray box, black box with scores, black box with decisions).
  • The true label is assumed to stay yy in the set. The set is chosen small enough that a person would give x′x' the same label as xx. This is a modeling assumption, not a theorem. A change that turns a "3" into a real "8" is not an adversarial example, even though the model changes its label.
  • The start must be correct. If f(x)≠yf(x) \ne y already, the model is simply wrong at xx. Some papers, such as Szegedy et al., define the condition as f(x′)≠f(x)f(x') \ne f(x) instead of f(x′)≠yf(x') \ne y. The two agree when f(x)=yf(x) = y. Say which one a number uses.

Bounds. An attack that finds an adversarial example proves that xx is not robust, so attacks give an upper bound on robust accuracy. A verifier or a certificate, such as randomized smoothing or interval bound propagation, proves that no adversarial example exists, so it gives a lower bound. A failed attack proves nothing.

Proposition (linear models). Let K=2K = 2 with f(x)=1f(x) = 1 when w⊤x+b>0w^\top x + b > 0 and f(x)=0f(x) = 0 otherwise, w≠0w \ne 0, and ignore the box. Then ρ2(x)=∣w⊤x+b∣/∥w∥2\rho_2(x) = |w^\top x + b| / \lVert w \rVert_2 and ρ∞(x)=∣w⊤x+b∣/∥w∥1\rho_\infty(x) = |w^\top x + b| / \lVert w \rVert_1.

Proof. Changing the label needs w⊤ηw^\top \eta to reach −(w⊤x+b)-(w^\top x + b) when the label is 11, or to pass it when the label is 00. So ∣w⊤η∣≥∣w⊤x+b∣|w^\top \eta| \ge |w^\top x + b| is needed, and by Hölder's inequality ∣w⊤η∣≤∥w∥q∥η∥p|w^\top \eta| \le \lVert w \rVert_q \lVert \eta \rVert_p with 1/p+1/q=11/p + 1/q = 1. So ∥η∥p≥∣w⊤x+b∣/∥w∥q\lVert \eta \rVert_p \ge |w^\top x + b| / \lVert w \rVert_q. The vectors η=τ w/∥w∥2\eta = \tau\, w / \lVert w \rVert_2 and η=τsign⁡(w)\eta = \tau \operatorname{sign}(w), with the sign of τ\tau chosen to move toward the boundary, attain equality in the two cases, and a slightly longer step crosses the boundary. ■\blacksquare

The ℓ∞\ell_\infty case shows the linear explanation of Goodfellow, Shlens and Szegedy. The change of the logit is ϵ∥w∥1\epsilon \lVert w \rVert_1, which grows with the number of coordinates: if every ∣wi∣|w_i| is about mm, it is about ϵ m d\epsilon\, m\, d. In high dimension, many changes that are each too small to see add up to a large change of the output.

Examples and non-examples

A linear model in the plane, three norms. Take K=3K = 3, z(x)=Wxz(x) = Wx with rows (1,0)(1, 0), (0,1)(0, 1) and (−1,−1)(-1, -1), and x=(0.6,0.4)x = (0.6, 0.4) with y=0y = 0. Then z(x)=(0.6,0.4,−1)z(x) = (0.6, 0.4, -1). The label becomes 11 once x2>x1x_2 > x_1. Class 22 is far away.

norm ρp(x)\rho_p(x) a perturbation that reaches it
ℓ2\ell_2 0.2/2=0.14140.2/\sqrt2 = 0.1414 τ(−1,1)/2\tau(-1, 1)/\sqrt2 with τ\tau just above 0.14140.1414
ℓ∞\ell_\infty 0.10.1 τ(−1,1)\tau(-1, 1) with τ\tau just above 0.10.1
ℓ0\ell_0 11 change one coordinate, for example x2x_2 to 0.610.61

The point x′=(0.498,0.502)x' = (0.498, 0.502), found by one step of DeepFool, is an adversarial example in ℓ2\ell_2 at every radius ϵ≥0.1443\epsilon \ge 0.1443. At ϵ=0.14\epsilon = 0.14 in ℓ2\ell_2, no adversarial example exists, because 0.14<ρ2(x)0.14 < \rho_2(x). The same pair is far apart in ℓ0\ell_0 (two changed coordinates) and close in ℓ∞\ell_\infty (0.1020.102). So the norm decides which inputs count.

A logistic model in six dimensions, with the box. Let w=(1.5,−2,0.5,1,−0.5,3)w = (1.5, -2, 0.5, 1, -0.5, 3), b=1b = 1, x=(0.2,0.9,0.5,0,1,0.4)x = (0.2, 0.9, 0.5, 0, 1, 0.4) and y=1y = 1. The logit is z=0.45z = 0.45. The fast gradient sign method at ϵ=0.1\epsilon = 0.1 in ℓ∞\ell_\infty gives x′=(0.1,1,0.4,0,1,0.3)x' = (0.1, 1, 0.4, 0, 1, 0.3) with z′=−0.25z' = -0.25, so x′x' is an adversarial example. Coordinates 4 and 5 cannot move, because the box stops them at 00 and 11. So the box matters: without it, ρ∞(x)=0.45/8.5=0.0529\rho_\infty(x) = 0.45 / 8.5 = 0.0529; with it, only the other four coordinates can move, and ρ∞(x)=0.45/7=0.0643\rho_\infty(x) = 0.45 / 7 = 0.0643.

A non-example: a radius that is too small. In the same model at ϵ=0.05\epsilon = 0.05, the smallest logit in S∞(x,0.05)S_\infty(x, 0.05) is 0.45−7⋅0.05=0.1>00.45 - 7 \cdot 0.05 = 0.1 > 0. FGSM is exact for a linear model (see its page), so this is a proof: no adversarial example exists, and xx is robust at this radius.

A non-example: a change outside the set. The input (0.2,0.9,0.5,0,1,0)(0.2, 0.9, 0.5, 0, 1, 0) changes one coordinate by 0.40.4 and has logit −0.75-0.75, a wrong label. At ϵ=0.1\epsilon = 0.1 in ℓ∞\ell_\infty it is not an adversarial example, because it is not in S∞(x,0.1)S_\infty(x, 0.1). In ℓ0\ell_0 with ϵ=1\epsilon = 1 it is one.

A non-example: random noise. A change of the same size in a random direction rarely changes the label. On two logistic models in 8 dimensions trained on seeded Gaussian blobs (the measurement on the page adversarial transferability), random sign noise of size 0.10.1 in ℓ∞\ell_\infty changed the label of 5 of 198 test points, while the FGSM change of the same size changed 90. Adversarial examples are rare in volume but easy to find with the gradient.

A non-example: a point that is already wrong. If f(x)≠yf(x) \ne y, then xx itself has the wrong label, and no search is needed. It counts against clean accuracy, not as an adversarial example.

An example in ℓ0\ell_0. The Jacobian saliency map attack changes few coordinates by a large amount. On the six-feature model of its page it reaches the target class with four changed features, so ∥η∥0=4\lVert \eta \rVert_0 = 4 while ∥η∥∞=0.8\lVert \eta \rVert_\infty = 0.8.

References

  1. Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow and Rob Fergus, Intriguing properties of neural networks, ICLR 2014, Section 4 (the box-constrained minimal perturbation that changes the label, found with L-BFGS)
  2. Battista Biggio, Igino Corona, Davide Maiorca, Blaine Nelson, Nedim Srndic, Pavel Laskov, Giorgio Giacinto and Fabio Roli, Evasion attacks against machine learning at test time, ECML PKDD 2013, LNCS 8190, pages 387 to 402, the adversary model (goal, knowledge, capability) and the gradient-based evasion of a classifier at test time
  3. Ian J. Goodfellow, Jonathon Shlens and Christian Szegedy, Explaining and harnessing adversarial examples, ICLR 2015, Section 3 (the linear explanation, with the perturbation eta of l_infinity norm at most epsilon)
  4. Battista Biggio and Fabio Roli, Wild patterns: Ten years after the rise of adversarial machine learning, Pattern Recognition 84, pages 317 to 331, 2018, the threat model in three parts and the history of evasion attacks since the work on spam filters
  5. Nicholas Carlini and David Wagner, Towards evaluating the robustness of neural networks, IEEE Symposium on Security and Privacy 2017, pages 39 to 57, the l_0, l_2 and l_infinity distance metrics and the targeted definition
  6. Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras and Adrian Vladu, Towards deep learning models resistant to adversarial attacks, ICLR 2018, Section 2 (the set of allowed perturbations and the robust objective)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/ZJAKP2/text.yaml