arXiv(opens in a new tab)Computer ScienceOct 2016Cited by 8 papers on PaperVantage

Manuscript Offprint

arXiv:1610.02391

Grad-CAM: Visual Explanations from Deep Networks via Gradient-Based Localization

Ramprasaath R. Selvaraju, Abhishek Das, Ramakrishna Vedantam, Michael Cogswell, Devi Parikh, Dhruv Batra

Abstract

We propose a technique for producing ‘visual explanations’ for decisions from a large class of Convolutional Neural Network (CNN)-based models, making them more transparent and explainable.

Our approach – Gradient-weighted Class Activation Mapping (Grad-CAM), uses the gradients of any target concept (say ‘dog’ in a classification network or a sequence of words in captioning network) flowing into the final convolutional layer to produce a coarse localization map highlighting the important regions in the image for predicting the concept.

Unlike previous approaches, Grad-CAM is applicable to a wide variety of CNN model-families: (1) CNNs with fully-connected layers (e.g. VGG), (2) CNNs used for structured outputs (e.g. captioning), (3) CNNs used in tasks with multi-modal inputs (e.g. visual question answering) or reinforcement learning, all without architectural changes or re-training. We combine Grad-CAM with existing fine-grained visualizations to create a high-resolution class-discriminative visualization, Guided Grad-CAM, and apply it to image classification, image captioning, and visual question answering (VQA) models, including ResNet-based architectures.

In the context of image classification models, our visualizations (a) lend insights into failure modes of these models (showing that seemingly unreasonable predictions have reasonable explanations), (b) outperform previous methods on the ILSVRC-15 weakly-supervised localization task, (c) are robust to adversarial perturbations, (d) are more faithful to the underlying model, and (e) help achieve model generalization by identifying dataset bias.

For image captioning and VQA, our visualizations show that even non-attention based models learn to localize discriminative regions of input image.

We devise a way to identify important neurons through Grad-CAM and combine it with neuron names [4] to provide textual explanations for model decisions. Finally, we design and conduct human studies to measure if Grad-CAM explanations help users establish appropriate trust in predictions from deep networks and show that Grad-CAM helps untrained users successfully discern a ‘stronger’ deep network from a ‘weaker’ one even when both make identical predictions. Our code is available at https://github.com/ramprs/grad-cam/, along with a demo on CloudCV [2], and a video at youtu.be/COjUB9Izk6E.

1 Introduction

Deep neural models based on Convolutional Neural Networks (CNNs) have enabled unprecedented breakthroughs in a variety of computer vision tasks, from image classification [33, 24], object detection [21], semantic segmentation [37] to image captioning [55, 7, 18, 29], visual question answering [3, 20, 42, 46] and more recently, visual dialog [11, 13, 12] and embodied question answering [10, 23]. While these models enable superior performance, their lack of decomposability into individually intuitive components makes them hard to interpret [36]. Consequently, when today’s intelligent systems fail, they often fail spectacularly disgracefully without warning or explanation, leaving a user staring at an incoherent output, wondering why the system did what it did.

Interpretability matters. In order to build trust in intelligent systems and move towards their meaningful integration into our everyday lives, it is clear that we must build ‘transparent’ models that have the ability to explain why they predict what they predict. Broadly speaking, this transparency and ability to explain is useful at three different stages of Artificial Intelligence (AI) evolution. First, when AI is significantly weaker than humans and not yet reliably deployable (e.g. visual question answering [3]), the goal of transparency and explanations is to identify the failure modes [1, 25], thereby helping researchers focus their efforts on the most fruitful research directions. Second, when AI is on par with humans and reliably deployable (e.g., image classification [30] trained on sufficient data), the goal is to establish appropriate trust and confidence in users. Third, when AI is significantly stronger than humans (e.g. chess or Go [50]), the goal of explanations is in machine teaching [28] – i.e., a machine teaching a human about how to make better decisions.

Figure

(a) Original Image

Figure

(b) Guided Backprop ‘Cat’

Figure

(c) Grad-CAM ‘Cat’

Figure

(d) Guided Grad-CAM ‘Cat’

Figure

(e) Occlusion map ‘Cat’

Figure

(f) ResNet Grad-CAM ‘Cat’

Figure

(g) Original Image

Figure

(h) Guided Backprop ‘Dog’

Figure

(i) Grad-CAM ‘Dog’

Figure

(j) Guided Grad-CAM ‘Dog’

Figure

(k) Occlusion map ‘Dog’

Figure

(l) ResNet Grad-CAM ‘Dog’

Figure 1: (a) Original image with a cat and a dog. (b-f) Support for the cat category according to various visualizations for VGG-16 and ResNet. (b) Guided Backpropagation [53]: highlights all contributing features. (c, f) Grad-CAM (Ours): localizes class-discriminative regions, (d) Combining (b) and (c) gives Guided Grad-CAM, which gives high-resolution class-discriminative visualizations. Interestingly, the localizations achieved by our Grad-CAM technique, (c) are very similar to results from occlusion sensitivity (e), while being orders of magnitude cheaper to compute. (f, l) are Grad-CAM visualizations for ResNet-18 layer. Note that in (c, f, i, l), red regions corresponds to high score for class, while in (e, k), blue corresponds to evidence for the class. Figure best viewed in color.

There typically exists a trade-off between accuracy and simplicity or interpretability. Classical rule-based or expert systems [26] are highly interpretable but not very accurate (or robust). Decomposable pipelines where each stage is hand-designed are thought to be more interpretable as each individual component assumes a natural intuitive explanation. By using deep models, we sacrifice interpretable modules for uninterpretable ones that achieve greater performance through greater abstraction (more layers) and tighter integration (end-to-end training). Recently introduced deep residual networks (ResNets) [24] are over 200-layers deep and have shown state-of-the-art performance in several challenging tasks. Such complexity makes these models hard to interpret. As such, deep models are beginning to explore the spectrum between interpretability and accuracy.

Zhou et al. [59] recently proposed a technique called Class Activation Mapping (CAM) for identifying discriminative regions used by a restricted class of image classification CNNs which do not contain any fully-connected layers. In essence, this work trades off model complexity and performance for more transparency into the working of the model. In contrast, we make existing state-of-the-art deep models interpretable without altering their architecture, thus avoiding the interpretability vs. accuracy trade-off. Our approach is a generalization of CAM [59] and is applicable to a significantly broader range of CNN model families: (1) CNNs with fully-connected layers (e.g. VGG), (2) CNNs used for structured outputs (e.g. captioning), (3) CNNs used in tasks with multi-modal inputs (e.g. VQA) or reinforcement learning, without requiring architectural changes or re-training.

What makes a good visual explanation? Consider image classification [14] – a ‘good’ visual explanation from the model for justifying any target category should be (a) class-discriminative (i.e. localize the category in the image) and (b) high-resolution (i.e. capture fine-grained detail).

Fig. 1 shows outputs from a number of visualizations for the ‘tiger cat’ class (top) and ‘boxer’ (dog) class (bottom). Pixel-space gradient visualizations such as Guided Backpropagation [53] and Deconvolution [57] are high-resolution and highlight fine-grained details in the image, but are not class-discriminative (Fig. 1(b) and Fig. 1(h) are very similar).

In contrast, localization approaches like CAM or our proposed method Gradient-weighted Class Activation Mapping (Grad-CAM), are highly class-discriminative (the ‘cat’ explanation exclusively highlights the ‘cat’ regions but not ‘dog’ regions in Fig. 1(c), and vice versa in Fig. 1(i)).

In order to combine the best of both worlds, we show that it is possible to fuse existing pixel-space gradient visualizations with Grad-CAM to create Guided Grad-CAM visualizations that are both high-resolution and class-discriminative. As a result, important regions of the image which correspond to any decision of interest are visualized in high-resolution detail even if the image contains evidence for multiple possible concepts, as shown in Figures 1d and 1j. When visualized for ‘tiger cat’, Guided Grad-CAM not only highlights the cat regions, but also highlights the stripes on the cat, which is important for predicting that particular variety of cat.

To summarize, our contributions are as follows:

(1) We introduce Grad-CAM, a class-discriminative localization technique that generates visual explanations for any CNN-based network without requiring architectural changes or re-training. We evaluate Grad-CAM for localization (Sec. 4.1), and faithfulness to model (Sec. 5.3), where it outperforms baselines.

(2) We apply Grad-CAM to existing top-performing classification, captioning (Sec. 8.1), and VQA (Sec. 8.2) models. For image classification, our visualizations lend insight into failures of current CNNs (Sec. 6.1), showing that seemingly unreasonable predictions have reasonable explanations. For captioning and VQA, our visualizations expose that common CNN + LSTM models are often surprisingly good at localizing discriminative image regions despite not being trained on grounded image-text pairs.

(3) We show a proof-of-concept of how interpretable Grad-CAM visualizations help in diagnosing failure modes by uncovering biases in datasets. This is important not just for generalization, but also for fair and bias-free outcomes as more and more decisions are made by algorithms in society.

(4) We present Grad-CAM visualizations for ResNets [24] applied to image classification and VQA (Sec. 8.2).

(5) We use neuron importance from Grad-CAM and neuron names from [4] and obtain textual explanations for model decisions (Sec. 7).

(6) We conduct human studies (Sec. 5) that show Guided Grad-CAM explanations are class-discriminative and not only help humans establish trust, but also help untrained users successfully discern a ‘stronger’ network from a ‘weaker’ one, even when both make identical predictions.

Paper Organization: The rest of the paper is organized as follows. In section 3 we propose our approach Grad-CAM and Guided Grad-CAM. In sections 4 and 5 we evaluate the localization ability, class-discriminativeness, trustworthyness and faithfulness of Grad-CAM. In section 6 we show certain use cases of Grad-CAM such as diagnosing image classification CNNs and identifying biases in datasets. In section 7 we provide a way to obtain textual explanations with Grad-CAM. In section 8 we show how Grad-CAM can be applied to vision and language models – image captioning and Visual Question Answering (VQA).

Figure

Figure 2: Grad-CAM overview: Given an image and a class of interest (e.g., ‘tiger cat’ or any other type of differentiable output) as input, we forward propagate the image through the CNN part of the model and then through task-specific computations to obtain a raw score for the category. The gradients are set to zero for all classes except the desired class (tiger cat), which is set to 1. This signal is then backpropagated to the rectified convolutional feature maps of interest, which we combine to compute the coarse Grad-CAM localization (blue heatmap) which represents where the model has to look to make the particular decision. Finally, we pointwise multiply the heatmap with guided backpropagation to get Guided Grad-CAM visualizations which are both high-resolution and concept-specific.

References (56)

  • Analyzing the Behavior of Visual Question Answering Models
  • CloudCV: Large Scale Distributed Computer Vision as a Cloud Service
  • VQA: Visual Question Answering
  • Network dissection: Quantifying interpretability of deep visual representations
  • Self-taught object localization with deep networks
  • Representation learning: A review and new perspectives
  • Lin, R. Vedantam, S. Gupta, P. Dollár, and C. L. Zitnick (opens arXiv in a new tab)
  • Weakly supervised object localization with multi-fold multiple instance learning
  • Human Attention in Visual Question Answering: Do Humans and Deep Networks Look at the Same Regions? In EMNLP, 2016
  • Embodied Question Answering
  • Visual Dialog
  • Learning cooperative visual dialog agents with deep reinforcement learning
  • Guesswhat?! visual object discovery through multi-modal dialogue
  • Li, K. Li, and L. Fei-Fei
  • Inverting Convolutional Networks with Convolutional Networks
  • Visualizing Higher-layer Features of a Deep Network
  • The PASCAL Visual Object Classes Challenge 2007 (VOC2007) Results
  • Yeung, and A. G. Hauptmann
  • Are You Talking to a Machine? Dataset and Methods for Multilingual Image Question Answering
  • Rich Feature Hierarchies for Accurate Object Detection and Semantic Segmentation
  • Explaining and harnessing adversarial examples
  • Iqa: Visual question answering in interactive environments (opens arXiv in a new tab)
  • Deep residual learning for image recognition
  • Diagnosing Error in Object Detectors
  • Caffe: Convolutional Architecture for Fast Feature Embedding
  • Becoming the Expert - Interactive Multi-Class Machine Teaching
  • DenseCap: Fully Convolutional Localization Networks for Dense Captioning
  • Deep visual-semantic alignments for generating image descriptions
  • Seed, expand and constrain: Three principles for weakly-supervised image segmentation
  • Imagenet classification with deep convolutional neural networks
  • Network in network
  • Fully convolutional networks for semantic segmentation
  • Deeper LSTM and normalized CNN Visual Question Answering model
  • Hierarchical question-image co-attention for visual question answering
  • Salient deconvolutional networks
  • Visualizing deep convolutional neural networks using natural pre-images
  • Ask your neurons: A neural-based approach to answering questions about images
  • Learning and transferring mid-level image representations using convolutional neural networks
  • Is object localization for free? – weakly-supervised learning with convolutional neural networks
  • From image-level to pixel-level labeling with convolutional networks
  • Exploring models and data for image question answering
  • Why Should I Trust You?
  • Choose your neuron: Incorporating domain knowledge through neuron-importance
  • Taking a hint: Leveraging explanations to make vision and language models more grounded
  • Nature, 529(7587):484–489, 2016
  • Deep Inside Convolutional Networks: Visualising Image Classification Models and Saliency Maps
  • Very Deep Convolutional Networks for Large-Scale Image Recognition
  • Striving for Simplicity: The All Convolutional Net
  • Rethinking the inception architecture for computer vision
  • Show and tell: A neural image caption generator
  • HOGgles: Visualizing Object Detection Features
  • Visualizing and understanding convolutional networks
  • Top-down Neural Attention by Excitation Backprop
  • Learning Deep Features for Discriminative Localization
  • Lapedriza, A. Oliva, and A. Torralba (opens arXiv in a new tab)
  • Places: A 10 million image database for scene recognition