DeepLLM Quiz
Neural Network Architectures

Saliency maps and DeepDream: what a convolutional network pays attention to

10 questions on class saliency maps from the last convolutional layer, channel weights, heat maps and the gradient-based image amplification known as DeepDream.

  • 10 questions
  • Stopwatch
  • Instant feedback

Shown publicly with your score. Don’t use your full real name.

Sample questions

Play now ↑

Answers stay hidden. Start the quiz to play them.

  1. Sample 1

    The final convolutional layer of a network has feature maps of size 14 by 14, and the input image is much larger. What size is the saliency map computed from that layer?

    • Exactly the size of the input image
    • A single number
    • 14 by 14, which is then superimposed on the image as a heat map

How it works

  • One question per screen. An answer is final once sent.
  • You see right away whether you were right, with a short explanation.
  • The stopwatch runs: on equal scores, the faster player ranks first.
  • Only your best attempt counts, so replaying is never risky.

About this quiz

A radiologist asks an image classifier why it flagged a scan, and the model answers with a probability. That is no help at all. What the radiologist wants is a picture: a heat map laid over the scan, showing which regions pushed the decision. Saliency maps are a family of techniques that produce exactly this, using the gradients that the network already knows how to compute. A related trick turns the same machinery towards art: instead of explaining a decision, it exaggerates whatever the network sees until clouds become dogs and walls sprout eyes.

This quiz covers both. For saliency, you will see why the last convolutional layer is the best place to look: it still has a spatial layout, which the fully connected layers destroy, and it carries the highest-level meaning. You will follow the recipe in words: take a class score, ask how it responds to each unit of that layer, average over positions to get one importance weight per channel, and combine the channels' maps with those weights into a single heat map. You will also see what size the resulting map has, and what that implies for how finely it can point.

For the synthetic images, you will see what the procedure amplifies and how, in terms of the familiar backpropagation machinery, with the response of a chosen layer used as the quantity to be increased. You will see why smoothing and clipping are added, what repeating the procedure does, and what happens if the starting image is random noise. The questions finish with a thought about what the possibility of such images says about networks trained only to discriminate between classes.

Two cautions come with all such pictures. A saliency map is evidence about what influenced a score, and not proof of what the model understands, so it should be examined with scepticism. And the pictures produced by amplification are, first of all, a window into what units respond to, whatever their value as art. Both techniques also illustrate a powerful idea: the machinery built for training can be pointed at a different target. During training, gradients with respect to the weights adjust the model. Here, gradients with respect to the input, or with respect to an intermediate layer, answer questions about the model or reshape the image. The same backpropagation code that learns a classifier can therefore explain it and, with a small change, can be turned into an image generator. The next quiz in this series shows a darker use of the same gradients.

The quiz suits learners interested in interpretability and in how gradients can be used beyond training, and practitioners who have used heat maps without knowing how they are made. It needs no mathematics. There are 10 questions, each with an explanation, and it takes about four minutes.

Questions and answers

›How long does the quiz take?

About 3 to 4 minutes for 10 questions, at roughly 20 seconds each. Each answer comes with an explanation of the reasoning.

›Do I need to know how backpropagation works?

It helps to know that backpropagation gives the derivative of an output with respect to earlier values in the network. The quiz on how backpropagation works covers it. The questions here describe each step in words, so a general idea is enough.

›What is a saliency map?

It is an image-sized or feature-map-sized array that indicates which regions of an input were most significant for a particular output, such as a class label. It is usually displayed as a heat map laid over the original image. It helps a person see which parts of a picture the network relied on to reach its decision.

›Why use the final convolutional layer?

Because it strikes a balance. It still retains spatial localisation, unlike the fully connected layers that follow it, in which the position information is lost. And it has the highest level of semantic representation among the layers that are laid out spatially. Earlier layers are located but not meaningful, and later ones are meaningful but not located.

›How is the heat map computed?

For a chosen class, compute how the class score before the softmax changes with each unit of the final convolutional layer, and average these derivatives over the positions of each channel. These averages act as weights for the channels. The heat map is the weighted sum of the channel maps, and it has the same dimensions as that layer.

›What is DeepDream?

It is a technique for generating a synthetic image with exaggerated characteristics. A chosen layer of a trained network is looked at, to see which of its units respond strongly to an image, and the image is changed so as to amplify those responses. If a unit sees a cat-like pattern in a cloud, the cloud is made more cat-like.

›How is the image changed?

The image is fed forward to the chosen layer. The backpropagation error variables for that layer are set equal to its pre-activations, and backpropagation is run to the input to get a gradient over the pixels. The image is then moved a small step along that gradient. Smoothing and clipping are applied for a smooth result, and the whole procedure can be repeated.

›What is DeepDream used for?

It gives some insight into what a network has learned, since it makes visible what units respond to. In practice it has mainly been used to produce unusual and decorative images. It also shows that networks trained to tell classes apart contain at least some of the information that would be needed to generate pictures of those classes.

More quizzes