research28 min studyLesson 935 in Engineering

Investigate gradients that conceal accessible failures

Use controlled diagnostics to distinguish genuine resistance from uninformative derivatives, saturation, and attack implementation errors.

On this page

What you’ll understand

  • Construct a zero-gradient toy with a nearby decision failure.
  • Interpret stronger-search and transfer diagnostics without treating them as proofs.
  • Separate numerical and optimization failures from valid robustness evidence.

A model wrapper returns zero input gradients on every test image. That could reflect a locally constant operation, a saturated numerical loss, a detached tensor, or a computation that hides useful directions from automatic differentiation. None of those explanations establishes that the decision is stable throughout the allowed perturbation set. Gradient masking describes this mismatch between an attack’s derivative information and accessible failures. Diagnose it with controlled experiments, retain true forward evaluations, and avoid turning a convenient optimization failure into a claim about the classifier’s entire neighborhood.

A flat derivative can hide a nearby threshold

Quantization makes an input-output map piecewise constant. Inside a quantization cell, an exact derivative can be zero even though a small feasible move crosses the next cell boundary and changes the decision. A straight gradient step starting strictly inside the cell may then remain stationary. This is a limitation of that search mechanism, not a contradiction in calculus. The local derivative describes an infinitesimal change; the threat may permit a finite move beyond the flat cell.

Numerical saturation produces another failure mode. A softmax or exponential calculation may round into a region where a particular loss gradient is unhelpful even though the underlying logit margin still changes. Inspect stable logit-based objectives and finite values before accepting a plateau. Also verify that the model wrapper has not accidentally detached its input or disabled gradients. An evaluator should be able to reproduce a simple known gradient through the same execution path before trusting a large attack benchmark.

q(x)=14⌊4x+12⌋,F(x)=1{q(x)≥1/8}q(x)=\frac14\left\lfloor4x+\frac12\right\rfloor,\qquad F(x)=\mathbf1\{q(x)\geq1/8\}
This deterministic scalar toy uses nearest-quarter quantization with the displayed tie convention. Away from quantizer boundaries its ordinary derivative is zero. Ground-truth label validity near the clean example is stipulated for this educational example.↔ Scroll wide equations horizontally.

Triangulate the source of attack failure

Compare one-step and iterative variants, multiple losses, step-size sweeps, random restarts, transfer candidates, and an appropriate gradient-free search. A stronger-capability white-box test that consistently underperforms a simpler transfer test is a reason to inspect the gradient path, although finite optimization budgets can also explain it. A finite random search finding a valid failure is decisive for that example; random search finding nothing is only limited search evidence.

Vary the distortion budget carefully. The exact feasible sets are nested as epsilon grows, so true worst-case robust accuracy cannot increase when the classifier and validity definition stay fixed. Independently rerun finite attacks can nevertheless produce nonmonotone estimates because they search different candidates. Preserve prior feasible candidates at larger budgets to make the aggregate evidence monotone where set inclusion applies. Do not attribute every jagged attack curve to masking without ruling out candidate bookkeeping and sampling variability.

DhL(x)=L(x+h)−L(x−h)2h,h>0D_hL(x)=\frac{L(x+h)-L(x-h)}{2h},\qquad h>0
This central finite difference measures a finite-scale loss slope, not necessarily the infinitesimal derivative. Both queried points must satisfy the domain and any testing constraints. Its usefulness depends on scale, numerical precision, and the underlying function.↔ Scroll wide equations horizontally.

Validate counterexamples and document uncertainty

For each newly found failure, check the original norm, input domain, output rule, label, and model version. A derivative workaround that silently bypasses the defense cannot establish failure of the defended pipeline. Conversely, a valid forward-evaluated failure needs no accurate gradient to be a counterexample. Separate feasibility errors from search errors in the report so a successful-looking but invalid candidate cannot contaminate the claimed robust-accuracy bound.

Document diagnostic results as evidence rather than a binary masking verdict. Useful records include finite-difference probes, gradient norms, loss scaling, best-so-far attack traces, and differences between exact and approximate backward paths. Avoid concluding that a defense is robust simply because common masking symptoms were absent. A smooth well-behaved gradient can still lead a finite attack to a poor local optimum, and a nonsmooth model can have genuine robustness under a separately proved certificate.

Cross a quantization cell with a valid finite move

Use the displayed scalar quantizer with clean x=0.12, true label 0, and allowed interval [0,1] intersected with |z−x|≤0.02. Assume label 0 remains semantically valid throughout that interval. Evaluate F at x and at z=0.14, then compute D₀.₀₁q(x).

  1. At x=0.12, 4x+0.5=0.98 and floor is 0, so q(x)=0 and F(x)=0. The ordinary derivative is zero inside this quantization cell.

  2. At z=0.14, 4z+0.5=1.06 and floor is 1, so q(z)=0.25 and F(z)=1. Displacement is 0.02, exactly the allowed budget, and the toy label assumption makes it a valid failure.

  3. For h=0.01, q(0.13)=0.25 and q(0.11)=0. The central finite difference is 0.25/(2×0.01)=12.5, revealing a finite-scale jump despite the zero derivative at 0.12.

The result

The gradient is locally correct but insufficient for this finite-radius search. The actual feasible candidate at 0.14 establishes failure of the toy classifier without any certification claim.

Explore the model

Interactive lab

Interactive lab · function

A derivative describes a point in a specified function

Reset, set Coefficient a to 1 and Position x to 0.5. Predict y=0.25 and tangent slope 1 before Step. Reset, explicitly set a=1 and x=1, then Step: predict y=1 and slope 2. This instrument uses only the smooth function y=ax²; it does not reproduce the quantizer or detect masking in a network. Playback traces geometry without changing the selected point.

A derivative describes a point in a specified functionThis lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Current readings: y at chosen x: 0.608; Tangent slope · 2ax: 1.35; Signed area · ax³/3: 0.182. All parameters are adjustable with the labeled controls below.−2.4−1.201.22.4−9−4.504.59xy(x, ax²)
y = ax²TangentSigned integral
y at chosen x
0.608
Tangent slope · 2ax
1.35
Signed area · ax³/3
0.182
t = 0 s

This lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forInterpret a derivative using the actual function, point, and finite perturbation scale.

Check your understanding

What does the valid candidate z=0.14 show in the quantizer example?

Try it yourself

Use the same quantizer and decision with clean x=0.10. Is z=0.13 feasible under budget 0.02? Is it feasible under budget 0.04, and what are the two decisions?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Compute the displacement before using the quantizer’s threshold at x=0.125.

Compare with the solution

Displacement is 0.03, so the candidate is invalid under budget 0.02 but valid under 0.04. At 0.10, q=0 and F=0; at 0.13, q=0.25 and F=1. Under the separately stipulated label-preservation assumption, this is a counterexample only for the larger stated budget.

Take it with you

  • Zero or unstable gradients do not establish finite-radius decision stability.
  • Use diverse diagnostic searches and preserve valid counterexamples.
  • Distinguish masking evidence from proofs of robustness or nonrobustness.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.