Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CNN attention/activation maps

What are common techniques for finding which parts of images contribute most to image classification via convolutional neural nets?

In general, suppose we have 2d matrices with float values between 0 and 1 as entires. Each matrix is associated with a label (single-label, multi-class) and the goal is to perform classification via (Keras) 2D CNN's.

I'm trying to find methods to extract relevant subsequences of rows/columns that contribute most to classification.

Two examples:

https://github.com/jacobgil/keras-cam

https://github.com/tdeboissiere/VGG16CAM-keras

Other examples/resources with an eye toward Keras would be much appreciated.

Note my datasets are not actual images, so using methods with ImageDataGenerator might not directly apply in this case.

like image 375
Quetzalcoatl Avatar asked Oct 18 '22 10:10

Quetzalcoatl


1 Answers

There are many visualization methods. Each of these methods has its strengths and weaknesses.

However, you have to keep in mind that the methods partly visualize different things. Here is a short overview based on this paper. You can distinguish between three main visualization groups:

  • Functions (gradients, saliency map): These methods visualize how a change in input space affects the prediction
  • Signal (deconvolution, Guided BackProp, PatternNet): the signal (reason for a neuron's activation) is visualized. So this visualizes what pattern caused the activation of a particular neuron.
  • Attribution (LRP, Deep Taylor Decomposition, PatternAttribution): these methods visualize how much a single pixel contributed to the prediction. As a result you get a heatmap highlighting which pixels of the input image most strongly contributed to the classification.

Since you are asking how much a pixel has contributed to the classification, you should use methods of attribution. Nevertheless, the other methods also have their right to exist.

One nice toolbox for visualizing heatmaps is iNNvestigate. This toolbox contains the following methods:

  • SmoothGrad
  • DeConvNet
  • Guided BackProp
  • PatternNet
  • PatternAttribution
  • Occlusion
  • Input times Gradient
  • Integrated Gradients
  • Deep Taylor
  • LRP
  • DeepLift
like image 128
Simdi Avatar answered Oct 21 '22 04:10

Simdi