Foundations to Frontier
Tests
M. Robust, Verifiable and Onboard AI › M1 Adversarial Robustness

Certified Robustness and Randomised Smoothing

Attacks can show that a model is not robust, but no attack can prove that it is. Certified defences give a guarantee: for a given input, no perturbation within a stated radius can change the prediction. This page covers the main approaches (exact verification, bound propagation, Lipschitz bounds) and builds the one that scales best to large models, randomised smoothing (Cohen, Rosenfeld and Kolter, 2019): classify many Gaussian-noised copies of the input, take the majority vote, and turn a statistical lower bound on the vote share into a certified L2 radius σ·Φ⁻¹(pA). The exercises implement exact Clopper–Pearson bounds, the CERTIFY procedure and certified-accuracy curves, and measure the trade-off set by the noise level σ.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

A guarantee instead of a test

Testing a bridge with the heaviest truck you can find does not prove it will hold every truck. Attacks are like that truck: when they fail, a stronger attack might still succeed, and history is full of defences that looked robust until a better attack arrived. A certificate is a proof instead: for this input, no change smaller than a stated size can alter the answer. Randomised smoothing gets such proofs in a surprisingly simple way. It asks the model about many noisy copies of the input and reports the majority answer; if the majority is large enough, a small change to the input cannot overturn it.

🎮 Robustness lab
If at least 99.00% of noisy copies (sigma 1) are classified as class A, no perturbation of L2 size below 2.326 can change the smoothed prediction.
certified accuracy at radius 1
91.0%
normal network under PGD at 1
90.0%
The certificate is a guarantee; the PGD figure is only an upper bound on the normal network's true robustness. With 1000 samples the largest radius sigma 1 can certify is 2.46.
Why engineers care

Randomised smoothing gave the first non-trivial certified L2 robustness on ImageNet (Cohen, Rosenfeld and Kolter, 2019).

📝 Quick check (Level 0)
0/3 answered
  1. 1. A certificate proves that…
  2. 2. Randomised smoothing classifies…
  3. 3. A failed attack shows…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Certified (provable) robustness: a proof that f(x + δ) = f(x) for every ‖δ‖ ≤ R; certified accuracy at radius R is the share of test points that are both correct and certified at R.
  • Complete (exact) verification: decides robustness exactly, for example with mixed-integer programming or SMT (topics M2-1 and M2-3); exponential in the worst case.
  • Incomplete verification: sound but possibly loose bounds, such as interval bound propagation and linear relaxations (topic M2-2) or global Lipschitz bounds.
  • Smoothed classifier: g(x) = the most likely class of f(x + ε), ε ~ N(0, σ²I).
  • Cohen’s theorem: if class A has probability at least pA and every other class at most pB under the noise, then g is constant within L2 radius σ/2·(Φ⁻¹(pA) − Φ⁻¹(pB)); with pB = 1 − pA this is σ·Φ⁻¹(pA).
  • CERTIFY and PREDICT: Monte Carlo procedures that estimate the class probabilities with Clopper–Pearson confidence bounds and abstain when unsure.
  • Noise level σ: larger σ certifies larger radii but blurs the input, lowering accuracy.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Certified accuracy at radius R counts points that are…
  2. 2. The smoothed classifier adds noise drawn from…
  3. 3. With pB = 1 − pA, the certified radius is…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Certifying with noise

Exercise 1.

  • The mixture data of topics M1-2 and M1-3; base networks trained with Gaussian noise added to the inputs.
  • Exact one-sided Clopper–Pearson lower bounds for a binomial proportion, computed by bisection on the binomial tail.
  • CERTIFY: guess the top class from n0 = 100 noisy samples, count it in n = 1000 fresh samples, lower-bound pA at confidence 1 − alpha (alpha = 0.001), and return the radius σ·Φ⁻¹(pA_lower) or abstain.
  • Checks: the bound equals alpha^(1/n) when all samples agree; for a linear base classifier the certified radii fall just below the exact L2 distances to the boundary.

Practice.

  • Train the base model with the same Gaussian noise used for smoothing (or with SmoothAdv, adversarial training of the smoothed classifier).
  • Choose σ for the radius you need: the largest certifiable radius is about σ·Φ⁻¹(alpha^(1/n)), 2.46σ for n = 1000 and 3.8σ for n = 100,000.
  • Report certified accuracy curves over radii, the noise level, the number of samples, alpha and the abstention rate.
  • Use separate samples to select the class and to estimate its probability, or the confidence bound is invalid.
  • Remember what is certified: the smoothed classifier g, which costs thousands of forward passes per prediction, not the base network.
def certify(P, x, sigma, n0=100, n=1000, alpha=0.001, rng=None):
    cA = int(sample_counts(P, x, sigma, n0, rng).argmax())    # select the class
    k = int(sample_counts(P, x, sigma, n, rng)[cA])           # estimate with fresh samples
    pA = lower_conf_bound(k, n, alpha)                         # Clopper–Pearson
    if pA <= 0.5: return -1, 0.0                               # abstain
    return cA, sigma * NormalDist().inv_cdf(pA)
🐍 Exercise 1: Clopper–Pearson bounds and CERTIFY
Implement noise-augmented training, exact Clopper–Pearson lower bounds and the CERTIFY procedure, and check it against a linear classifier whose exact distances are known.
📝 Quick check (Level 2)
0/3 answered
  1. 1. The base model should be trained…
  2. 2. With n = 1000 and alpha = 0.001 the largest certifiable radius is about…
  3. 3. Class selection and probability estimation should use…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Why the radius is σ·Φ⁻¹(pA). Compare the noise distributions N(x, σ²I) and N(x + δ, σ²I). Among all base classifiers that give class A probability pA at x, the one whose probability of A at x + δ is smallest is the worst case; by the Neyman–Pearson lemma it is a half-space perpendicular to δ. For that half-space the probability of A moves from pA = Φ(a) to Φ(a − ‖δ‖/σ). It stays above 1/2 exactly while ‖δ‖ < σ·Φ⁻¹(pA), and comparing with the runner-up class gives the general radius σ/2·(Φ⁻¹(pA) − Φ⁻¹(pB)). The bound is tight: a linear base classifier attains it, which Exercise 1 checks numerically.

From estimates to guarantees. pA is unknown and estimated from n samples, so CERTIFY uses a one-sided Clopper–Pearson lower bound valid with probability 1 − alpha. If every sample agrees, the bound is alpha^(1/n), which caps the radius at σ·Φ⁻¹(alpha^(1/n)). Because Φ⁻¹ grows like √(2 log(1/(1 − p))), the cap grows only like √(log n): each tenfold increase in n adds less radius.

Limits and alternatives. Gaussian smoothing certifies L2 balls; since ‖δ‖₂ ≤ √d‖δ‖∞, it certifies only R/√d in L∞, and for L∞ in high dimension smoothing-based certificates are provably weak. Lipschitz certificates use margin/L, where L bounds how fast the margin can change; products of layer norms give sound but loose L unless the network is trained to keep it small. Bound-propagation methods (topic M2-2) certify the network itself and handle L∞ naturally, but are hard to scale to very deep networks.

📝 Quick check (Level 3)
0/3 answered
  1. 1. The worst-case base classifier in Cohen's proof is…
  2. 2. The radius cap grows with the number of samples like…
  3. 3. An L2 radius R certifies an L∞ radius of…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

How does the noise level σ trade certified radius against accuracy, and how close do the certified accuracies come to the accuracy an ordinary network keeps under a strong L2 attack?

History.

  • G. Katz and colleagues (2017, Reluplex) and V. Tjeng, K. Xiao and R. Tedrake (2019, mixed-integer programming) verified networks exactly; E. Wong and J. Z. Kolter (2018) and A. Raghunathan, J. Steinhardt and P. Liang (2018) trained networks with certificates from convex relaxations; S. Gowal and colleagues (2018) introduced interval bound propagation training; Y. Tsuzuku, I. Sato and M. Sugiyama (2018) trained for Lipschitz margins.
  • M. Lecuyer and colleagues (2019, PixelDP) and B. Li and colleagues (2019) introduced randomised smoothing; J. Cohen, E. Rosenfeld and J. Z. Kolter (2019) proved the tight L2 guarantee.
  • H. Salman and colleagues (2019) combined smoothing with adversarial training; G. Yang and colleagues (2020) extended it to other norms; A. Kumar and colleagues (2020) showed its limits for L∞ in high dimension; N. Carlini and colleagues (2023) used diffusion-model denoisers to smooth off-the-shelf classifiers.

Exercise 2.

  • Base networks trained with noise σ = 0.25, 0.5, 1 and 2 on 1000 points; CERTIFY on 200 test points with n0 = 100, n = 1000, alpha = 0.001.
  • Comparison: a normally trained network under 20-step margin-loss L2 PGD at the same radii, which gives an upper bound on that network’s true robust accuracy.

Certified accuracy, seed 0:

σ R = 0 0.5 1 1.5 2 3 abstain largest certifiable R
0.25 0.995 0.960 0 0 0 0 0 0.62
0.5 0.995 0.980 0.890 0 0 0 0.005 1.23
1 0.995 0.975 0.910 0.785 0.535 0 0 2.46
2 0.955 0.860 0.780 0.605 0.380 0.065 0.045 4.93
normal network, L2 PGD 0.990 0.965 0.900 0.790 0.635 0.250 — —

Seeds 1 and 2, best certified accuracy over σ at R = 1: 0.740 and 0.850 (normal network under PGD: 0.780 and 0.855); at R = 2: 0.290 and 0.435 (PGD: 0.380 and 0.500).

Findings.

  • Each σ certified nothing beyond about 2.46σ, the cap for n = 1000: σ = 0.25 certified no point at radius 1 even though most points were far from the boundary.
  • Larger σ cost accuracy: at σ = 2 the accuracy at radius 0 fell to 0.955 (0.855 and 0.940 for seeds 1 and 2) and 4.5% of points were abstained on (14% and 5.5%), but only σ = 2 certified anything at radius 3.
  • At small radii the guarantees nearly matched what an ordinary network keeps under attack (0.910 certified against 0.900 empirical at radius 1 for seed 0); the gap grew with the radius (0.535 against 0.635 at radius 2; 0.065 against 0.250 at radius 3). The empirical figures are only upper bounds, so the true gap is smaller.
🐍 Exercise 2 (research): how does the noise level σ trade certified radius against accuracy, and how close do the certified accuracies come to the accuracy an ordinary network keeps under a strong L2 attack?
Certify a smoothed classifier at several noise levels, plot certified accuracy against radius, and compare with the accuracy of an ordinary network under an L2 attack.

Certification in practice

  • Randomised smoothing scales to ImageNet and works with any base model, including denoiser-plus-classifier pipelines built from pretrained models; its costs are thousands of forward passes per prediction and guarantees only for L2-type threat models.
  • Deterministic certification with bound propagation and branch-and-bound (α,β-CROWN, the winner of several VNN-COMP verification competitions) certifies the network itself and is used for smaller safety-critical networks such as aircraft collision avoidance (ACAS Xu) and control policies.
  • Beyond Lp balls: certificates against geometric transformations, patches, data poisoning and, for language models, word substitutions.
  • For safety-critical systems, certificates are evidence in a safety case (topic M2-5), alongside testing and runtime monitoring.

References

  1. J. Cohen, E. Rosenfeld and J. Z. Kolter (2019). “Certified adversarial robustness via randomized smoothing.” ICML.
  2. M. Lecuyer and colleagues (2019). “Certified robustness to adversarial examples with differential privacy.” IEEE Symposium on Security and Privacy.
  3. H. Salman and colleagues (2019). “Provably robust deep learning via adversarially trained smoothed classifiers.” NeurIPS.
  4. E. Wong and J. Z. Kolter (2018). “Provable defenses against adversarial examples via the convex outer adversarial polytope.” ICML.
  5. A. Kumar, A. Levine, T. Goldstein and S. Feizi (2020). “Curse of dimensionality on randomized smoothing for certifiable robustness.” ICML.
  6. C. J. Clopper and E. S. Pearson (1934). “The use of confidence or fiducial limits illustrated in the case of the binomial.” Biometrika.