# Distillation as a Defense to Adversarial Perturbations against Deep Neural Networks

Defensive distillation cuts adversarial sample success on neural networks sharply

Nicolas Papernot, Patrick McDaniel, Xi Wu, Somesh Jha, Ananthram Swami · arXiv · 2015-11-14

- **Problem** Attackers can force a trained DNN to output a chosen class by perturbing its inputs. Earlier defenses either change the architecture or block only some adversarial samples.
- **Method** Defensive distillation retrains a DNN on the soft probability outputs of a first DNN trained at high temperature. Unlike earlier defenses, it keeps the same architecture, and the model runs at temperature 1 at test time.
- **Results** On MNIST, adversarial sample success falls from 95.89% to 0.45% with distillation at T = 100. On CIFAR10 it falls from 87.89% to 5.11%.

## Why trained DNNs stay exposed to adversarial samples

An adversarial sample is built by adding a chosen perturbation to a legitimate input so that the network produces an output the attacker selected, such as a wrong class. Because the attack acts on a finished model at test time, it needs no access to the training procedure, which is why a trained network stays exposed after deployment.

The stakes are concrete: a perturbed road sign or vehicle could be misread by a driverless car, illicit content could pass a filter, and a biometric check could admit the wrong person. The perturbation has to stay small enough that a human still reads the input correctly, which is what makes the altered input hard to spot.

The threat studied here is the source-target, or chosen target, attack, in which a sample from any source class is moved to a target class the attacker picks. Attackers who cannot see the target network can craft samples on a substitute model, since adversarial samples transfer between models, so the threat is not limited to fully informed adversaries.

Earlier defenses either require changing the DNN architecture or block only part of the adversarial samples, which is the gap this work addresses. Requirements for a useful defense include little architectural change, no loss of accuracy, and no large slowdown at test time.

## How the defensive training procedure is built

Distillation was first designed to move knowledge from a larger network or ensemble into a smaller one, which reduces computing cost for constrained devices. Defensive distillation keeps the same procedure but feeds the extracted knowledge back into a model of the same size, so the network improves its own resistance to adversarial inputs.

The first network ends in a softmax layer whose logits are divided by a temperature T greater than 1, so each class probability is exp(z\_i(X)/T) divided by the sum over l of exp(z\_l(X)/T). A high temperature makes the output distribution flatter, and as T grows the probabilities approach 1/N for N classes, so the softmax returns soft outputs instead of nearly one-hot ones.

The probability vectors produced by the first network replace the hard indicator labels of the training set, giving soft labels for the distilled network. The distilled network is trained on the same inputs with these soft targets at the same high temperature, and its training minimizes a cross-entropy between the soft labels and its own outputs.

Training can also mix hard labels with the soft labels, and the distilled network is then used with temperature set back to 1 at test time.

The cross-entropy splits into the entropy of the soft labels plus a Kullback-Leibler divergence, so the minimum is reached when the distilled model matches the first model. In practice the optimizer only approximates that minimum on a non-convex problem with finitely many samples, so the distilled model is not guaranteed to converge to the first model.

## Why a high temperature smooths the model

The sensitivity of the model is measured by its Jacobian, the matrix of derivatives of each output with respect to each input component. Differentiating the temperature softmax gives each Jacobian entry as \\\\( (1/T) \\\\, e^{z\_i/T} / g(X)^2 \\\\) times the sum over l of \\\\( (\\\\partial z\_i/\\\\partial X\_j - \\\\partial z\_l/\\\\partial X\_j) e^{z\_l/T} \\\\), where \\\\( g(X) = \\\\sum\_l e^{z\_l(X)/T} \\\\).

For fixed logits, raising T reduces the absolute value of every Jacobian component, because each component carries a factor 1/T and the logits are divided by T before exponentiation. A network trained at high temperature therefore has smaller sensitivity to small input changes during training.

At test time the temperature returns to 1, and the authors argue that the smaller sensitivity remains because it is encoded in the learned weights, which the temperature change does not modify. The authors state that this explanation is an intuition supported by experiments, and that a formal analysis is still needed.

The generalization argument uses the link between learnability and stability, where a stable learning rule that also minimizes the empirical risk is argued to generalize. The authors argue that, with a suitable temperature, training sets differing in one item produce close soft targets, and that the distillation objective minimizes empirical risk, so the distilled model generalizes well.

## Attack success and accuracy after distillation

On the MNIST DNN, the success rate of adversarial sample crafting was 95.89% without distillation and 0.45% with distillation at T = 100. On the CIFAR10 DNN, the same success rate was 87.89% without distillation and 5.11% with distillation at T = 100. The adversarial samples are crafted with the iterative saliency-map attack of Papernot et al.

described earlier, so the reductions are for that attack.

Accuracy is computed on all 10,000 samples of each test set, and the baselines without distillation are 99.51% for the MNIST model and 80.95% for the CIFAR10 model. Across the temperatures tested, distillation degrades MNIST accuracy by less than 1.28%, and CIFAR10 accuracy by at most 1.37%. Some CIFAR10 variations are positive, and the authors attribute part of that to better generalization, without quantifying it.

The temperature choice is a trade-off, and the MNIST model at T = 20 is given as an example that keeps accuracy at 99.05% while improving robustness.

## Adversarial gradients under distillation

The CIFAR10 test set's 10,000 samples are binned by mean adversarial gradient amplitude, and the bin frequencies are plotted for each temperature from no distillation to T = 100. Without distillation, 4763 samples have a mean adversarial gradient amplitude above 0.001, whereas with distillation at T = 100 only 172 do.

The mass of samples moves toward smaller amplitudes as the temperature increases, which the authors read as the trained model being smoother near the data. Smaller gradients mean an adversary must add more perturbation for the same original sample. The gradient reduction is reported as a factor of 1030 (as printed) for defensive distillation at high temperature.

The authors also note that overfitting increases adversarial gradients, so early stopping can help, and training for 50 epochs was enough for the distilled models to match the original accuracies.

## Robustness as the number of altered features

Robustness is the average minimum perturbation needed to change a sample's class, measured with a norm chosen for the input domain. For this evaluation the perturbation is measured as the number of altered input features, and it is approximated over all 10,000 test samples, with each of the 9 possible targets considered, rather than found by exhaustive search.

For the MNIST architecture, robustness rises from 1.55% without distillation to 13.79% with distillation at T = 20, which the paper reports as an increase of 790%. For the CIFAR10 architecture, robustness rises from 0.39% without distillation to 2.56% with distillation at T = 50, an increase of 556%. The introduction gives an increase of about 800% for one of the DNNs, while the body gives 790% for the same MNIST comparison.

The authors interpret 13.79% as large enough to change the true class or to be flagged by anomaly detection, and they cite earlier work that humans begin to misclassify adversarial samples beyond that level.

## Soft class labels versus probability vectors

The MNIST DNN trained with these soft labels has a misclassification rate of 86.00% on adversarial samples crafted with the same attack parameters, whereas the distilled MNIST model stays below 1%.

The authors attribute the gap to the relative information between classes that the probability vectors carry and the soft class labels do not. Label smoothing without distillation was tested by other work, which found that it partly resists the fast gradient sign method, but the authors argue that it does not resist the more powerful iterative method they use.

## Limitations

The experiments use only the MNIST and CIFAR10 DNNs, and the main attack is the one from Papernot et al.; defensive distillation is evaluated against that attack and not against the other attacks mentioned. Attacks based on L-BFGS, the fast gradient sign method and genetic algorithms are named as untested, and the authors expect benefits but do not show them.

The distance measure is the number of altered features, and L1 and L2 norms were not used.

The robustness values are approximations over the test set, not exhaustive worst cases. The defender must find a temperature that balances robustness and accuracy empirically, so the choice is not fixed by the method. The method is stated to rely on the probability distribution of a softmax with temperature, so it applies to DNNs and would need new work for other models.

The generalization result is argued, not proven, and the sensitivity explanation at test time is an intuition the authors leave to future formal analysis. Comparisons to traditional regularization were not made, because the authors argue that adversarial examples are not a standard overfitting problem.

## Paper info

- **Authors**: Nicolas Papernot, Patrick McDaniel, Xi Wu, Somesh Jha, Ananthram Swami
- **Venue**: arXiv · Preprint
- **First published**: 2015-11-14
- **Added**: 2026-11-12
- **Updated**: 2016-3-14
- **Version**: v2
- **arXiv**: 1511.04508
- **Category**: cs.CR · cs.LG · cs.NE · stat.ML
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1511.04508v2) · [PDF ↗](https://arxiv.org/pdf/1511.04508v2)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Nicolas Papernot, Patrick McDaniel, Xi Wu, Somesh Jha, Ananthram Swami (2015). Distillation as a Defense to Adversarial Perturbations against Deep Neural Networks. arXiv:1511.04508v2. https://arxiv.org/abs/1511.04508v2

**BibTeX**

```
@misc{papernot2015distillation,
  title = {{Distillation as a Defense to Adversarial Perturbations against Deep Neural Networks}},
  author = {Nicolas Papernot and Patrick McDaniel and Xi Wu and Somesh Jha and Ananthram Swami},
  year = {2015},
  eprint = {1511.04508},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1511.04508v2}
}
```

## Other paper commentary

- [Progressive Neural Networks](https://refivu.com/en/papers/312c9749-ed9b-42c3-9bf3-bb139310d4dd-progressive-neural-networks.md)
- [Cyclical Learning Rates for Training Neural Networks](https://refivu.com/en/papers/922235f3-8c7b-4983-9a6d-b6a3d0b4a72e-cyclical-learning-rates-for-training-neural-networks.md)
- [Deep Learning and Its Applications to Machine Health Monitoring: A Survey](https://refivu.com/en/papers/8b968c5c-f4ea-4c3b-9ca4-f3e2b3ad82db-deep-learning-and-its-applications-to-machine-health.md)
- [A systematic study of the class imbalance problem in convolutional neural networks](https://refivu.com/en/papers/68d2ae65-6b32-4762-8915-c1b74804b262-a-systematic-study-of-the-class-imbalance-problem.md)
- [DeepFM: A Factorization-Machine based Neural Network for CTR Prediction](https://refivu.com/en/papers/d46f0084-9d39-4160-9e16-7e698dbfde00-deepfm-a-factorization-machine-based-neural-network-for.md)
- [A Survey of the Recent Architectures of Deep Convolutional Neural Networks](https://refivu.com/en/papers/108c5acb-7c6f-4ccb-b4c9-7174cc472551-a-survey-of-the-recent-architectures-of-deep.md)
- [SuperGlue: Learning Feature Matching with Graph Neural Networks](https://refivu.com/en/papers/9343403c-486b-4202-af8a-3329d26b1dad-superglue-learning-feature-matching-with-graph-neural.md)
- [NTU RGB+D: A Large Scale Dataset for 3D Human Activity Analysis](https://refivu.com/en/papers/5edff39c-c403-4be6-ac6f-5fbcfa1ca3f7-ntu-rgb-d-a-large-scale-dataset-for.md)
- [Improved Baselines with Visual Instruction Tuning](https://refivu.com/en/papers/3cfdbdfa-775a-4f66-9c2e-f6fc6c4b4e96-improved-baselines-with-visual-instruction-tuning.md)
- [CCNet: Criss-Cross Attention for Semantic Segmentation](https://refivu.com/en/papers/0b5bae85-f19c-40ec-85a8-6d588ce0497b-ccnet-criss-cross-attention-for-semantic-segmentation.md)
- [Semantics derived automatically from language corpora contain human-like biases](https://refivu.com/en/papers/abf5bfd6-5402-457c-958c-81fe475605f3-semantics-derived-automatically-from-language-corpora.md)
- [Estimation and Inference of Heterogeneous Treatment Effects using Random Forests](https://refivu.com/en/papers/ee58e924-ae1d-4d66-9ec5-6c7d18a8692c-estimation-and-inference-of-heterogeneous-treatment-effects.md)

## Terms in this paper

- [Success rate](https://refivu.com/en/terms/0964df1dc5eb-success-rate)
- [classification accuracy](https://refivu.com/en/terms/3c67905d3166-classification-accuracy)
- [deep neural networks](https://refivu.com/en/terms/c5e1efb0ea81-deep-neural-networks)
- [Fast gradient sign method](https://refivu.com/en/terms/75749bc5431d-fast-gradient-sign-method)
- [classification](https://refivu.com/en/terms/df3aa00e3435-classification)
- [distillation](https://refivu.com/en/terms/6f4f52fc9c49-distillation)
- [label smoothing](https://refivu.com/en/terms/92ff7104c813-label-smoothing)
- [Robustness](https://refivu.com/en/terms/aae67093955e-robustness)
- [cross entropy](https://refivu.com/en/terms/f914876d14b2-cross-entropy)
- [generalization](https://refivu.com/en/terms/e48ace30330d-generalization)
- [defensive distillation](https://refivu.com/en/terms/b6e09e50ff14-defensive-distillation)
- [Jacobian](https://refivu.com/en/terms/ec880bf0bce7-jacobian)
- [softmax layer](https://refivu.com/en/terms/2ca3fbe341da-softmax-layer)
- [distillation temperature](https://refivu.com/en/terms/021b4ada2e6a-distillation-temperature)
- [stability](https://refivu.com/en/terms/44d6db576ab4-stability)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/c5136527-4bfb-4b86-9a2a-78184dd93989-distillation-as-a-defense-to-adversarial-perturbations)
