Guided Backpropagation

Sources:

  1. Deconvolution 2013 paper
  2. Guided Backpropagation 2015 paperhttps://arxiv.org/abs/1412.6806)

Code: Jax Feature Attribution Methods

Notation

Suppose we have a convolutional neural network (CNN) which intakes an image and outputs a scalar target.

Symbol Type Explanation
\(x\) \(\in \mathbb{R}^{\text{any tensor shape}}\) tensor before the relu function
\(y\) \(\in \mathbb{R}^{\text{any tensor shape}}\) tensor after the relu function
\(L\) \(\in \mathbb{R}\) scalar output of the CNN
\((x > 0)\) \(\in \{0, 1\}\) indicator function, 1 if \(( x > 0 )\), otherwise 0

Deconvolution

The deconvolutional network ('deconvnet') approach to visualizing concepts learned by neurons in higher layers of a CNN can be summarized as follows. Given a high-level feature map, the 'deconvnet' inverts the data flow of a CNN , going from neuron activations in the given layer down to an image. Typically, a single neuron is left non-zero in the high level feature map. Then the resulting reconstructed image shows the part of the input image that is most strongly activating this neuron (and hence the part that is most discriminative to it). A schematic illustration of this procedure is shown in Figure 1 a). In order to perform the reconstruction through max-pooling layers, which are in general not invertible, the method of Zeiler and Fergus requires first to perform a forward pass of the network to compute ’switches’ – positions of maxima within each pooling region. These switches are then used in the ’deconvnet’ to obtain a discriminative reconstruction. By using the switches from a forward pass the ’deconvnet’ (and thereby its reconstruction) is hence conditioned on an image and does not directly visualize learned features.

A deconvolutional version of the neural network is created. Then the values from a convolutional layer are passed through the deconvolutional network to convert the features to pixel space, which produces the desired attribution map.

Figure 1

Figure 1. Top: A deconvnet layer (left) attached to a convnet layer (right). The deconvnet will reconstruct an approximate version of the convnet features from the layer beneath. Bottom: An illustration of the unpooling operation in the deconvnet, using switches which record the location of the local max in each pooling region (colored zones) during pooling in the convnet.

  • Unpooling: In the convnet, the max pooling opera- tion is non-invertible, however we can obtain an ap- proximate inverse by recording the locations of the maxima within each pooling region in a set of switch variables.
  • Rectification: We pass the reconstructed signal through a relu non-linearity..
  • Filtering: The deconvnet uses transposed versions of the same filters, but applied to the rectified maps,

Guided Backpropagation

Suppose we have the following sequence in a CNN: \[ x \xrightarrow{\operatorname{ReLU}()} y \rightarrow \cdots \rightarrow L , \] where \(x\) is transformed to \(y\) through the ReLU activation function, and \(L\) is the scalar output.

During backpropagation, the gradient of \(L\) with respect to \(x\) is given by: \[ \frac {\partial L}{\partial x} = \frac {\partial L}{\partial y} \color{red}{\frac {\partial y}{\partial x}} . \]

Since \(y=\operatorname{ReLU}(x)\), we can express this gradient as:

\[ \frac {\partial L}{\partial x} = \frac {\partial L}{\partial y} \color{red}{(x>0)} . \]

In the deconvnet method, we replace the condition \(\color{red}{(x>0)}\) with \(\color{salmon}{(\frac {\partial L}{\partial y} > 0)}\), i.e., \[ \frac {\partial L}{\partial x} = \frac {\partial L}{\partial y} \color{salmon}{(\frac {\partial L}{\partial y} > 0)} . \]

In the guided backpropagation method, we combine both conditions, i.e.,

\[ \frac {\partial L}{\partial x} = \frac {\partial L}{\partial y} \color{red}{(x>0)}\color{salmon}{(\frac {\partial L}{\partial y} > 0)} . \]

Constrains

Both deconvolution and guided backpropagation are not class discriminative (doesn't localize the category in the image),

Drawbacks

According to 2018 paper Sanity Checks for Saliency Maps, Guided Backprop is invariant to higher layer weights.