wikillm

Paper · 2019-05-23 · cs.LG, cs.CV, stat.ML

Adversarially Robust Distillation

Adversarially Robust Distillation (ARD) trains a small student to match a robust teacher's softmax on clean images while the student is attacked with PGD, so robustness transfers during distillation. Author-reported on CIFAR-10: an ARD MobileNetV2 from a TRADES WideResNet reaches 50.42% robust accuracy versus 46.90% for an adversarially trained MobileNetV2 of the same size.

Knowledge distillationAdversarial trainingAdversarial robustnessadversarial-robustnessknowledge-distillationmodel-compression

arXivPDFCodeMarkdown13 min read

AI-compiled by claude-haiku-5-5 on 2026-11-05, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

In plain words

Small neural networks are cheap to run, but they are easy to fool: a tiny, almost invisible change to an image can flip the answer. Making a small network resist such changes usually means adversarial training, which is slow because every training batch needs extra attack computations.

This paper asks whether a small network can inherit robustness from a big, already robust network, the same way it inherits accuracy in ordinary distillation. The student learns to copy the teacher's answers, but its copy is checked on attacked versions of the images. The paper also finds that distilling a robust teacher onto clean images alone passes on a good share of the robustness.

The method is named Adversarially Robust Distillation (ARD). It makes a small network robust, and in the paper's experiments it beats a small network that was trained adversarially from scratch.

TL;DR

  • Distilling a robust teacher onto a small student transfers much of the teacher's robustness, even when the student sees only clean images §4.2.
  • ARD trains the student to match the teacher's softmax on adversarial inputs (the student is attacked) §5 eq. 1.
  • Author-reported CIFAR-10 result: ARD MobileNetV2 from a TRADES WideResNet teacher gets 50.42% robust accuracy, versus 46.90% for adversarially trained MobileNetV2 tab. 6.
  • ARD costs about as much training time as adversarial training, so the cheap part is the student, not the training tab. 10.
  • Official PyTorch code is MIT-licensed and matches most of the method, but its test attack and learning-rate schedule differ from the paper (see Paper vs code).

Problem

Knowledge distillation trains a small student to match a large teacher's outputs and gives accurate, compact models. The student is usually not robust to adversarial examples, even when the teacher is robust §1 §2. Adversarial training makes a model robust but needs many gradient computations per batch, so it is slow §5.4. Defensive distillation is reported as broken by stronger attacks §2. The paper focuses on ℓ∞ attacks §3.

The question is whether robustness moves from a robust teacher to a student during distillation §4, and whether a distillation loss built on adversarial inputs can produce better robust students than adversarial training of the same architecture §5.

Method

Robustness transfer under plain distillation §4. The authors distill a non-robust ResNet18 teacher, which gives a student with 0% robust accuracy under 20-step PGD §4.1 tab. 2. Distilling an adversarially trained ResNet18 gives a student that keeps most of the teacher's robust accuracy §4.2 tab. 3. Robust WideResNet teachers transfer less robustness than the weaker ResNet18 teacher, and on CIFAR-100 a robust WideResNet transfers almost none §4.3 tab. 4 tab. 5.

ARD objective §5 eq. 1. The student S_θ with teacher T and temperature t is trained with

\min_{\theta}\ \mathbb{E}_{(X,y)\sim\mathcal{D}}\Big[\alpha t^2\, \mathrm{KL}\big(S_\theta^t(X+\delta_\theta),\,T^t(X)\big) + (1-\alpha)\,\ell\big(S_\theta^t(X),\,y\big)\Big] \qquad \delta_\theta=\arg\max_{\|\delta\|_p<\epsilon}\ell\big(S_\theta^t(X+\delta),y\big) eq. 1 §5

Here ℓ is cross-entropy, S^t and T^t are logits divided by the temperature before the softmax, and α sets the balance. The attack δ_θ is computed against the student, while the teacher sees clean X. The t² factor offsets the gradient shrinkage caused by dividing the logits by t §5. The paper sets α = 1 in most experiments, which removes the clean cross-entropy term §5.

Training procedure alg. 1 §5. For each batch: build adversarial examples for the student with K-step PGD on cross-entropy against the true labels, then take one SGD step on the ARD loss alg. 1. Teacher logits on clean inputs are the targets §5.

Pseudocode
# ARD training step  [alg. 1] [§5] [eq. 1]
# Input: student, frozen teacher, images (B, 3, H, W), labels (B,)
# Output: scalar loss for one SGD step

def ard_loss(student, teacher, images, labels, temp, alpha):
    # Attack the student; adversarial inputs depend on the student  [alg. 1]
    adv_images = pgd_attack(student, images, labels)

    # Teacher soft targets computed on the clean images  [§5] [eq. 1]
    teacher_probs = softmax(teacher(images) / temp)

    # Student soft predictions on the adversarial images  [§5] [eq. 1]
    student_log_probs = log_softmax(student(adv_images) / temp)

    # KL(teacher || student), scaled by alpha and temp squared  [§5] [eq. 1]
    distill = kl_divergence(teacher_probs, student_log_probs)
    distill = alpha * temp * temp * distill

    # Clean cross-entropy term, weighted by (1 - alpha)  [§5]
    xent = cross_entropy(student(images), labels)

    return distill + (1 - alpha) * xent
Pseudocode
# K-step l-infinity PGD on cross-entropy  [§8] [alg. 1]
# Input: model, images (B, 3, H, W), labels (B,)
# Output: adversarial images inside the eps-ball around images

def pgd_attack(model, images, labels, eps, step, num_steps):
    # Start from a uniform random point in the eps-ball  [§8] [code: main.py#L70]
    adv = images + uniform(-eps, eps)
    for _ in range(num_steps):
        # Ascend the cross-entropy with a signed gradient step  [§8]
        grad = grad_cross_entropy(model(adv), labels, wrt=adv)
        adv = adv + step * sign(grad)
        # Project back into the eps-ball around the clean images  [alg. 1]
        adv = clip(adv, images - eps, images + eps)
        # Keep pixel values in [0, 1]  [code: main.py#L78]
        adv = clip(adv, 0, 1)
    return adv

The method's parameter values are in the table below §8.

Fast-ARD §5.4 alg. 2. The authors adapt "free" adversarial training to distillation. Each mini-batch is replayed m times. On each replay, one backward pass gives both the input gradient, used for a 1-step attack that keeps a running perturbation δ per training image, and the parameter gradient for the update. The epoch count is divided by m so the total training time matches plain distillation alg. 2 §5.4. The paper reports m = 4 and m = 8 tab. 9.

Extensions noted by the paper. Combining ARD with a non-adversarial KL term, using teacher outputs at adversarial points, and maximising the KL instead of cross-entropy in the attack all lowered robust accuracy or natural accuracy app. B. Passing adversarial examples through a large teacher slows training and raises memory use app. B.

Hyperparameters

NameValueWhereNotes
Lossα t² KL + (1 − α) cross-entropyeq. 1 §5ARD loss as written in the training algorithm alg. 1
Attack normℓ∞§3only ℓ∞ attacks are studied
Attack radius ε8/255§8 main.py
Attack step size2/255§8 main.py
Attack steps during training10 (K-step PGD)§8 main.pyARD algorithm writes K; §8 fixes 10
Random startyes§8 main.pyuniform in [−ε, ε] in code
Temperature t30 for CIFAR-10, 5 for CIFAR-100§8code default is 30 main.py; code has no CIFAR-100 setting
α1 by default; lower for harder tasks§5 §8code default 1.0 main.py
α used in results0.95 (Table 6); 0.93 (Table 7, CIFAR-100)tab. 6 tab. 7
OptimizerSGD, momentum 0.9§8 main.py
Weight decay2e-4§8 main.py
Epochs200§8 main.pyFast-ARD uses 200/m epochs §8
Initial learning rate0.1§8 main.py
LR schedule÷10 at epochs 100 and 150§8 main.pycode does not match; see Paper vs code
Batch sizenot stated—code: 128 for CIFAR-10, 256 for CIFAR-100 main.py main.py; test batch 100 main.py
Data augmentationrandom crops and horizontal flipsapp. Bcode pads by 4 pixels before cropping main.py
Teacher architecturesWideResNet 34-10; ResNet18§3 §8code default WideResNet depth 34, widen factor 10 wideresnet.py
Student architectureMobileNetV2, about 2.3M parameters§6
Fast-ARD replays m4 and 8§5.4 tab. 9
Timing hardwaresingle RTX 2080 Ti, identical batch sizestab. 10
Robust-accuracy test attack20-step PGD (in table captions)tab. 1 tab. 6 tab. 7 tab. 8code test uses the 10-step config; see Paper vs code
Attack random restartsnot stated for training—the 100-restart variant appears only as an evaluation attack tab. 11

Results

Author-reported. CIFAR-10 and CIFAR-100. Teacher and student architectures as in the Hyperparameters table. Robust accuracy is under 20-step PGD unless the row says otherwise. Values are natural accuracy / robust accuracy, in percent.

SettingModelNaturalRobustSource
CIFAR-10, clean distillation from natural ResNet18teacher94.750.00tab. 2
ResNet18 → ResNet1894.920.00tab. 2
ResNet18 → MobileNetV293.530.00tab. 2
CIFAR-10, clean distillation from AT ResNet18AT ResNet18 teacher76.5444.46tab. 3
AT ResNet18 → ResNet1876.1340.13tab. 3
AT ResNet18 → MobileNetV276.8638.21tab. 3
CIFAR-10, clean distillation from robust WRNAT WRN teacher84.4145.75tab. 4
TRADES WRN teacher84.9256.61tab. 4
AT WRN → MobileNetV292.495.46tab. 4
TRADES WRN → MobileNetV285.6021.69tab. 4
CIFAR-100, clean distillation from AT WRNAT WRN teacher59.9028.36tab. 5
AT WRN → MobileNetV225.541.30tab. 5
AT WRN → MobileNetV2, α = 0.9575.940.02tab. 5
AT WRN → MobileNetV2, α = 0.9376.380.00tab. 5
CIFAR-10, ARD from ResNet18 (teacher AT)AT ResNet18 teacher—44.46tab. 1
AT ResNet18 → MobileNetV2 (clean KD)—38.21tab. 1
AT ResNet18 ARD → MobileNetV2—50.22tab. 1
CIFAR-10, ARD from TRADES WRNTRADES WRN teacher84.9256.61tab. 6
AT MobileNetV2 (baseline)80.5046.90tab. 6
TRADES MobileNetV2 (baseline)83.5944.79tab. 6
TRADES WRN ARD → MobileNetV282.6350.42tab. 6
TRADES WRN ARD → MobileNetV2, α = 0.9584.7046.28tab. 6
CIFAR-100, ARD from AT WRNAT WRN teacher59.9028.36tab. 7
AT MobileNetV2 (baseline)55.6222.80tab. 7
AT WRN ARD → MobileNetV2, α = 0.9355.4727.64tab. 7
Same architecture ARDAT ResNet18 (baseline)76.5444.46tab. 8
AT MobileNetV2 (baseline)80.5046.90tab. 8
AT ResNet18 ARD → ResNet1879.4951.21tab. 8
AT MobileNetV2 ARD → MobileNetV281.2247.95tab. 8
AT ResNet18 ARD → MobileNetV279.4750.22tab. 8
Fast-ARD (CIFAR-10, MobileNetV2)free-trained MobileNetV2, m = 482.6323.13tab. 9
TRADES WRN F-ARD → MobileNetV2, m = 483.5137.07tab. 9
free-trained MobileNetV2, m = 872.3027.96tab. 9
TRADES WRN F-ARD → MobileNetV2, m = 876.3836.85tab. 9

Training time, hours, CIFAR-10, one RTX 2080 Ti, 200 epochs of parameter updates per image tab. 10: AT MobileNetV2 41.09; clean distillation from TRADES WRN 5.13; TRADES WRN ARD 41.06; TRADES WRN Fast-ARD m = 4 5.15; m = 8 5.10.

Attacks on MobileNetV2 (CIFAR-10; all numbers are robust validation accuracy, ε = 8/255) tab. 11: AT MobileNetV2 gets 50.82 (MI-FGSM 20 steps), 57.74 (DeepFool), 46.51 (1000-step PGD), 46.79 (20-step PGD, 100 restarts). ARD from TRADES WRN gets 55.16, 64.61, 49.98 and 50.30. Free-trained MobileNetV2 (m = 4) gets 30.60, 41.09, 22.23 and 22.94; Fast-ARD (m = 4) gets 44.78, 60.03, 36.01 and 36.88.

Ablations, author-reported app. A app. C app. D app. E:

AblationSettingNaturalRobustSource
KD temperature (AT ResNet18 → MobileNetV2)t = 1 / 10 / 30 / 50 / 10077.37 / 78.1 / 76.86 / 76.28 / 76.4435.44 / 38.55 / 38.21 / 38.5 / 38.65tab. 12
KD α (AT ResNet18 → MobileNetV2)α = 1.00 / 0.99 / 0.95 / 0.90 / 0.70 / 0.5076.86 / 82.93 / 91.58 / 92.34 / 92.33 / 92.1438.21 / 28.36 / 9.65 / 7.96 / 7.54 / 2.73tab. 13
KD data augmentation (AT WRN → MobileNetV2)none / flips / crops / both / teacher adv. examples75.76 / 76.24 / 76.31 / 76.86 / 76.7632.05 / 35.39 / 37.31 / 38.21 / 38.33tab. 14
ARD from natural teachersResNet18 → MobileNetV2 / WRN → MobileNetV284.18 / 84.4344.61 / 42.51tab. 15
ARD attack steps (TRADES WRN → MobileNetV2)4 / 6 / 10 steps84.28 / 83.38 / 82.6346.49 / 48.35 / 50.42tab. 16
ARD temperature (TRADES WRN → MobileNetV2)t = 1 / 5 / 10 / 30 / 5081.41 / 82.24 / 82.33 / 82.63 / 82.1449.57 / 48.77 / 48.93 / 50.42 / 48.97tab. 17
ARD α (TRADES WRN → MobileNetV2)α = 1.00 / 0.95 / 0.90 / 0.70 / 0.5082.63 / 84.7 / 86.58 / 90.57 / 83.0050.42 / 46.28 / 41.16 / 25.18 / 13.09tab. 18

The paper's own summary: ARD students exceed adversarially trained students of the same architecture in robust accuracy and often in natural accuracy; they also exceed the reported state of the art on CIFAR-10 and CIFAR-100 §7. These are the authors' claims, not verified here.

Paper vs code

Official code: https://github.com/goldblum/AdversariallyRobustDistillation (MIT, Copyright 2019 MicahGoldblum), commit 779ade36d612bddb0a5a705fdd74efe7571a1381. The repo owner is an author. The paper links this repo §8.

  • Test attack is 10 steps, not 20. Robust accuracy in the paper's tables uses 20-step PGD tab. 1 tab. 6. The code builds a single attack object with num_steps 10 and uses it for both training and evaluation main.py main.py. Numbers from this code are therefore not comparable to the paper's 20-step columns.
  • Learning-rate decay does not compound. The paper decreases the LR by a factor of 10 at epochs 100 and 150 §8. The code's adjust_learning_rate multiplies a base value that is passed in unchanged, so both decay epochs set the LR to 0.1 × 0.1 = 0.01 and it never reaches 0.001 main.py main.py. Epochs are also 0-based in the loop, so the first decay happens at index 100 main.py.
  • Adversarial examples are generated with the student in training mode. The attack calls the student inside train(), so each PGD forward pass updates the BatchNorm running statistics main.py main.py. The paper does not describe BatchNorm mode during attack generation.
  • KL reduction and direction. The paper writes KL(S(X+δ), T(X)) eq. 1. The code uses nn.KLDivLoss() with the student's log-probabilities as input and the teacher's probabilities as target, so it computes KL(teacher ‖ student) main.py main.py. The default reduction averages over every element (batch × classes), which is not a per-example sum. The paper does not state a reduction.
  • Teacher runs on every step. The teacher is applied to the clean batch in every iteration main.py. Appendix B notes that stored logits would avoid these forward passes app. B; the code does not use stored logits.
  • Clean cross-entropy is computed even when α = 1. The clean forward pass runs regardless and is multiplied by zero main.py. Its BatchNorm side effect still happens.
  • CIFAR-100 temperature is not in the code. The default temperature is 30 main.py. The paper uses 5 for CIFAR-100 §8. The code has a CIFAR-100 data branch but no temperature setting for it main.py.
  • No teacher training and no adversarial-training baseline. The script loads a teacher checkpoint unconditionally main.py. Adversarial-training teachers and the AT baseline are not in the repo, although the paper says the authors re-implemented them §3.
  • No Fast-ARD. The repo has only the standard ARD loop. The "free" replay of Algorithm 2 alg. 2 is absent.
  • Pixel clamp. The attack clamps to [0, 1] main.py. The paper does not state an input range.
  • Attack initialisation and steps match. Uniform random start, 10 steps, ε = 8/255, step 2/255, and cross-entropy against the true label match §8 alg. 1 main.py main.py.
  • Loss weights and temperature squared match. The loss is α t² times the KL plus (1 − α) cross-entropy, with logits divided by t §5 main.py.
  • Optimiser, momentum, weight decay, initial LR and epoch count match §8 main.py main.py main.py.
  • Batch size is not in the paper. Code uses 128 for CIFAR-10 and 256 for CIFAR-100 main.py main.py.

Pitfalls

  • Expect lower numbers if you use the code's test loop. The code evaluates with a 10-step attack, the paper with 20 steps tab. 1 main.py.
  • Implement the LR schedule as written in the paper, or document the deviation. The code's schedule keeps LR at 0.01 after epoch 150.
  • BatchNorm. Attacks in training mode change BatchNorm statistics. The paper says nothing about this, so it is a choice you must make explicitly.
  • Cost is the main limit. ARD trains as slowly as adversarial training: 41.06 hours against 5.13 for clean distillation in the authors' setup tab. 10. Only the Fast-ARD variant brings the cost down, and the paper reports it as less robust than full ARD §5.4.
  • α trades robustness for accuracy and matters a lot for clean distillation. For clean distillation robustness falls fast as α drops; ARD is less sensitive to α and temperature app. E tab. 13 tab. 18.
  • A robust teacher is required. Naturally trained teachers give students with lower robust accuracy than AT students of the same architecture app. C tab. 15.
  • Robust teachers do not always help. WideResNet teachers transfer less robustness than ResNet18 through clean distillation, and on CIFAR-100 almost none §4.3 tab. 5. ARD is what the paper proposes for these cases §4.3.
  • Only ℓ∞ attacks are studied. The experiments focus on ℓ∞ attacks, and other norms are not evaluated §3.
  • Notation is ambiguous. The order in KL(S(·), T(·)) is written two ways across the paper. Follow the code's convention (teacher as the target distribution) unless you have reason to switch eq. 1 main.py.
  • Hidden tuning. The paper's robust results depend on α = 0.95 or 0.93 for some teachers, and on a specific temperature, whose best value differs by dataset tab. 6 tab. 7 tab. 12 tab. 17.
  • Single-run results. No variance or seed information is given in the paper. Robust accuracy differences of about one point should be treated with caution.
  • Teacher pretraining is not described in terms of the adversarial-training recipe for the teacher beyond "as described in" prior work §3.
  • The reported Fast-ARD numbers depend on m, which changes the epoch count §5.4 tab. 9.

Lineage

  • Builds on: knowledge distillation §1 §3; adversarial training with PGD §3; TRADES and VAT, whose KL consistency terms ARD adapts §3; "free" adversarial training and a related accelerated method, which Fast-ARD adapts §5.4 (no card for these papers).
  • Compared against: defensive distillation §2; defensive quantisation and pruning-based compression §2; adversarial training of same-architecture students §5.
  • Discussed as a possible extension: knowledge distillation with feature maps and adaptive data augmentation such as AutoAugment §7.
  • Superseded by: not stated in this card.

Attribution

Title, authors and the arXiv link are in the frontmatter and the page footer. This card is not endorsed by the authors.

Source and license

Adapted from “Adversarially Robust Distillation” by Micah Goldblum, Liam Fowl, Soheil Feizi, Tom Goldstein (arXiv:1905.09747), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/goldblum/AdversariallyRobustDistillation at commit 779ade36d612 (MIT). Any quoted code is shown under that license.