Simple Algorithm
Deep Learning · Emergence · 28 min

Certified Robustness

Provable guarantees from bound propagation, Lipschitz networks and randomized smoothing.

An attack that fails proves nothing: a stronger one might succeed tomorrow. A certificate is different, a proof that no perturbation in a given ball changes the prediction. This lesson builds certificates four ways (exact search, bounds pushed through the layers, a bound on the network's Lipschitz constant, and smoothing the classifier with noise) and shows what each costs in compute, in accuracy and in the threat models it can cover.

What you’ll learn

  • Explain why exact verification of ReLU networks is NP-complete, and encode a ReLU exactly with mixed-integer constraints and approximately by its convex relaxation.
  • Derive interval bound propagation and linear relaxation bounds, compute a certified margin by hand, and describe certified training and its paradox.
  • Derive the Lipschitz-margin radius m/(2L)m/(\sqrt2L), show why products of spectral norms are loose, and explain what 1-Lipschitz architectures need.
  • Prove the randomized-smoothing radius from the Lipschitz property of Φ−1\Phi^{-1} of a Gaussian-smoothed classifier, and compute certified radii.
  • Compare the guarantees, costs and limits of the four approaches as of the mid-2020s.

Certificates and exact verification

Fix a classifier with logits z(x)\mathbf z(\mathbf x), an input x0\mathbf x_0 that it assigns to class yy, and a ball B=Bp(x0,ε)B=B_p(\mathbf x_0,\varepsilon). The prediction is robust on BB exactly when every margin stays positive:

min⁡x∈B(zy(x)−zj(x))>0for every j≠y\min_{\mathbf x\in B}\big(z_y(\mathbf x)-z_j(\mathbf x)\big)>0\qquad\text{for every }j\ne y
A certificate is a proof of this. A verifier is sound if it never certifies a non-robust input, and complete if it certifies every robust one. Attacks look for points with a negative margin, so they can only refute robustness; certified robustness needs a guaranteed lower bound on the minimum.
DerivationProof sketch: 3-SAT inside a ReLU network
  1. yi=1−max⁡(0, 1−∑j=13qij)={1if some literal is 10if all three are 0y_i=1-\max\Big(0,\ 1-\sum_{j=1}^3q_i^j\Big)=\begin{cases}1&\text{if some literal is }1\\0&\text{if all three are }0\end{cases}

    In NP. Guess for every ReLU whether it is active. With that pattern fixed, every constraint is linear, and linear programming decides feasibility in polynomial time. (Katz et al. guessed the input itself, a real vector whose size they did not bound, one of the gaps Sälzer and Lange (2021) repaired.) NP-hard. Encode a 3-SAT formula whose clauses Ci=qi1∨qi2∨qi3C_i=q_i^1\vee q_i^2\vee q_i^3, i=1,…,ni=1,\dots,n, are built from literals over Boolean variables x1,…,xKx_1,\dots,x_K. A negated literal is 1−xk1-x_k, one affine unit, and each clause is a single ReLU:

  2. m(x)=∑i=1n(1−yi)+∑k=1K∣bk∣ ≥ 0,m(x)=0  ⟺  x∈{0,1}K satisfies every clausem(\mathbf x)=\sum_{i=1}^n\big(1-y_i\big)+\sum_{k=1}^K\abs{b_k}\ \ge\ 0,\qquad m(\mathbf x)=0\iff\mathbf x\in\{0,1\}^K\text{ satisfies every clause}

    Linear input constraints cannot say "Boolean", but a small ReLU gadget per variable can: bk=max⁡(0,12−xk)+max⁡(0,xk−12)−12b_k=\max(0,\tfrac12-x_k)+\max(0,x_k-\tfrac12)-\tfrac12 equals −xk-x_k below 12\tfrac12 and xk−1x_k-1 above, so it vanishes exactly at xk∈{0,1}x_k\in\{0,1\} (Sälzer & Lange, 2021). Fold every requirement into one output, using ∣b∣=max⁡(0,b)+max⁡(0,−b)\abs b=\max(0,b)+\max(0,-b); since each yi≤1y_i\le1, it is never negative:

  3. Read mm as the margin zy−zjz_y-z_j of a two-class network, and take the box [0,1]K[0,1]^K, the ℓ∞\ell_\infty ball of radius 12\tfrac12 around (12,…,12)(\tfrac12,\dots,\tfrac12), where m=K/2>0m=K/2>0. An adversarial example in the box exists exactly when the formula is satisfiable. Katz et al.'s own gadget for Boolean inputs, max⁡(0,ϵ−x)+max⁡(0,x−1+ϵ)\max(0,\epsilon-x)+\max(0,x-1+\epsilon) constrained to [0,ϵ][0,\epsilon], forces nothing: it is 0 for every xx between ϵ\epsilon and 1−ϵ1-\epsilon.

Exact answers are still within reach for networks of modest size, by mixed-integer programming. A ReLU h=max⁡(0,z)h=\max(0,z) whose pre-activation is known to lie in [l,u][l,u] is stable if u≤0u\le0 (then h=0h=0) or l≥0l\ge0 (then h=zh=z), and unstable if l<0<ul<0<u. Only unstable units need a binary variable a∈{0,1}a\in\{0,1\} (Tjeng, Xiao & Tedrake, 2019):

DerivationA ReLU as integer constraints, and its relaxation
  1. h≥0,h≥z,h≤u a,h≤z−l (1−a)h\ge0,\qquad h\ge z,\qquad h\le u\,a,\qquad h\le z-l\,(1-a)

    These four linear constraints together with a∈{0,1}a\in\{0,1\} hold exactly when h=max⁡(0,z)h=\max(0,z): with a=0a=0 they force h=0h=0 and z≤0z\le0, and with a=1a=1 they force h=zh=z and z≥0z\ge0.

  2. h≥0,h≥z,h≤u (z−l)u−lh\ge0,\qquad h\ge z,\qquad h\le\frac{u\,(z-l)}{u-l}

    Relax aa to the interval [0,1][0,1] and eliminate it. A feasible aa exists exactly when h/u≤1−(h−z)/(−l)h/u\le1-(h-z)/(-l), which rearranges to the upper face of a triangle. These three constraints are the convex hull of the ReLU's graph over [l,u][l,u], the tightest convex relaxation of a single unit (Ehlers, 2017):

  3. With this formulation and careful bounds [l,u][l,u] for every unit, Tjeng et al. verified convolutional and residual networks with more than 100,000 ReLUs, and for the first time computed the exact adversarial accuracy of an MNIST classifier at ℓ∞\ell_\infty radius 0.1: an adversarial example for 4.38% of the test images and a certificate for all the others. Tight bounds mean fewer unstable units and fewer binary variables, and that is what makes or breaks exact verification.

Predict before you look

A ReLU's pre-activation is known to lie in [−1,3][-1,3]. At z=0z=0 the true output is h=0h=0. What is the largest hh that the triangle relaxation allows at z=0z=0?

Show the answer

0.75

The upper face is h≤u(z−l)/(u−l)=3×(0+1)/4=0.75h\le u(z-l)/(u-l)=3\times(0+1)/4=0.75. The relaxation lets this unit output anything in [0,0.75][0,0.75] at z=0z=0. Such gaps, added up over all the unstable units and layers, are what loosen the final bound.

Bound propagation

Instead of solving an optimization problem, push guaranteed bounds through the network one layer at a time. Interval bound propagation (IBP; Gowal et al., 2018) keeps a box [h‾,h‾][\underline{\mathbf h},\overline{\mathbf h}] for every layer, starting from the input box [x0−ε1, x0+ε1][\mathbf x_0-\varepsilon\mathbf 1,\ \mathbf x_0+\varepsilon\mathbf 1]:

μ=12(h‾+h‾),  r=12(h‾−h‾) ⟶ μ′=Wμ+b,  r′=∣W∣ r;[h‾,h‾] → ϕ  [ϕ(h‾),ϕ(h‾)]\boldsymbol\mu=\tfrac12\big(\overline{\mathbf h}+\underline{\mathbf h}\big),\ \ \mathbf r=\tfrac12\big(\overline{\mathbf h}-\underline{\mathbf h}\big)\ \longrightarrow\ \boldsymbol\mu'=W\boldsymbol\mu+\mathbf b,\ \ \mathbf r'=\abs{W}\,\mathbf r;\qquad\big[\underline{\mathbf h},\overline{\mathbf h}\big]\ \xrightarrow{\ \phi\ }\ \big[\phi(\underline{\mathbf h}),\phi(\overline{\mathbf h})\big]
An affine layer maps the box's center by WW and its radius by ∣W∣\abs W, the elementwise absolute value: two matrix products. A monotone activation such as ReLU maps the two ends. Each step gives the tightest box around the image of the previous box, but that image is a slanted parallelotope, and replacing it by its bounding box at every layer is where IBP loses tightness.
DerivationA worked example
  1. z∈[(−0.2, 0.8), (0.2, 1.2)] → ReLU⁡  h∈[(0, 0.8), (0.2, 1.2)]\mathbf z\in\big[(-0.2,\ 0.8),\ (0.2,\ 1.2)\big]\ \xrightarrow{\ \operatorname{ReLU}\ }\ \mathbf h\in\big[(0,\ 0.8),\ (0.2,\ 1.2)\big]

    Take x0=(1,1)\mathbf x_0=(1,1) and ε=0.1\varepsilon=0.1, one hidden layer with W=(1−111)W=\begin{pmatrix}1&-1\\1&1\end{pmatrix}, b=(0,−1)\mathbf b=(0,-1) and ReLU, and the margin m=zy−zj=−4h1+h2m=z_y-z_j=-4h_1+h_2. At x0\mathbf x_0 the hidden units are (0,1)(0,1) and m=1m=1. The input box has center (1,1)(1,1) and radius (0.1,0.1)(0.1,0.1), so

  2. m‾=−4×0.2+0.8=0\underline m=-4\times0.2+0.8=0

    The margin's lower bound takes h1h_1 at its largest and h2h_2 at its smallest, and IBP cannot certify the point, since that needs m‾>0\underline m>0:

  3. min⁡x∈Bm(x)=−4 (1.1−0.9)+(1.1+0.9−1)=0.2\min_{\mathbf x\in B}m(\mathbf x)=-4\,(1.1-0.9)+(1.1+0.9-1)=0.2

    Yet the point is robust. Both extremes cannot happen at once: h1h_1 is largest at the corner x=(1.1,0.9)\mathbf x=(1.1,0.9), where h2=1h_2=1, and the true minimum over the box is at that corner:

  4. m ≥ −4 (0.5z1+0.1)+z2=−x1+3x2−1.4 ≥ −1.1+2.7−1.4=0.2m\ \ge\ -4\,(0.5z_1+0.1)+z_2=-x_1+3x_2-1.4\ \ge\ -1.1+2.7-1.4=0.2

    A linear relaxation keeps track of that dependence. Unit 2 is stably active, h2=z2h_2=z_2; unit 1 is unstable on [−0.2,0.2][-0.2,0.2], and its triangle gives h1≤0.2(z1+0.2)/0.4=0.5z1+0.1h_1\le0.2(z_1+0.2)/0.4=0.5z_1+0.1. Substituting the affine layer gives a lower bound linear in x\mathbf x, minimized at a corner of the box. Here it is exact, and it certifies the point:

Propagating such linear bounds backward through the network, with a lower line h≥azh\ge az (0≤a≤10\le a\le1) and the triangle's upper line for every unstable unit, is CROWN (Zhang, Weng, Chen, Hsieh & Daniel, 2018), which picks a=1a=1 when u≥∣l∣u\ge\abs l and a=0a=0 otherwise. Wong and Kolter (2018) reached the same triangle relaxation through the dual of its linear program; their fixed choice of dual variables amounts to a lower line of slope u/(u−l)u/(u-l), parallel to the upper one, and they trained networks so that the resulting bound certifies. Branching on unstable units makes such bounds complete: β-CROWN with branch and bound was up to three orders of magnitude faster than branch and bound built on linear-programming solvers (Wang et al., 2021).

Certified training minimizes a loss on the bounds themselves. Gowal et al. trained IBP networks on κ ℓ(z,y)+(1−κ) ℓ(z^(ε),y)\kappa\,\ell(\mathbf z,y)+(1-\kappa)\,\ell(\hat{\mathbf z}(\varepsilon),y), where z^\hat{\mathbf z} puts the true logit at its lower bound and every other logit at its upper bound, ramping ε\varepsilon up from 0 and κ\kappa down from 1 to 12\frac12. Training makes the network's bounds tight: on CIFAR-10 at ε=8/255\varepsilon=8/255, Gowal et al.'s IBP-trained network had a clean error of 50.51% and a verified error of 68.44% by its own interval bounds (67.96% with a slower MIP and linear-programming verifier), so about 32% of the test images were certified. CROWN-IBP, which adds a linear backward pass to the training bound, reached 66.94%; Zhang et al. (2020) report that the IBP figure needed an extra PGD training term, without which IBP training gave 73.52%. There is a paradox: training against tighter relaxations often certifies less than training against loose intervals. Jovanović, Balunović, Baader and Vechev (2022) traced it to properties beyond tightness, the continuity and sensitivity of the relaxation, which shape the optimization.

python
import torch

def ibp_margin_lower(layers, x, y, eps):
    lo, hi = x - eps, x + eps                          # the l_inf box around x
    for layer in layers[:-1]:
        if isinstance(layer, torch.nn.Linear):
            mid, rad = (hi + lo) / 2, (hi - lo) / 2
            mid, rad = layer(mid), rad @ layer.weight.abs().T     # W mid + b,  |W| rad
            lo, hi = mid - rad, mid + rad
        else:                                          # ReLU, or any monotone activation
            lo, hi = layer(lo), layer(hi)
    W, b = layers[-1].weight, layers[-1].bias          # fold the margins into the last layer
    C = W[y] - W                                       # row j: w_y - w_j
    mid, rad = (hi + lo) / 2, (hi - lo) / 2
    lower = C @ mid + (b[y] - b) - C.abs() @ rad       # lower bounds on z_y - z_j
    return torch.cat([lower[:y], lower[y + 1:]])       # certified if all are > 0

For a 1-D input x and a list of Linear and ReLU modules. Folding each margin wy−wj\mathbf w_y-\mathbf w_j into the last layer is never looser than bounding zyz_y and zjz_j separately and subtracting; Gowal et al. call this elision of the last layer and found that it tightens the bounds. On the worked example the function returns 0 (up to rounding): not certified.

Lipschitz certificates

A bound that holds everywhere is simpler still. If the logit map is LL-Lipschitz in ℓ2\ell_2, ∥z(x)−z(x′)∥2≤L∥x−x′∥2\norm{\mathbf z(\mathbf x)-\mathbf z(\mathbf x')}_2\le L\norm{\mathbf x-\mathbf x'}_2, the prediction cannot change until the margin is used up:

DerivationProof
  1. ∣(zy−zj)(x0+δ)−(zy−zj)(x0)∣≤2 ∥z(x0+δ)−z(x0)∥2≤2 L∥δ∥2\big\lvert(z_y-z_j)(\mathbf x_0+\boldsymbol\delta)-(z_y-z_j)(\mathbf x_0)\big\rvert\le\sqrt2\,\norm{\mathbf z(\mathbf x_0+\boldsymbol\delta)-\mathbf z(\mathbf x_0)}_2\le\sqrt2\,L\norm{\boldsymbol\delta}_2

    Each margin is a linear function of the logits, zy−zj=(ey−ej)⊤zz_y-z_j=(\mathbf e_y-\mathbf e_j)^\top\mathbf z, and ∥ey−ej∥2=2\norm{\mathbf e_y-\mathbf e_j}_2=\sqrt2. By Cauchy–Schwarz it moves by at most

  2. So (zy−zj)(x0+δ)≥m(x0)−2L∥δ∥2>0(z_y-z_j)(\mathbf x_0+\boldsymbol\delta)\ge m(\mathbf x_0)-\sqrt2L\norm{\boldsymbol\delta}_2>0 for every jj inside the radius. Bounding instead the subnetwork below the last layer by LsubL_{\text{sub}} and using each row difference gives the radius min⁡j(zy−zj)/(Lsub∥wy−wj∥2)\min_j(z_y-z_j)/(L_{\text{sub}}\norm{\mathbf w_y-\mathbf w_j}_2), which is never smaller than the radius from L=∥W∥2LsubL=\norm{W}_2L_{\text{sub}}, since ∥wy−wj∥2≤2∥W∥2\norm{\mathbf w_y-\mathbf w_j}_2\le\sqrt2\norm{W}_2.

The catch is LL. For a network WLϕ(⋯ϕ(W1x))W_L\phi(\cdots\phi(W_1\mathbf x)) with 1-Lipschitz activations, the product ∏ℓ∥Wℓ∥2\prod_\ell\norm{W_\ell}_2 of the spectral norms is an upper bound, cheap to compute and often wildly loose. With W1=diag⁡(10,0.1)W_1=\diag(10,0.1) and W2=diag⁡(0.1,10)W_2=\diag(0.1,10) each factor is 10 and the bound is 100, yet W2DW1W_2DW_1 has norm at most 1 for every 0/1 diagonal DD a ReLU can produce, so the true constant is 1. A loose LL certifies tiny radii. The alternative is to build networks whose constant is known by construction, Lipschitz networks, and that turns out to need more than constraining the weights.

Every layer of a norm-constrained network can only shrink the gradient, so an expressive 1-Lipschitz network needs layers that preserve it. Anil et al. proposed GroupSort, which sorts groups of pre-activations; with groups of two it is MaxMin, (a,b)↦(max⁡(a,b),min⁡(a,b))(a,b)\mapsto(\max(a,b),\min(a,b)). Its Jacobian is a permutation matrix, so it preserves gradient norms. With ∞\infty-norm-constrained weights they proved GroupSort networks universal approximators of Lipschitz functions; whether the same holds under 2-norm constraints they left open. For convolutions, Trockman and Kolter (2021) parameterized exactly orthogonal layers with the Cayley transform Q=(I−A)(I+A)−1Q=(I-A)(I+A)^{-1} of a skew-symmetric AA, computed efficiently for circular convolutions in the Fourier domain. Such networks certify with a single forward pass, but only in ℓ2\ell_2, and constraining every layer costs clean accuracy: Trockman and Kolter's most accurate orthogonal network reached 83% on CIFAR-10, and the one with the best certificates 75%, while an unconstrained wide ResNet reaches about 95% (Madry et al., 2018).

Check your understanding

Every layer of a network has spectral norm at most 1 and its activations are 1-Lipschitz. At an input, the top logit beats every other by at least 0.6. What ℓ2\ell_2 radius does the Lipschitz-margin certificate guarantee?

  1. 0.6/2≈0.420.6/\sqrt2\approx0.42
  2. 0.6
  3. 0.3
  4. 0.62≈0.850.6\sqrt2\approx0.85
Show the answer

A. 0.6/2≈0.420.6/\sqrt2\approx0.42

With L=1L=1 the radius is m/(2L)=0.6/2≈0.424m/(\sqrt2L)=0.6/\sqrt2\approx0.424. The 2\sqrt2 appears because a perturbation can raise one logit and lower another at the same time: a margin is a difference of two logits, and ∥ey−ej∥2=2\norm{\mathbf e_y-\mathbf e_j}_2=\sqrt2.

Randomized smoothing

Bound propagation and Lipschitz layers both constrain the network. Randomized smoothing constrains nothing: it replaces any base classifier ff by its vote under Gaussian noise, g(x)=arg max⁡cPr⁡η∼N(0,σ2I)[f(x+η)=c]g(\mathbf x)=\argmax_c\Pr_{\boldsymbol\eta\sim\mathcal N(\mathbf 0,\sigma^2I)}[f(\mathbf x+\boldsymbol\eta)=c] (Lecuyer et al., 2019; Cohen, Rosenfeld & Kolter, 2019).

Cohen et al. proved it with the Neyman–Pearson lemma, by finding the worst base classifier, a half-space. A shorter route shows that smoothing makes every class probability Lipschitz in a nonlinear way (Salman et al., 2019):

DerivationProof: Φ⁻¹ of a smoothed classifier is Lipschitz
  1. u⊤∇h^(x)=1σ E[h(x+η) Z]\mathbf u^\top\nabla\hat h(\mathbf x)=\frac1\sigma\,\E\big[h(\mathbf x+\boldsymbol\eta)\,Z\big]

    Fix one class, let h(x)∈[0,1]h(\mathbf x)\in[0,1] indicate it, and let h^(x)=Eη[h(x+η)]\hat h(\mathbf x)=\E_{\boldsymbol\eta}[h(\mathbf x+\boldsymbol\eta)]. Differentiating the Gaussian density moves the gradient onto the noise (Stein's identity): for a unit vector u\mathbf u and Z=u⊤η/σ∼N(0,1)Z=\mathbf u^\top\boldsymbol\eta/\sigma\sim\mathcal N(0,1),

  2. u⊤∇h^(x)≤1σ E[Z 1{Z>−Φ−1(p)}]=1σ Φ′(Φ−1(p))\mathbf u^\top\nabla\hat h(\mathbf x)\le\frac1\sigma\,\E\Big[Z\,\mathbf 1\big\{Z>-\Phi^{-1}(p)\big\}\Big]=\frac1\sigma\,\Phi'\big(\Phi^{-1}(p)\big)

    Among all functions with values in [0,1][0,1] and the same mean p=h^(x)p=\hat h(\mathbf x), E[hZ]\E[hZ] is largest when hh puts all of its mass where ZZ is largest, h=1{Z>−Φ−1(p)}h=\mathbf 1\{Z>-\Phi^{-1}(p)\}: a half-space again. With Φ′\Phi' the standard normal density,

  3. u⊤∇ Φ−1(h^(x))=u⊤∇h^(x)Φ′(Φ−1(h^(x)))≤1σ⟹Φ−1∘h^  is 1σ-Lipschitz\mathbf u^\top\nabla\,\Phi^{-1}\big(\hat h(\mathbf x)\big)=\frac{\mathbf u^\top\nabla\hat h(\mathbf x)}{\Phi'\big(\Phi^{-1}(\hat h(\mathbf x))\big)}\le\frac1\sigma\qquad\Longrightarrow\qquad\Phi^{-1}\circ\hat h\ \text{ is }\tfrac1\sigma\text{-Lipschitz}

    Since ddpΦ−1(p)=1/Φ′(Φ−1(p))\frac{d}{dp}\Phi^{-1}(p)=1/\Phi'(\Phi^{-1}(p)), the chain rule turns this into a constant bound on the slope:

  4. Φ−1(h^A(x+δ))−Φ−1(h^B(x+δ)) ≥ Φ−1(pA)−Φ−1(pB)−2∥δ∥2σ > 0whenever∥δ∥2<σ2(Φ−1(pA)−Φ−1(pB))□\Phi^{-1}\big(\hat h_A(\mathbf x+\boldsymbol\delta)\big)-\Phi^{-1}\big(\hat h_B(\mathbf x+\boldsymbol\delta)\big)\ \ge\ \Phi^{-1}(p_A)-\Phi^{-1}(p_B)-\frac{2\norm{\boldsymbol\delta}_2}{\sigma}\ >\ 0\quad\text{whenever}\quad\norm{\boldsymbol\delta}_2<\frac\sigma2\Big(\Phi^{-1}(p_A)-\Phi^{-1}(p_B)\Big)\qquad\square

    Apply this to class AA and to any other class BB. Along a perturbation δ\boldsymbol\delta, Φ−1(h^A)\Phi^{-1}(\hat h_A) falls by at most ∥δ∥2/σ\norm{\boldsymbol\delta}_2/\sigma and Φ−1(h^B)\Phi^{-1}(\hat h_B) rises by at most as much, so their gap shrinks by at most twice that. Since Φ−1\Phi^{-1} is increasing, a positive gap means AA still wins:

Predict before you look

A smoothed classifier with σ=0.5\sigma=0.5 has top-class probability pA=0.99p_A=0.99 under the noise, and pB=1−pAp_B=1-p_A. What ℓ2\ell_2 radius does it certify? (Φ−1(0.99)≈2.326\Phi^{-1}(0.99)\approx2.326.)

Show the answer

1.16

R=σΦ−1(pA)=0.5×2.326≈1.16R=\sigma\Phi^{-1}(p_A)=0.5\times2.326\approx1.16, in units where pixels lie in [0,1][0,1]. Bounding instead the ordinary Lipschitz constant of h^A−h^B\hat h_A-\hat h_B, which is 2/π/σ\sqrt{2/\pi}/\sigma, would certify only σ(pA−pB)π/2≈0.61\sigma(p_A-p_B)\sqrt{\pi/2}\approx0.61: here the Φ−1\Phi^{-1} transform almost doubles the radius.

In practice pAp_A is unknown and must be estimated. Cohen et al. guess the top class from a few noisy samples, draw nn more, and certify with a one-sided Clopper–Pearson lower bound on pAp_A at confidence 1−α1-\alpha, abstaining when the bound falls below 12\frac12; the certificate then holds with probability at least 1−α1-\alpha over the sampling. Even a unanimous vote gives a lower bound of only α1/n\alpha^{1/n}, which caps the certifiable radius at σΦ−1(α1/n)\sigma\Phi^{-1}(\alpha^{1/n}). The cap grows very slowly: at α=0.001\alpha=0.001 it is about 3.2σ3.2\sigma for n=10,000n=10{,}000 samples, 3.8σ3.8\sigma for Cohen et al.'s n=100,000n=100{,}000 and 4.3σ4.3\sigma for a million. A larger σ\sigma certifies larger radii but makes the base classifier's job harder, so accuracy falls.

Denoised smoothing. The base classifier must cope with heavy noise, which standard classifiers do not. Salman et al. (2020) placed a denoiser in front of an off-the-shelf classifier, and Carlini et al. (2023) used a pretrained diffusion model as that denoiser: noise of level σ\sigma matches the diffusion forward process at the step t⋆t^\star with σ2=(1−αˉt⋆)/αˉt⋆\sigma^2=(1-\bar\alpha_{t^\star})/\bar\alpha_{t^\star}, so one denoising call on αˉt⋆ (x+η)\sqrt{\bar\alpha_{t^\star}}\,(\mathbf x+\boldsymbol\eta), followed by a standard classifier, serves as the base classifier. Without training anything, this certified 71% of ImageNet at ℓ2\ell_2 radius 0.5, 14 points above the previous best certified result of any method (Diffusion Models).

The ℓ∞\ell_\infty wall. An ℓ2\ell_2 radius RR covers only ℓ∞\ell_\infty perturbations of size R/dR/\sqrt d: for ImageNet-sized images and the ℓ2\ell_2 radii that smoothing typically certifies, less than one 8-bit intensity level per pixel (the Artificial Intelligence course's Adversarial Examples & Robustness works through the numbers). Smoothing cannot do much better: for p>2p>2, the ℓp\ell_p radius that a broad class of noise distributions with independent, identically distributed coordinates can certify shrinks like d1/p−1/2d^{1/p-1/2} (Kumar, Levine, Goldstein & Feizi, 2020), and noise that certifies a fixed ℓ∞\ell_\infty radius for every base classifier needs a variance growing in proportion to dd on almost every pixel, which swamps the image (Blum, Dick, Manoj & Zhang, 2020).

Choosing a certificate

MethodGuaranteeScales toMain limitation
MILP, branch and boundComplete: certifies every robust input and finds every counterexampleNetworks of modest size; more than 100,000 ReLUs when most units are stableExponential time in the worst case
Interval bound propagationSound and deterministic, for any boxLarge networks: two matrix products per layerLoose unless the network is trained for it
Linear relaxations (CROWN, LP duals)Sound and tighter than intervals; complete with branching (β-CROWN)Medium to large networksMore compute and memory; tighter bounds do not always train better
Lipschitz networksSound and deterministic in ℓ2\ell_2, from one forward passAny size, if every layer is constrainedConstrained layers cost accuracy; ℓ2\ell_2 only
Randomized smoothingℓ2\ell_2, with probability 1−α1-\alpha, for any base classifierImageNet and pretrained modelsMany noisy forward passes per input; ℓ∞\ell_\infty radii vanish in high dimension
Deterministic methods certify the network you have and suit small radii and ℓ∞\ell_\infty; smoothing certifies a different, slower classifier, in ℓ2\ell_2, at a scale no deterministic method has reached.

Key takeaways

  • Certifying an ℓp\ell_p ball means lower-bounding the minimum margin over it. Doing so exactly is NP-complete for ReLU networks; MILP encodes each unstable ReLU with one binary variable, and relaxing it gives the triangle, the convex hull of a single ReLU.
  • Interval bound propagation maps centers by WW and radii by ∣W∣\abs W: cheap, but loose because it forgets correlations between units. Linear relaxations such as CROWN are tighter, branch and bound makes them complete, and certified training makes the bounds tight enough to use, although tighter relaxations do not always train better.
  • An LL-Lipschitz logit map certifies the ℓ2\ell_2 radius m/(2L)m/(\sqrt2L). Products of spectral norms can vastly overestimate LL, and expressive 1-Lipschitz networks need gradient-norm-preserving layers such as GroupSort and orthogonal convolutions.
  • Gaussian smoothing makes Φ−1\Phi^{-1} of each class probability 1/σ1/\sigma-Lipschitz, which certifies σ2(Φ−1(pA)−Φ−1(pB))\frac\sigma2\big(\Phi^{-1}(p_A)-\Phi^{-1}(p_B)\big) for any base classifier; Monte Carlo estimates make it hold with probability 1−α1-\alpha, and diffusion denoisers let it use off-the-shelf models.
  • Certificates lag empirical robustness, most of all for ℓ∞\ell_\infty in high dimension, where converted ℓ2\ell_2 radii shrink by d\sqrt d and independent smoothing noise cannot close the gap.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

Exact verification of ReLU networks is NP-complete. What does this imply in practice?

  1. No ReLU network can ever be verified exactly
  2. Verification is easy for networks with more than 100,000 ReLUs
  3. Unless P = NP, every complete verifier, MILP included, takes superpolynomial time on some networks, so practical verifiers either stay at modest scale or give up completeness for speed
  4. Attacks are NP-complete too, so adversarial examples must be rare
Show the answer

C. Unless P = NP, every complete verifier, MILP included, takes superpolynomial time on some networks, so practical verifiers either stay at modest scale or give up completeness for speed

NP-completeness is a worst-case statement. MILP verifiers handle networks with many ReLUs when good bounds make most units stable, while sound but incomplete methods (intervals, linear relaxations, Lipschitz bounds, smoothing) trade the ability to certify every robust input for speed.

Question 2

Why can interval bound propagation fail to certify a point that is in fact robust?

  1. It ignores the bias terms
  2. It treats every unit's interval as independent, so it can pair one unit's worst value with another's even when no single input produces both
  3. It only works with sigmoid activations
  4. It estimates the bounds by random sampling
Show the answer

B. It treats every unit's interval as independent, so it can pair one unit's worst value with another's even when no single input produces both

Each layer's box is the tightest box around the image of the previous box, but the activations actually reachable form a correlated, slanted set inside it. In the worked example IBP paired h1=0.2h_1=0.2 with h2=0.8h_2=0.8, which no input in the box produces together.

Question 3

You bound your network's Lipschitz constant by the product of its layers' spectral norms, and the certified radii come out tiny. What is the most likely reason?

  1. The product can vastly overestimate the true constant, because the directions one layer stretches need not be the ones the next layer stretches
  2. The network cannot be robust at all
  3. Spectral norms underestimate the Lipschitz constant
  4. Lipschitz certificates only work for ℓ∞\ell_\infty perturbations
Show the answer

A. The product can vastly overestimate the true constant, because the directions one layer stretches need not be the ones the next layer stretches

The product is an upper bound that is tight only when the layers' top singular directions line up. In the diagonal example each layer has norm 10 and the product is 100, while the network's true constant is 1. Lipschitz networks avoid the problem by constraining every layer, so that the product is the constant.

Question 4

A randomized-smoothing certificate was computed from nn noisy samples at confidence 1−α1-\alpha. Which statement about it is correct?

  1. It holds deterministically for every input within the radius
  2. It also certifies the base classifier ff within the radius
  3. It certifies the same radius in ℓ∞\ell_\infty
  4. With probability at least 1−α1-\alpha over the sampling, the smoothed classifier's prediction is constant within the certified ℓ2\ell_2 radius
Show the answer

D. With probability at least 1−α1-\alpha over the sampling, the smoothed classifier's prediction is constant within the certified ℓ2\ell_2 radius

The certificate concerns gg, the vote under noise, and rests on a confidence bound for pAp_A; with probability at most α\alpha that bound is too optimistic. The base classifier can still have adversarial examples arbitrarily close to x\mathbf x, and an ℓ2\ell_2 radius RR covers only ℓ∞\ell_\infty perturbations of size R/dR/\sqrt d.

Further reading

  • G. Katz, C. Barrett, D. Dill, K. Julian & M. Kochenderfer, "Reluplex: an efficient SMT solver for verifying deep neural networks," CAV (2017).
  • S. Gowal et al., "On the effectiveness of interval bound propagation for training verifiably robust models," arXiv:1810.12715 (2018); published at ICCV (2019) as "Scalable verified training for provably robust image classification".
  • Y. Tsuzuku, I. Sato & M. Sugiyama, "Lipschitz-margin training: scalable certification of perturbation invariance for deep neural networks," NeurIPS (2018).
  • J. M. Cohen, E. Rosenfeld & J. Z. Kolter, "Certified adversarial robustness via randomized smoothing," ICML (2019).
  • H. Salman, G. Yang, J. Li, P. Zhang, H. Zhang, I. Razenshteyn & S. Bubeck, "Provably robust deep learning via adversarially trained smoothed classifiers," NeurIPS (2019).