liveBook · Manning

Chapter 10: Interpreting what ConvNets learn

What you will learn in chapter 10 of Deep Learning with Python, Third Edition

The chapter introduces why interpreting ConvNet decisions matters and why ConvNets are particularly amenable to visualization.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces why interpreting ConvNet decisions matters and why ConvNets are particularly amenable to visualization.

Key terms: interpretability, classifier, black boxes, representations, visual concepts, visualization

10.1 Visualizing intermediate activations

The section shows how to display a ConvNet’s intermediate activations and use them to see representations become more abstract with depth.

Key terms: intermediate activations, feature maps, channels, Keras model, multi-output model, layer activations, edge detectors, sparsity, abstract, information distillation pipeline

10.2 Visualizing ConvNet filters

This section explains how to visualize what a ConvNet filter responds to by optimizing an input image, and identifies the model calls and gradient handling needed for that process.

Key terms: filters, gradient ascent in input space, activation, Xception, Functional API, feature extractor, model-specific image preprocessing, model.predict(x), model(x), differentiable

10.2.1 Gradient ascent in TensorFlow

The subsection identifies how TensorFlow obtains the gradients needed for filter visualization and notes a way to speed up the computation.

Key terms: GradientTape, loss, gradients, @tf.function

10.2.2 Gradient ascent in PyTorch

This subsection shows how to obtain input-image gradients in PyTorch and why they do not need to be reset in this example.

Key terms: loss.backward(), image.grad, input image, gradients

10.2.3 Gradient ascent in JAX

10.2.4 The filter visualization loop

This section turns filter-activation patterns into displayable images and uses them to show how ConvNet filters become more complex in higher layers.

Key terms: filter index, target layer, activation, post-process, filter banks, directional edges, colors, textures

10.3 Visualizing heatmaps of class activation

The section introduces class activation heatmaps, explains the intuition behind Grad-CAM, and sets up an Xception example for locating image regions relevant to a prediction.

Key terms: class activation map (CAM), class activation heatmap, output class, Grad-CAM, output feature map, channel, gradient, Xception, classification head, KerasHub ImageClassifier

10.3.1 Getting the gradient of the top class: TensorFlow version

10.3.2 Getting the gradient of the top class: PyTorch version

10.3.3 Getting the gradient of the top class: JAX version

This subsection explains how the JAX version uses the top predicted class’s activation as a loss for gradient computation.

Key terms: JAX, loss computation function, final layer’s output, top predicted class, activation channel, gradient

10.3.4 Displaying the class activation heatmap

This subsection turns class-activation information into a viewable heatmap and uses it to interpret an African elephant prediction.

Key terms: gradient tensor, pooling, importance weighting, heatmap of class activation, normalize, superimposes, class activation heatmap, strongly activated, African elephant, Indian elephants

10.4 Visualizing the latent space of a ConvNet

The section explains how a ConvNet’s layer activations can be projected into two dimensions to inspect its latent space, and why that view is necessarily imperfect.

Key terms: latent space, manifold, semantically similar inputs, activations, latent manifold, classification layer, projection, intrinsic dimensionality

10.5 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 9: ConvNet architecture patterns Chapter 11: Image segmentation →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.