Search

Search papers and lessons

Intriguing properties of neural networks

Christian Szegedy, Wojciech Zaremba, Ilya Sutskever et al. · 2013

Szegedy et al. (2013) showed that deep networks can be flipped to a wrong answer by changes to an image too small for a person to notice, and that these adversarial examples transfer across models.

On this page

  • Colour = topic mix
  • Calculus
  • Discrete math
  • Linear algebra
  • Neural network basics
  • Architectures
  • Probability
  • ReadReady to readNot yet

TL;DR

Szegedy and colleagues asked two questions about deep image classifiers. First, do the individual units of a hidden layer carry the meaning of the layer, or does meaning live in the whole space of activations? They found that random directions in that space look just as meaningful as the units. Second, are the learned input-output maps smooth? They found they are not: by optimising a small change to an image, they could make a network misclassify it while a person sees no difference. They called these inputs adversarial examples, and found that many transfer to other networks trained with different settings or on different data.

Builds on: Convolutional Neural Network, Constrained Optimization, Lipschitz Continuity · Leads to: Adversarial Examples

Note: this is a research summary for education, not a guide to building or attacking real systems.

Why it mattered

Adversarial examples became one of the central problems in machine learning. Today the same question, whether a model's decision holds up under small input changes, is asked about image classifiers in safety-critical settings such as driving and medical imaging, and about language models that read adversarial text. Papers that propose attacks and defences routinely use the same basic setup this paper introduced: find the smallest change that flips a prediction, then test whether that change also fools other models. The paper also gave an early operator-norm argument for why depth can amplify instability, which later work refined into the robustness methods used today.

The problem

By 2013 deep networks achieved excellent results on visual and speech recognition. Earlier work had tried to understand what hidden units had learned by finding the input that most strongly activated one unit. That method assumes the units of a layer form a meaningful basis, so that a single coordinate is a meaningful feature. The paper questions that assumption.

It also asked how smooth the learned function is. Classical kernel methods are assumed to be smooth in the sense that a tiny change to an input changes the output only a little, and vision models are usually assumed to be smooth in the same way because a tiny change to a photo should not change what it shows. The paper tests that assumption directly, and finds it does not hold for deep networks in the way people had assumed.

How it works

The paper has two parts. Here is the pipeline for the second part, the adversarial search, in the order the paper runs it.

flowchart LR
  A["Correctly classified image x, label f(x)"] --> B["Choose a wrong target label l"]
  B --> C["Search for a small r with f(x + r) = l"]
  C --> D["Keep x + r inside the valid pixel range [0, 1]"]
  D --> E["Output: x + r looks the same but gets label l"]
  1. Input. A trained classifier ff and an image xx that it classifies correctly. Check: f(x)f(x) is the true label.
  2. Pick a target. Choose a wrong label l≠f(x)l \neq f(x). Check: if l=f(x)l = f(x), the problem has nothing to solve.
  3. State the goal. Find the smallest perturbation rr such that f(x+r)=lf(x + r) = l and x+rx + r still has valid pixel values. Check: "smallest" is measured by the Euclidean norm ∥r∥2\|r\|_2.
  4. Relax the constraint. Exact minimisation is hard, so the paper replaces the constraint with a penalty: minimise c ∥r∥+lossf(x+r,l)c\,\|r\| + \mathrm{loss}_f(x + r, l), and search for the smallest cc that makes the classifier output ll. Check: a larger cc forces rr to be smaller, at the cost of a larger loss.
  5. Use the approximation. The paper solves the penalty problem with box-constrained L-BFGS, a quasi-Newton optimiser that respects the valid pixel range. Check: the output is a candidate adversarial example, not a guaranteed minimum, because the network is not convex.

A tiny linear example shows the geometry, although the paper's method is for deep networks. Take a linear score s(x)=w⋅xs(x) = w \cdot x with w=(2,−1)w = (2, -1), and an input x=(0.3,0.1)x = (0.3, 0.1). The score is s=0.6−0.1=0.5s = 0.6 - 0.1 = 0.5, so the input is on the positive side. The smallest perturbation that reaches the boundary s=0s = 0 is r=−s∥w∥2w=−0.55(2,−1)=(−0.2,0.1)r = -\frac{s}{\|w\|^2} w = -\frac{0.5}{5}(2, -1) = (-0.2, 0.1). Check: w⋅(x+r)=0.5−0.4−0.1=0w \cdot (x + r) = 0.5 - 0.4 - 0.1 = 0, which lies exactly on the boundary. The length of rr is 0.05=0.2236\sqrt{0.05} = 0.2236.

The math

The classifier maps an image vector x∈Rmx \in \mathbb{R}^m to a label in {1,…,k}\{1, \dots, k\}. It has an associated continuous loss lossf(x,l)\mathrm{loss}_f(x, l). The paper defines the minimum-distortion function D(x,l)D(x, l) as the closest image to xx that the classifier labels ll, found by solving

min⁡r∥r∥2subject tof(x+r)=l,x+r∈[0,1]m.\min_r \|r\|_2 \quad \text{subject to} \quad f(x + r) = l, \quad x + r \in [0, 1]^m.

This is hard for a neural network, so the paper uses the penalised form, the minimum c>0c \gt 0 for which the solution rr of

min⁡r  c ∥r∥2+lossf(x+r,l)subject tox+r∈[0,1]m\min_r \; c\,\|r\|_2 + \mathrm{loss}_f(x + r, l) \quad \text{subject to} \quad x + r \in [0, 1]^m

satisfies f(x+r)=lf(x + r) = l. The paper notes that this would be exact for convex losses, which neural networks are not.

The stability bound

Let ϕk\phi_k be the map from layer k−1k-1 to layer kk, with ϕ(x)=ϕK(⋯ϕ1(x)⋯ )\phi(x) = \phi_K(\cdots \phi_1(x)\cdots). Call LkL_k the upper Lipschitz constant of layer kk, the smallest value with

∥ϕk(x)−ϕk(x+r)∥≤Lk∥r∥\|\phi_k(x) - \phi_k(x + r)\| \le L_k \|r\|

for all xx and rr. Composing the layers gives ∥ϕ(x)−ϕ(x+r)∥≤L∥r∥\|\phi(x) - \phi(x + r)\| \le L \|r\| with L=∏k=1KLkL = \prod_{k=1}^{K} L_k. The product is the step where depth matters: each layer multiplies the bound.

For a half-rectified layer ϕk(x)=max⁡(0,Wkx+bk)\phi_k(x) = \max(0, W_k x + b_k), the ReLU step does not expand distances, so Lk≤∥Wk∥L_k \le \|W_k\|, where ∥Wk∥\|W_k\| is the largest singular value of WkW_k (see Singular Value Decomposition (SVD)). A max-pooling layer is contractive too, with Lk≤1L_k \le 1, because its Jacobian projects onto a subset of the input coordinates. For a contrast-normalisation layer ϕk(x)=x/(ϵ+∥x∥2)γ\phi_k(x) = x / (\epsilon + \|x\|^2)^{\gamma} with γ\gamma between 0.5 and 1, the paper gives the bound ϵ−γ\epsilon^{-\gamma}.

For a convolutional layer the paper computes the operator norm with Parseval's formula: the norm is the supremum over frequencies ξ\xi of the norm of a matrix A(ξ)A(\xi) built from the 2-D Fourier transforms of the kernels. The paper uses this to bound each layer of an ImageNet network.

Units and directions

For a layer's activation vector ϕ(x)\phi(x) and a unit ii with basis vector eie_i, the earlier method looked at images x′=arg⁡max⁡x∈I⟨ϕ(x),ei⟩x' = \arg\max_{x \in \mathcal{I}} \langle \phi(x), e_i \rangle, where I\mathcal{I} is a held-out image set. The paper replaces eie_i with a random direction vv and finds images that are just as semantically consistent.

Results

The results are on three networks: a set of models on MNIST, a convolutional network trained on ImageNet ("AlexNet" in the paper), and an unsupervised network trained on YouTube frames ("QuocNet"). Here are the numbers the paper reports, copied from its tables and text.

Adversarial examples exist for every network studied. The paper says that for each sample it "always managed" to generate close, visually hard to distinguish adversarial examples for MNIST, QuocNet and AlexNet (Figure 5 and the linked examples). For AlexNet, the average distortion over 64 examples is 0.006508.

Table 1 (MNIST, single-model results). The softmax model FC10 with weight decay 10−410^{-4} has a training error of 6.7 percent, a test error of 7.4 percent, and an average minimum distortion of 0.062. The two-hidden-layer sigmoid network FC100-100-10 has a test error of 1.64 percent and a distortion of 0.058. The autoencoder-based AE400-10 has a test error of 1.9 percent and a distortion of 0.086. Distortion is the root-mean-square pixel difference on the [0,1][0, 1] scale, over n=784n = 784 pixels.

Table 2 (cross-model transfer). Adversarial examples made for one model are fed to the others. For example, examples made for FC10 with weight decay 10−410^{-4} cause errors on FC10 with weight decay 10−210^{-2} in 11.7 percent of cases and on the two-hidden-layer FC100-100-10 in 2 percent. Examples made for the high-regularisation FC10(11) model cause 48.1 percent errors on FC100-100-10. The paper also reports the error caused by Gaussian noise of the same size; for noise with standard deviation 0.1 those errors range from 0 to 18.3 percent across the models.

Table 4 (cross-training-set transfer). Two networks were trained on one half of the MNIST training set and one on the other half. Examples made for FC100-100-10 trained on the first half caused 5.9 percent errors on the network trained on the second half. When the same perturbation is amplified to standard deviation 0.1, the error on that network rises to 43 percent. The paper says the examples "remain hard" for a model trained on a disjoint training set, although their effectiveness decreases considerably.

Training with adversarial examples. On MNIST, a 100-100-10 network trained with weight decay and with a pool of adversarial examples mixed into training reached a test error below 1.2 percent. The paper reports 1.6 percent for weight decay alone and about 1.3 percent with carefully applied dropout. The paper says these are preliminary results on one network, and that the gain appeared only when adversarial examples were generated for each layer's outputs.

Layer bounds (Table 5). The upper Lipschitz bounds computed for the ImageNet network of Krizhevsky et al. are 2.75 for the first convolutional layer, 10 for the second, 7 for the third, 7.5 for the fourth, 11 for the fifth, 3.12 for the first fully connected layer, and 4 for each of the next two. The paper says instability "can appear as soon as in the first convolutional layer."

Limits. The paper states that the Lipschitz numbers are upper bounds: large bounds do not automatically mean adversarial examples exist, while small bounds guarantee none. It does not explain why the examples transfer across models. It reports no results for convolutional models on MNIST, and its ImageNet analysis gives layer-wise upper bounds only, without a measured adversarial error rate for that network. Its own discussion says the authors do not have a deep understanding of how often adversarial negatives occur in practice.

Reading guide

  • Section 1 (Introduction) states the two properties. Read it with Backpropagation in mind: the paper says the computation found by backpropagation can be hard to interpret.
  • Section 2 (Framework) lists the networks and datasets. The notation ϕ(x)\phi(x) for an activation vector comes from Activation Function layers.
  • Section 3 (Units) asks whether single units carry meaning. It relies on Vector Norm and on the idea that a direction in activation space is a linear combination of units.
  • Section 4.1 (Formal description) is the optimisation problem. Read it with Constrained Optimization and Loss Function; the penalty step is the standard way to remove a hard constraint.
  • Section 4.2 (Experiments) reports the tables. Read the tables against Softmax, Cross-Entropy Loss, Dropout and Autoencoder.
  • Section 4.3 (Spectral analysis) bounds the instability of each layer. It needs Lipschitz Continuity, Singular Value Decomposition (SVD), Max Pooling and Rectified Linear Unit (ReLU).
  • Section 5 (Discussion) raises the tension between high generalisation and adversarial examples, and leaves it open.

Check yourself

QuestionRecall: what did the paper mean by an adversarial example?Show answer

An input made by adding a small, carefully chosen perturbation to a correctly classified image, so that the trained network assigns it a different label while a person sees no meaningful change.

QuestionComputation: for the linear score s(x)=w⋅xs(x) = w \cdot x with w=(2,−1)w = (2, -1) and x=(0.3,0.1)x = (0.3, 0.1), the minimum-norm change that reaches the boundary is r=−s∥w∥2wr = -\frac{s}{\|w\|^2} w. What is ∥r∥\|r\|?Show answer

s=0.5s = 0.5, ∥w∥2=5\|w\|^2 = 5, so r=−0.1(2,−1)=(−0.2,0.1)r = -0.1(2, -1) = (-0.2, 0.1). Its length is 0.04+0.01=0.05=0.2236\sqrt{0.04 + 0.01} = \sqrt{0.05} = 0.2236.

QuestionWhy: why does the product of layer bounds L=∏kLkL = \prod_k L_k grow with depth, and what does that imply?Show answer

Each layer multiplies the worst-case stretch of the input difference by its own Lipschitz constant. With KK layers, the stretch is the product of KK numbers. If most of them are above 1, the bound grows quickly with depth, so a deep network can magnify a small perturbation at its output. The paper stresses these are upper bounds, so this shows a possibility, not a guarantee.

QuestionApplied: a team trains a new classifier on a different subset of the same data and finds that adversarial examples made for their first model still fool the second model. What does the paper suggest about the cause?Show answer

The paper's results show that transfer happens across training subsets as well as across hyperparameters, so the cause is not just overfitting to one training set or one random run. The paper treats this as evidence that the networks share blind spots tied to the data distribution, but it does not explain the mechanism. The team should not conclude that the second model is safe.

Sources

Read the full paper

Christian Szegedy, Wojciech Zaremba, Ilya Sutskever et al., 2013. arXiv:1312.6199