Techniqueadvanced
Backward pass differentiable approximation
Also called BPDA, obfuscated gradients.
Breaks defenses that hide gradients by using the true function on the forward pass and a differentiable stand-in on the backward pass.
Backward pass differentiable approximation (BPDA) is a technique of Athalye, Carlini and Wagner (2018) for testing a defense that puts a step in front of a classifier and so makes the gradient of useless: zero almost everywhere, undefined, or wrong. Such a step can be a quantization of the input, a non-differentiable image transformation or a projection onto a learned set. Gradient attacks such as PGD then fail, and the defense looks robust. BPDA computes exactly on the forward pass but uses a differentiable function on the backward pass, often the identity when . The gradient is then at , which is good enough to find adversarial examples. In their study of 9 defenses accepted at ICLR 2018, 7 relied on such obfuscated gradients, and the new attacks circumvented 6 of them completely and 1 partially, in the threat model each paper claimed. The lesson is about evaluation: an attack that fails gives no evidence of robustness when its gradients are broken.
In plain words
Many defenses add a step before the model, such as rounding the pixels. The rounding gives the attacker a flat gradient, a signal that says "nothing changes here", so the usual attack makes no progress, and the defense seems strong.
The model behind the rounding is still the same weak model. BPDA keeps the real rounding when it runs the input forward, but when it asks which way to move, it pretends the rounding was not there. That answer is close enough to the truth, and the attack works again.
So a defense must be tested by an attacker who knows the defense and adapts the attack to it. A failed attack with broken gradients proves nothing.
When it applies
- The defended model has the form with differentiable and a step whose gradient is zero, missing or misleading, and the attacker knows (white box).
- A differentiable with is known, or , so the identity is a good stand-in. A neural network trained to imitate also works.
- The threat model allows test-time changes of inside a set , such as .
- It does not help against a defense with a certificate, such as randomized smoothing or interval bound propagation, whose guarantee does not depend on gradients. Against random defenses, combine it with expectation over transformation.
The template
Notation: is the classifier, the defense step, the differentiable stand-in, the loss, the projection onto the allowed set . The holes in angle brackets are chosen for each evaluation.
BPDA-EVALUATE(f, g, h, x, y, S)- 1
x' ← x - 2
for i ← 1 to ⟨number of steps⟩ do - 3
v ← g(x') ▷ the true defense on the forward pass - 4
r ← ∇_v L(f(v), y) ▷ the gradient of the classifier at g(x') - 5
d ← J_h(x')^T r ▷ the stand-in on the backward pass; d = r if h is the identity - 6
x' ← Π_S(x' + ⟨step rule⟩(d)) ▷ a PGD step inside the allowed set - 7
return x' ▷ check f(g(x')) on the true defense
Line L3 runs the defense exactly, so the final check at line L7 is on the real system and not on the stand-in. Line L5 is the only change to PGD. If is the identity, is the gradient of at the processed input ; this is like the straight-through estimator used to train networks with quantized units. For defenses whose gradient vanishes or explodes because is a deep iterative procedure, Athalye et al. use a related idea, reparameterization: write with and attack in .
Cost. Each step costs one call of , one forward and backward pass of , and one product with . With the identity stand-in the cost is that of PGD plus the cost of .
Why it works. If , then and are close functions near the iterates, and so the gradient of at points in a useful direction even though itself has zero gradient. This is a heuristic, not a theorem: a stand-in can fail when is far from , and then the evaluation must try a better .
Classic examples
- Input quantization against PGD. Let be a linear score (label 1 if , label 0 otherwise) on one input, and let . At , and , so the label is 1. The gradient of is at every point where it exists, so a plain gradient attack does not move. With the identity, line L5 gives , and one step of down, inside the budget , gives , and : the label changes. The same pattern broke defenses based on thermometer encoding and on input transformations such as bit depth reduction.
- Defensive distillation. An earlier case of a masked gradient: defensive distillation made the softmax saturate, so gradients of the loss were tiny, but the Carlini-Wagner attack on the logits found adversarial examples at the same distances as before.
- Projection onto a learned set. Defenses that move the input to a nearby point of a generative model before classifying it compute by an inner optimization. Its gradient explodes or vanishes, and BPDA with the identity, or reparameterization, attacks them.
- Random transformations. A defense that applies a random resize or padding has a random gradient; BPDA for the non-differentiable parts plus expectation over transformation for the randomness breaks it.
- Training-time defenses are a contrast. Adversarial training changes itself and keeps true gradients, and it held up in the same study within its threat model.
Variations
- A learned stand-in. When is not close to , train a small network to imitate and use it on the backward pass.
- Reparameterization. For an iterative , attack in a latent space with and .
- Combined with EOT. For random , average the BPDA gradient over many draws of the randomness.
- Gradient-free checks. Black-box attacks such as the boundary attack or the zeroth-order attack need no gradient at all, so if they beat a white-box gradient attack, the gradients are masked.
- Adaptive attacks in general. Tramer, Carlini, Brendel and Madry (2020) circumvented 13 recently published defenses, each with its own adapted attack, and showed that BPDA is one tool among several: the attack must be built for the defense.
Pitfalls
- Checking success on the stand-in. Line L7 must evaluate with the true ; a success of says nothing about the defense.
- A bad stand-in. If is far from at line L5, the attack can fail, and the failure is about , not about the defense. Try another before you report robustness.
- Too few steps. With a stand-in the direction is noisy, so line L2 often needs more steps than plain PGD. Report how the attack success changes with the number of steps.
- Reading a failed attack as a lower bound. An attack gives an upper bound on robust accuracy, never a lower bound. Only a verifier or a certificate gives a lower bound.
- Signs of masked gradients. Carlini et al. (2019) list them: one-step attacks beat iterative ones, black-box attacks beat white-box ones, a larger budget does not reach 100 percent success, or random search finds adversarial examples that gradients miss. If any holds, the gradients are broken somewhere.
Exercises
- Let on . Show that the derivative of is at every point where it exists, for every differentiable , and find the points where it does not exist.
- In the quantization example, show that every budget allows an with and the label 0, and that no budget does.
- Suppose for every and the score of is -Lipschitz. Show that , and explain why an attack on alone with a margin larger than also succeeds against .
References
- Anish Athalye, Nicholas Carlini and David Wagner, Obfuscated gradients give a false sense of security, circumventing defenses to adversarial examples, ICML 2018, PMLR 80, pages 274 to 283, the three kinds of obfuscated gradients, BPDA, the reparameterization and EOT attacks, and the study of 9 defenses of ICLR 2018, of which 7 relied on obfuscated gradients (6 circumvented completely and 1 partially)
- Nicholas Carlini, Anish Athalye, Nicolas Papernot, Wieland Brendel, Jonas Rauber, Dimitris Tsipras, Ian Goodfellow, Aleksander Madry and Alexey Kurakin, On evaluating adversarial robustness, arXiv 2019, the checklist for an evaluation, including the signs of gradient masking
- Florian Tramer, Nicholas Carlini, Wieland Brendel and Aleksander Madry, On adaptive attacks to adversarial example defenses, NeurIPS 2020, thirteen defenses with an adaptive attack for each, and the lessons for evaluation
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W3 standard |
|
Tag EN0RG5 Edit this page History Report an error Markdown