• Stars
    star
    327
  • Rank 128,686 (Top 3 %)
  • Language
    Jupyter Notebook
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tensorflow tutorial for various Deep Neural Network visualization techniques

Understanding NN

This repository is intended to be a tutorial of various DNN interpretation and explanation techniques. Explanation of the theoretical background as well as step-by-step Tensorflow implementation for practical usage are both covered in the Jupyter Notebooks. I did not include explanation for techniques for which I thought the algorithm as well as the explanation of the original paper was clear.

UPDATE

It seems that Github is unable to render some of the equations in the notebooks. I strongly recommend using the nbviewer until I find out what the problem is (you can also download the repo and view them on your local environment). Links are listed below.

Nbviewer Links

1.1 Activation Maximization

1.3 Performing AM in Code Space

2.1 Sensitivity Analysis

2.2 Simple Taylor Decomposition

2.3 Layer-wise Relevance Propagation Part 1

2.3 Layer-wise Relevance Propagation Part 2

2.4 Deep Taylor Decomposition Part 1

2.4 Deep Taylor Decomposition Part 2

2.5 DeepLIFT

3.1 Deconvolution

3.2 Backpropagation

3.3 Guided Backpropagation

3.4 Integrated Gradients

3.5 SmoothGrad

4.1 Class Activation Map

4.2 Grad-CAM

4.3 Grad-CAM++

5.1 Explanation Continuity

5.2 Explanation Selectivity

1 Activation Maximization

This section focuses on interpreting a concept learned by a deep neural network (DNN) through activation maximization.

1.1 Activation Maximization (AM)

alt tag

alt tag

1.3 Performing AM in Code Space

alt tag

alt tag

2 Layer-wise Relevance Propagation

In this section, we first introduce the concept of relevance score with Sensitivity Analysis, explore basic relevance decomposition with Simple Taylor Decomposition and then build up to various Layer-wise Relevance Propagation methods such as Deep Taylor Decomposition and DeepLIFT.

2.1 Sensitivity Analysis

alt tag

alt tag

2.2 Simple Taylor Decomposition

alt tag

alt tag

2.3 Layer-wise Relevance Propagation

alt tag

2.4 Deep Taylor Decomposition

alt tag

alt tag

2.5 DeepLIFT

alt tag

alt tag

3 Gradient Based Methods

Implementation of various types of gradient-based visualization methods such as Deconvolution, Backpropagation, Guided Backpropagation, Integrated Gradients and SmoothGrad.

3.1 Deconvolution

alt tag

alt tag

3.2 Backpropagation

alt tag

alt tag

3.3 Guided Backpropagation

alt tag

alt tag

3.4 Integrated Gradients

alt tag

alt tag

3.5 SmoothGrad

alt tag

alt tag

4 Class Activation Map

Implementation of Class Activation Map (CAM) and its generalized versions, Grad-CAM and Grad-CAM++ the cluttered MNIST dataset.

4.1 Class Activation Map

alt tag

alt tag

4.2 Grad-CAM

alt tag

alt tag

4.3 Grad-CAM++

alt tag

alt tag

5 Quantifying Explanation Quality

While each explanation technique is based on its own intuition or mathematical principle, it is also important to de fine at a more abstract level what are the characteristics of a good explanation, and to be able to test for these characteristics quantitatively. We present in Sections 5.1 and 5.2 two important properties of an explanation, along with possible evaluation metrics.

5.1 Explanation Continuity

alt tag

alt tag

5.2 Explanation Selectivity

alt tag

alt tag

Explanation Technique Comparison Graph

Prerequisites

This tutorial requires Tensorflow, NumPy, Matplotlib, and OpenCV.

References

Sections 1.1 ~ 2.2 and 5.1 ~ 5.2

[1] Montavon, G., Samek, W., Müller, K., jun 2017. Methods for Interpreting and Understanding Deep Neural Networks. arXiv preprint arXiv:1706.07979, 2017.

Section 1.3

[2] Nguyen, A., Dosovitskiy, A., Yosinski, J., Brox, T., Clune, J., 2016. Synthesizing the preferred inputs for neurons in neural networks via deep generator networks. In: Advances in Neural Information Processing Systems 29: Annual Conference on Neural Information Processing Systems 2016, December 5-10, 2016, Barcelona, Spain. pp. 3387-3395.

[3] A. Dosovitskiy and T. Brox. Generating images with perceptual similarity metrics based on deep networks. In NIPS, 2016.

Section 2.3

[4] Bach, S., Binder, A., Montavon, G., Klauschen, F., Müller, K.R., Samek, W., 07 2015. On pixel-wise explanations for non-linear classi er decisions by layer-wise relevance propagation. PLOS ONE 10 (7), 1-46.

Section 2.4

[5] Montavon, G., Lapuschkin, S., Binder, A., Samek, W., Müller, K.R., 2017. Explaining nonlinear classi cation decisions with deep Taylor decomposition. Pattern Recognition 65, 211-222.

Section 2.5

[6] Avanti Shrikumar, Peyton Greenside, and Anshul Kundaje. Learning Important Features Through Propagating Activation Differences. arXiv preprint arXiv:1704.02685, 2017.

Section 3.1

[7] Zeiler, M. D., Fergus, R., 2014. Visualizing and understanding convolutional networks. In: Computer Vision - ECCV 2014 - 13th European Conference, Zurich, Switzerland, September 6-12, 2014, Proceedings, Part I. pp. 818-833.

Section 3.2

[8] K. Simonyan, A. Vedaldi, and A. Zisserman. Deep inside convolutional networks: Visualising image classification models and saliency maps. In Workshop at International Conference on Learning Representations, 2014.

Section 3.3

[9] Jost Tobias Springenberg, Alexey Dosovitskiy, Thomas Brox, and Martin Riedmiller. Striving for simplicity: The all convolutional net. arXiv preprint arXiv:1412.6806, 2014.

Section 3.4

[10] Mukund Sundararajan, Ankur Taly, and Qiqi Yan. Axiomatic attribution for deep networks. arXiv preprint arXiv:1703.01365, 2017.

Section 3.5

[11] Daniel Smilkov, Nikhil Thorat, Been Kim, Fernanda Viégas, and Martin Wattenberg. SmoothGrad: removing noise by adding noise. arXiv preprint arXiv:1706.03825, 2017.

Section 4.1

[12] Bolei Zhou, Aditya Khosla, Agata Lapedriza, Aude Oliva, and Antonio Torralba. Learning deep features for discriminative localization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2921–2929, 2016.

Section 4.2

[13] R. R.Selvaraju, A. Das, R. Vedantam, M. Cogswell, D. Parikh, and D. Batra. Grad-cam: Why did you say that? visual explanations from deep networks via gradient-based localization. arXiv:1611.01646, 2016.

Section 4.3

[14] A. Chattopadhyay, A. Sarkar, P. Howlader, and V. N. Balasubramanian. Grad-cam++: Generalized gradient-based visual explanations for deep convolutional networks. CoRR, abs/1710.11063, 2017.

More Repositories

1

Rectified-Gradient

Official repository for "Why are Saliency Maps Noisy? Cause of and Solution to Noisy Saliency Maps".
Jupyter Notebook
33
star
2

Robustness-and-Interpretability

Official repository for "Bridging Adversarial Robustness and Gradient Interpretability".
Jupyter Notebook
29
star
3

DMCMC

Official PyTorch implementation of "Denoising MCMC for Accelerating Diffusion-Based Generative Models"
Python
18
star
4

Paper-Review

Reviews of papers on ML, DL, Statistics, Optimization, etc.
TeX
11
star
5

MemN2N-Tensorflow

Implementation of End-To-End Memory Networks with Tensorflow for bAbI Dataset
Jupyter Notebook
11
star
6

Generative-Adversarial-Text-to-Image-Synthesis-Tensorflow

Tensorflow implementation of Generative Adversarial Text to Image Synthesis for MNIST handwritten digit dataset
Python
8
star
7

object-detection-api-wrapper

Simple wrapper for Google Object Detection API
Jupyter Notebook
7
star
8

InfoGAN-Tensorflow

Implementation of InfoGAN in Tensorflow for MNIST handwritten digit dataset
Jupyter Notebook
7
star
9

EBCLR

Official PyTorch implementation of "Energy-Based Contrastive Learning of Visual Representations", NeurIPS 2022
Python
5
star
10

Gaussian-Process

Numpy implementation of "Gaussian Processes for Machine Learning", Chapters 2.1 and 2.2
Jupyter Notebook
5
star
11

LSTM

MATLAB
4
star
12

GCTM

Official repository for Generalized Consistency Trajectory Models
Python
4
star
13

HMM

A java library for Hidden Markov Models
Java
4
star
14

Tensorflow-Graph-Utils

Simple module for visualizing and editing Tensorflow Graphs in Jupyter Notebook
Jupyter Notebook
2
star
15

Annotated_MNIST

Thickness and skew labeler for MNIST handwritten digit dataset
Jupyter Notebook
2
star
16

stackGAN-Tensorflow

Tensorflow implementation of Generative Adversarial Network for MNIST handwritten digit dataset
Jupyter Notebook
1
star