Foundations to Frontier
Tests
E. Deep Learning › E8 CNN Architectures (one page each)

ZFNet

ZFNet (Zeiler and Fergus, 2014) is AlexNet with a smaller, finer first layer (7 × 7 kernels at stride 2 instead of 11 × 11 at stride 4), a change found by looking inside the network. Its lasting contribution is the tools it used: a deconvolutional network that projects any feature back to pixel space, and occlusion experiments that show which parts of an image a prediction depends on. This page covers the architecture change, the deconvnet (unpooling with switches, rectification, transposed filters) and what the visualisations revealed. In the exercises you implement unpooling with switches, then run the occlusion test on a small CNN: the most damaging 3 × 3 patch lay on the digit in 99–100% of images (70% by chance), and covering the digit cut confidence about 30 times more than covering background.

Level 0: Foundation

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

Looking inside the black box

After AlexNet, nobody quite knew what its neurons had learned. Matthew Zeiler and Rob Fergus built tools to find out. For any neuron they could draw the parts of an image that excited it, and they could cover parts of an image to see which parts the answer depended on. The pictures showed that AlexNet’s first layer had dead filters and blocky artefacts. Shrinking its first-layer kernels and stride fixed that and improved accuracy: the improved network is ZFNet.

Architecture explorer: shapes, parameters and compute
stageoutput C × H × Wparametersmultiply–adds
conv196 × 55 × 55
14.2 k
170.76 M
conv2256 × 13 × 13
614.7 k
415.33 M
conv3-5256 × 6 × 6
3.10 M
523.32 M
fc6-81000 × 1 × 1
58.63 M
58.62 M
Total: 62,357,608 parameters (62.36 M), 1.17 G multiply–adds per image at 224 × 224.
AlexNet61.10 M parameters714.19 M MACs
ZFNet62.36 M parameters1.17 G MACs
Bars show each row's share of the total. Convolutions dominate compute because they run at every position; fully connected layers dominate parameters in older designs (AlexNet, VGG). Changing the input size changes the compute of every convolution but not its parameters. Parameter counts include biases and BatchNorm scale and shift and match torchvision's implementations.
Why engineers care

Before trusting a vision network on a robot or satellite, engineers need evidence that it looks at the object and not at the background. Occlusion tests give that evidence without access to the network’s internals.

📝 Quick check (Level 0)
0/3 answered
  1. 1. ZFNet changed AlexNet's…
  2. 2. Occlusion tests cover parts of an image to see…
  3. 3. The deconvnet shows…

Level 1: Beginner

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

By hand

  • First layer: AlexNet uses 11 × 11 kernels at stride 4 (224 → 55). ZFNet uses 7 × 7 at stride 2 with padding 1, giving (224 + 2 − 7)/2 + 1 = 110.
  • Next stages: pooling 3/2 gives 55; conv2 (5 × 5, stride 2) gives 26; pooling gives 13; three 3 × 3 convolutions keep 13; a final pooling gives 6. Then come fully connected layers of 4,096, 4,096 and 1,000 units.
  • Parameters: about 62.4 million, almost all in the fully connected layers. Compute is about 1.17 G multiply–adds, against 0.71 G for AlexNet, because the first layers run at higher resolution.
  • Unpooling with switches: pooling [[1, 5], [3, 4]] gives 5, with switch (0, 1). Unpooling puts 5 back at (0, 1) and zeros elsewhere.
  • Occlusion positions: a 3 × 3 patch slid over a 10 × 10 image has 8 × 8 = 64 positions.
📝 Quick check (Level 1)
0/3 answered
  1. 1. ZFNet's conv1 output side for 224 × 224:
  2. 2. A switch records…
  3. 3. Occluder positions for 3 × 3 on 10 × 10:

Level 2: Intermediate

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

Visualising in code

Exercise 1.

  • Max pooling with switches returned [[5, 8], [9, 3]] for the 4 × 4 example.
  • Unpooling placed each maximum back at its source and zeros elsewhere.
  • ZFNet’s first layer produced 110 × 110 maps against AlexNet’s 55 × 55.

Practice.

  • The deconvnet visualises a feature by setting all other activations in its layer to zero and passing the map back through three steps:
    • unpooling with the recorded switches;
    • ReLU;
    • convolution with the transposed (flipped) filters.
  • Today the same idea is usually done with gradients:
    • guided backpropagation (Springenberg et al., 2015) is a close relative;
    • Grad-CAM (Selvaraju et al., 2017) weights the last convolutional maps by their average gradient.
  • Occlusion needs only forward passes:
    • slide a grey or mean-valued patch;
    • record the drop in the true-class probability;
    • plot it as a heat map.
heat = np.zeros((m, m))
for a in range(m):
    for b in range(m):
        x = img.clone(); x[:, a*s:a*s+k, b*s:b*s+k] = mean
        heat[a, b] = p_true(img) - p_true(x)
🐍 Exercise 1: unpooling with switches
Max-pool with switches, unpool, and compare ZFNet's and AlexNet's first layers.
📝 Quick check (Level 2)
0/3 answered
  1. 1. The deconvnet passes a map back through…
  2. 2. Occlusion maps need…
  3. 3. Grad-CAM weights the last conv maps by…

Level 3: Advanced

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

Theory

What the visualisations showed.

  • Hierarchy of features:
    • layers 1 and 2 respond to edges, colours and corners;
    • layer 3 to textures and meshes;
    • layers 4 and 5 to object parts and whole objects, such as dog faces and wheels.
  • Training dynamics: lower layers converged within a few epochs; upper layers developed only after 40 to 50 epochs.
  • Invariance: small translations and scalings changed layer-1 features a lot but the top layers little; rotation invariance was weak except for rotationally symmetric objects.

Why the first layer changed. With 11 × 11 kernels at stride 4, AlexNet’s first-layer filters mixed very high and very low frequencies with few mid-frequency filters, and some filters were dead. Its second-layer features also showed aliasing from the large stride. A 7 × 7 kernel at stride 2 kept more information and gave cleaner features and better accuracy.

What occlusion measures. The drop in the true-class probability when a region is masked estimates how much the prediction depends on that region. The method has two limits:

  • it measures the effect of a particular masking value, so a mask that looks unnatural can itself change the prediction;
  • it cannot detect redundant evidence, because masking one of two sufficient cues leaves the prediction unchanged.
📝 Quick check (Level 3)
0/3 answered
  1. 1. Layers 4–5 respond to…
  2. 2. Upper layers converged after about…
  3. 3. Occlusion misses…

Level 4: Expert

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

Does the network look at the digit?

History.

  • M. Zeiler, G. Taylor, R. Fergus (2011) introduced deconvolutional networks.
  • M. Zeiler and R. Fergus (2014) used them to visualise and improve AlexNet. Their ensemble reached 14.8% top-5 error on ImageNet 2012, and Clarifai, Zeiler’s company, won the ILSVRC 2013 classification task with 11.7%.
  • They also showed ImageNet features transfer: retraining only the classifier on Caltech-101 and Caltech-256 beat the previous best results.

Exercise 2. A small convolutional network (as in E8-1) is trained on 300 shifted digits. For each of 300 test digits classified confidently (true-class probability above 0.5), a 3 × 3 patch set to 0 is slid over every position, and the drop in the true-class probability is recorded.

seed confidently classified most damaging patch on the digit chance mean drop, patch on digit off digit
0 0.573 1.000 0.709 0.232 0.0065
1 0.590 0.994 0.701 0.298 0.0094
  • The network depends on the digit, not the background. The single most damaging patch overlapped the digit in nearly every image, where chance would give about 70%. The 7 × 5 box covers much of the 10 × 10 canvas, so chance is high, and the hit rate is the stronger test.
  • Covering the digit cut confidence about 30 times more than covering background. Seeds 2 to 4 gave hit rates of 0.99 to 1.00.
  • This test cannot tell which strokes matter, or whether the network would still be right using a different part of the digit. Those questions need finer occluders or gradient-based maps.
🐍 Exercise 2 (research): does the network look at the digit?
Train a small CNN, slide an occluder over test digits, and measure whether the confidence drop is concentrated on the digit.

Visualisation in AI, robotics and aerospace

  • Certification: occlusion and saliency maps are used to argue that perception networks for driving and aviation attend to relevant features, though they are evidence, not proof.
  • Debugging datasets: occlusion often reveals shortcuts, such as a network recognising a class by a watermark or by the background sky, before deployment.
  • Remote sensing: saliency maps check that land-cover classifiers use the land, not clouds or image borders.

References

  1. M. D. Zeiler, R. Fergus (2014). “Visualizing and understanding convolutional networks.” Proc. ECCV.
  2. M. D. Zeiler, G. W. Taylor, R. Fergus (2011). “Adaptive deconvolutional networks for mid and high level feature learning.” Proc. ICCV.
  3. J. T. Springenberg, A. Dosovitskiy, T. Brox, M. Riedmiller (2015). “Striving for simplicity: the all convolutional net.” ICLR workshop.
  4. R. R. Selvaraju et al. (2017). “Grad-CAM: visual explanations from deep networks via gradient-based localization.” Proc. ICCV.