(This repo is based on the visual-attribution (07c79...) frame work by Yulong Wang (2018).)
Code accompanying the paper Pattern-Guided Integrated Gradients, presented at the ICML 2020 Workshop on Human Interpretability in MachineLearning (WHI 2020) by Robert Schwarzenberg and Steffen Castle (equal contribution):
@inproceedings{pgig2020,
title={Pattern-Guided Integrated Gradients},
author={Schwarzenberg, Robert and Steffen Castle},
booktitle={Proc. of the ICML 2020 Workshop on Human Interpretability in Machine Learning (WHI)},
year={2020}
}
For a quick overview, see the synthetic experiments.
Addendum: We now also present arguments against the implementation invariance of PA and PGIG.
Input | Integrated Gradients | PatternAttribution | Pattern-Guided Integrated Gradients |
---|---|---|---|
We ran the experiments on Ubuntu 16.04.6 LTS, with Python 3.6.9 installed, on GeForce GTX 1080 Tis, using cuda10.0+cudnn7.6.2
The minimal requirements are
torch==1.2.0
torchvision==0.4.0a0+6b959ee
scikit-learn==0.22.1
All other dependencies are listed in dependencies.txt
Weights and patterns can be downloaded using the download_patterns.sh
script in the weights
directory. In case the URLs become invalid, there are backups here.
The degradation experiment can be executed by running experiments/degradation_test.py
.
To run experiments, the validation set of ImageNet 2012 must already be downloaded and extracted locally, and the ImageNet directory must be specified using the --data_dir
argument. The --imagenet_download_key
argument and functionality to automatically download the ImageNet dataset is deprecated.
Argument | Description |
---|---|
--methods | List of methods to evaluate |
--batch_size | Batch size, default is 50 |
--data_dir | Directory where imagenet validation set is downloaded, or where to download it |
--val_size | Number of samples to evaluate, default is the whole ImageNet validation set |
--n_patches | Number of patches to degrade, default is 100 |
--imagenet_download_key | Optional URL string for ImageNet download (deprecated) |
Method | Method argument string |
---|---|
Vanilla Gradient | vanilla_grad |
PatternAttribution | pattern_vanilla_grad |
Gradient times Input | grad_x_input |
Integrated Gradients | integrate_grad |
Guided Backprop | guided_backprop |
SmoothGrad | smooth_grad |
SmoothGrad2 | smooth_grad2 |
SmoothGrad-Integrated Gradients | sg_ig |
VarGrad | var_grad |
Expected Gradients | exp_grad |
Pattern-Guided Integrated Gradients | pattern_integrate_grad |
python3 experiments/degradation_test.py --methods vanilla_grad pattern_vanilla_grad integrate_grad pattern_integrate_grad --batch_size 100 --val_size 10000 --n_patches 100 --data_dir /mnt/hdd/datasets/imagenet/
[1] Kindermans, Pieter-Jan, et al. "Learning how to explain neural networks: Patternnet and patternattribution." arXiv preprint arXiv:1705.05598 (2017).
[2] Sundararajan, Mukund, Ankur Taly, and Qiqi Yan. "Axiomatic attribution for deep networks." arXiv preprint arXiv:1703.01365 (2017).