# Explaining and Harnessing Adversarial Examples

Linear models explain why adversarial examples transfer across networks

Ian J. Goodfellow, Jonathon Shlens, Christian Szegedy · arXiv · 2014-12-20

- **Problem** Earlier explanations of adversarial examples blamed nonlinearity and overfitting. Those ideas struggle to explain why different models make the same mistakes on one input.
- **Method** The authors blame linearity instead. They perturb each input by a tiny amount in the sign of the gradient, which is a fast one-step attack.
- **Results** Adversarial training lowered maxout test error on MNIST from 0.94% to 0.84%.

## Why the earlier explanations fell short

Szegedy et al. showed that strong neural networks can misclassify inputs that differ only slightly from correctly classified data. The surprising part was agreement: different architectures trained on different subsets of the data often made the same mistake on one input. That pointed at blind spots in the training process itself, not at one unlucky model.

The earlier explanations blamed extreme nonlinearity of deep networks, perhaps combined with too little model averaging and regularization. Those ideas struggle with the shared errors, because it is hard to see why many nonlinear models would all label an out-of-distribution point the same way. Adversarial training had been tried before, but its examples came from expensive L-BFGS optimization, which made it hard to test widely.

So the question is whether one simple property of the models can explain the errors and also give a cheap way to produce them.

## A linear account and a one-step attack

The key idea is that many tiny changes, each below the precision of an input feature, can add up to one large change in a high-dimensional linear model. The perturbed input is \\(\\tilde{x}=x+\\eta\\), and the perturbation is allowed as long as \\(\\\|\\eta\\\|\_\\infty\<\\epsilon\\). For a weight vector \\(w\\), the activation becomes \\(w^\\top\\tilde{x}=w^\\top x+w^\\top\\eta\\), so the perturbation adds \\(w^\\top\\eta\\) to it.

Choosing \\(\\eta=\\mathrm{sign}(w)\\) maximizes that added term under the max-norm bound. If \\(w\\) has \\(n\\) dimensions and its elements average magnitude \\(m\\), the activation grows by \\(\\epsilon m n\\). The bound on \\(\\eta\\) doesn't grow with \\(n\\), but the effect on the activation does, so high-dimensional inputs are the vulnerable case. This also explains why softmax regression can be attacked, not only deep networks.

The authors then ask whether neural networks are linear enough to suffer the same way. LSTMs, ReLUs and maxout units were designed to act linearly so they are easier to optimize, and sigmoid networks are tuned to stay in their linear regime. So cheap, analytic perturbations of a linear model should also damage neural networks.

Linearizing the cost around \\(\\theta\\) gives the perturbation \\(\\eta=\\epsilon\\,\\mathrm{sign}(\\nabla\_x J(\\theta,x,y))\\), which is the fast gradient sign method. The gradient is computed efficiently with backpropagation, which keeps the attack cheap. On GoogLeNet with ImageNet, an \\(\\epsilon\\) of .007 changes the class the network assigns to an image.

## Fast perturbations on trained classifiers

On MNIST with \\(\\epsilon=.25\\), the shallow softmax classifier had 99.9% error on these perturbed inputs. Its average confidence was 79.3%, so its wrong labels weren't tentative guesses. A maxout network without adversarial training misclassified 89.4% of them, with average confidence 97.6%.

On a preprocessed CIFAR-10 test set, a convolutional maxout network with \\(\\epsilon=.1\\) had 87.15% error. It put an average probability of 96.6% on the incorrect labels. A small rotation toward the gradient also produced misclassified examples, so the gradient step isn't the only cheap route.

Logistic regression is the clean case, because for it the fast gradient sign method is exact rather than an approximation. On MNIST 3 versus 7, the model had 1.6% error on the clean examples and 99% error with \\(\\epsilon=.25\\). The optimal perturbation pattern doesn't look like a 3 or a 7 to a human eye, which is what makes the attack hard to spot.

## Linear models: adversarial training versus L1 weight decay

For logistic regression, the adversarial objective reduces to a closed form that looks like an L1 penalty. The objective becomes \\\[ \\mathbb{E}\_{x,y\\sim p\_{\\text{data}}}\\,\\zeta\\big(y(\\epsilon\\\|w\\\|\_1-w^\\top x-b)\\big) \\\] Here \\(\\zeta\\) is the softplus function, and the \\(\\\|w\\\|\_1\\) term appears because the gradient sign is \\(-\\mathrm{sign}(w)\\), so \\(w^\\top\\mathrm{sign}(w)=\\\|w\\\|\_1\\).

This resembles L1 regularization, but the penalty is subtracted from the model's activation rather than added to the training cost. So the penalty can start to disappear once the model becomes confident enough that \\(\\zeta\\) saturates. That isn't guaranteed, and in the underfitting regime adversarial training simply makes underfitting worse.

For multiclass softmax regression, L1 weight decay treats each output as perturbable on its own, which overstates the possible damage. So its coefficient has to be smaller than the \\(\\epsilon\\) tied to feature precision. On the first layer of a maxout network, a coefficient of .0025 was already too large, leaving over 5% training error.

## Adversarial training of a maxout network

The fix is to train on a mix of clean and perturbed inputs, with the perturbations regenerated from the current model at each step. The objective is \\\[ \\tilde J(\\theta,x,y)=\\alpha J(\\theta,x,y)+(1-\\alpha)J\\big(\\theta,x+\\epsilon\\,\\mathrm{sign}(\\nabla\_x J(\\theta,x,y))\\big) \\\] with \\(\\alpha=0.5\\) in all experiments. The authors didn't tune \\(\\alpha\\), because 0.5 worked well enough.

Adversarial error on the training set wasn't reaching zero, so the maxout network grew from 240 to 1600 units per layer. The larger model without adversarial training overfit slightly and had 1.14% test error. Validation error flattened while the adversarial validation error kept moving, so early stopping used the adversarial validation error, and the final model was retrained on all 60,000 examples.

With dropout in the network, test error went from 0.94% without adversarial training to 0.84% with it. Across five seeds, four runs scored 0.77% and one scored 0.83%, averaging 0.782%. The authors call this statistically indistinguishable from fine-tuned DBMs with dropout at 0.79%.

On fast-gradient-sign examples, error fell from 89.4% to 17.9% after adversarial training. Examples made on the original model fooled the adversarially trained model 19.6% of the time, and examples from the new model fooled the original 40.9% of the time. The adversarially trained weights also look more localized and interpretable.

## Noise controls and hidden-layer perturbation

Random noise of the same size didn't give the same benefit. Maxout networks trained with random \\(\\pm\\epsilon\\) per-pixel noise and with uniform noise had 86.2% and 90.4% error on fast-gradient-sign examples. Zero-mean noise rarely lines up with the gradient, so it often changes little. Adversarial training instead works like hard example mining among noisy inputs, keeping the points that most resist classification.

Szegedy et al. found that perturbing hidden layers regularized best on a sigmoid network. With unbounded activations, the network responds by growing its hidden activations, so perturbing the input is usually better. Rotational perturbations of hidden layers gave a weaker effect than additive perturbation of the input layer. The authors expect underfitting when the final hidden layer is perturbed, because the last linear-sigmoid or linear-softmax layer isn't a universal approximator, and their best hidden-layer runs never perturbed that layer.

## Low-capacity RBF networks

A shallow RBF network with no hidden layer had 55.4% error on fast-gradient-sign MNIST examples with \\(\\epsilon=.25\\). Its confidence on those mistakes was 1.2%, while its average confidence on clean test examples was 60.6%. So the model is often wrong on these inputs but doesn't commit to its wrong answers.

This is a precision-recall trade-off: linear units respond to every input in a direction and risk false confidence, while RBF units respond only near a point and give up recall. RBF units aren't invariant to significant transformations, so they generalize poorly. Quadratic models with enough inhibition to resist perturbation gave high training error when trained with SGD.

## Why adversarial examples transfer across models

Under the linear view, adversarial examples fill contiguous stretches of the one-dimensional line that the attack defines, not isolated pockets. That makes it likely that an example fooling one classifier also fools another. The hypothesis is that current networks resemble one reference linear classifier learned from the same training set.

To test this, they built examples on a deep maxout network and classified them with a shallow softmax network and a shallow RBF network. On maxout mistakes, the RBF network predicted the maxout class 16.0% of the time, and the softmax classifier got the maxout class right 54.6% of the time. The authors say those rates are largely driven by each model's own error rate.

Excluding cases where both models err, softmax predicted the maxout class 84.6% of the time, compared with 54.3% for the RBF network. The RBF network predicted the softmax class 53.6% of the time, so it has a linear component of its own. The authors conclude that the linear hypothesis explains a substantial share of cross-model mistakes, but not all of them.

## Generative training and ensembles

The MP-DBM has a differentiable inference procedure and reaches 0.88% error on MNIST, so it is a fair test of generative training. With \\(\\epsilon\\) of 0.25, its error rate on adversarial examples from the MNIST test set was 97.5%. Being generative alone doesn't give resistance.

To test averaging, they trained an ensemble of twelve maxout networks, each with a different seed. Examples designed for the whole ensemble gave 91.1% error at \\(\\epsilon=.25\\), and examples designed for one member gave 87.9%. Ensembling provides only limited resistance to adversarial perturbation.

## Limitations

All adversarial training results in the body are on MNIST. The CIFAR-10 result only shows that the one-step attack fools a trained model, not that adversarial training helps there.

The adversarially trained model stays highly confident when it is wrong, averaging 81.4% on its mistakes. The 0.94% to 0.84% comparison is for a maxout network that also uses dropout, so it doesn't cover models without dropout.

L1 weight decay needed a coefficient so small that it gave no regularization benefit. The authors leave open whether better optimization can train more nonlinear models and so escape the tension between easy training and robustness.

## Paper info

- **Authors**: Ian J. Goodfellow, Jonathon Shlens, Christian Szegedy
- **Venue**: arXiv · Preprint
- **First published**: 2014-12-20
- **Added**: 2026-11-11
- **Updated**: 2015-3-20
- **Version**: v3
- **arXiv**: 1412.6572
- **Category**: stat.ML · cs.LG
- **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/1412.6572v3) · [PDF ↗](https://arxiv.org/pdf/1412.6572v3)

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

Ian J. Goodfellow, Jonathon Shlens, Christian Szegedy (2014). Explaining and Harnessing Adversarial Examples. arXiv:1412.6572v3. https://arxiv.org/abs/1412.6572v3

**BibTeX**

```
@misc{goodfellow2014explaining,
  title = {{Explaining and Harnessing Adversarial Examples}},
  author = {Ian J. Goodfellow and Jonathon Shlens and Christian Szegedy},
  year = {2014},
  eprint = {1412.6572},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1412.6572v3}
}
```

## Other paper commentary

- [Large Scale GAN Training for High Fidelity Natural Image Synthesis](https://refivu.com/en/papers/93f6ad29-8cca-4630-9a3b-d12f9ad91854-large-scale-gan-training-for-high-fidelity-natural.md)
- [DU-GAN: Generative Adversarial Networks with Dual-Domain U-Net Based Discriminators for Low-Dose CT Denoising](https://refivu.com/en/papers/46030b78-75d0-4156-80ef-e92602d09b95-du-gan-generative-adversarial-networks-with-dual-domain.md)
- [Generative Modeling by Estimating Gradients of the Data Distribution](https://refivu.com/en/papers/f3ef856d-6161-4eaa-b2c9-6a0c3f1ff432-generative-modeling-by-estimating-gradients-of-the-data.md)
- [Improved Techniques for Training GANs](https://refivu.com/en/papers/fa2b409d-90c8-47af-916c-aa43ebfdf357-improved-techniques-for-training-gans.md)
- [Variational Inference with Normalizing Flows](https://refivu.com/en/papers/681d4ceb-2dde-4627-a4ad-6ee307d4d2ec-variational-inference-with-normalizing-flows.md)
- [Generative Adversarial Imitation Learning](https://refivu.com/en/papers/4c0dc7dc-4282-4fe9-8bb5-0b267ba684d1-generative-adversarial-imitation-learning.md)
- [Deep Learning in Neural Networks: An Overview](https://refivu.com/en/papers/fc7c2f1e-9030-4a55-892b-82a89ff398b7-deep-learning-in-neural-networks-an-overview.md)
- [Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation](https://refivu.com/en/papers/c3292ceb-d0f0-4799-82a9-423146b8a1ba-encoder-decoder-with-atrous-separable-convolution-for.md)
- [SegNet: A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation](https://refivu.com/en/papers/6ef91be9-1378-47a3-b7a6-b70c7cdb6ba6-segnet-a-deep-convolutional-encoder-decoder-architecture-for.md)
- [Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation](https://refivu.com/en/papers/a52e355d-5c49-4353-8d39-5013e656760c-learning-phrase-representations-using-rnn-encoder-decoder.md)
- [A Unified Approach to Interpreting Model Predictions](https://refivu.com/en/papers/f0be20fa-d9a3-4802-80ea-831a1c564ae5-a-unified-approach-to-interpreting-model-predictions.md)
- [MobileNetV2: Inverted Residuals and Linear Bottlenecks](https://refivu.com/en/papers/db077330-ba7d-43fd-b0bb-608efe9dd258-mobilenetv2-inverted-residuals-and-linear-bottlenecks.md)

## Terms in this paper

- [ImageNet](https://refivu.com/en/terms/5eadad128667-imagenet)
- [CIFAR-10](https://refivu.com/en/terms/19035a518d0a-cifar-10)
- [MNIST](https://refivu.com/en/terms/28b9bb66d1c6-mnist)
- [GoogLeNet](https://refivu.com/en/terms/50b933468e4c-googlenet)
- [neural networks](https://refivu.com/en/terms/88c79be50288-neural-networks)
- [adversarial examples](https://refivu.com/en/terms/277fed423ea7-adversarial-examples)
- [Adversarial training](https://refivu.com/en/terms/79bc85d56747-adversarial-training)
- [ensemble](https://refivu.com/en/terms/0dba40e835aa-ensemble)
- [Fast gradient sign method](https://refivu.com/en/terms/75749bc5431d-fast-gradient-sign-method)
- [Box-constrained L-BFGS](https://refivu.com/en/terms/53047dc19f66-box-constrained-l-bfgs)
- [maxout network](https://refivu.com/en/terms/689d5c9f21f4-maxout-network)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/37bc09da-a299-4ed8-8384-7f87f7409fd4-explaining-and-harnessing-adversarial-examples)
