Skip to content

Commit d91ea00

Browse files
author
eclique
committed
Easy_start added
1 parent c6cd21a commit d91ea00

File tree

3 files changed

+329
-2
lines changed

3 files changed

+329
-2
lines changed

Easy_start.ipynb

Lines changed: 298 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,30 @@
11
# RISE
2-
Detect model's attention
2+
This repository contains source code necessary to reproduce some of the main results in the paper:
3+
4+
[Vitali Petsiuk](http://cs-people.bu.edu/vpetsiuk/), [Abir Das](http://cs-people.bu.edu/dasabir/), [Kate Saenko](http://ai.bu.edu/ksaenko.html) (BMVC, 2018) <br>
5+
[RISE: Randomized Input Sampling for Explanation of Black-box Models](https://arxiv.org/abs/1806.07421)
6+
7+
**If you use this software in an academic article, please consider citing:**
8+
9+
@inproceedings{Petsiuk2018rise,
10+
title = {RISE: Randomized Input Sampling for Explanation of Black-box Models},
11+
author = {Vitali Petsiuk and Abir Das and Kate Saenko},
12+
booktitle = {Proceedings of the British Machine Vision Conference (BMVC)},
13+
year = {2018}
14+
}
15+
16+
For more information regarding the paper, please visit http://cs-people.bu.edu/vpetsiuk/rise/.
17+
18+
## Method overview
19+
To generate a saliency map for model's prediction, RISE queries black-box model on multiple randomly masked versions of input.
20+
After all the queries are done we average all the masks with respect to their scores to produce the final saliency map. The idea behind this is that whenever a mask preserves important parts of the image it gets higher score, and consequently has a higher weight in the sum.
21+
![](https://eclique.github.io/rep-imgs/RISE/rise-overview.png)
22+
23+
## Repository contents
24+
* The whole idea is implemented in [Easy_start](Easy_start.ipynb) notebook, it's done in Keras but is really easy to modify for any framework, since the method itself is model-agnostic.
25+
* [Saliency](Saliency.ipynb) notebook demonstrates the usage of RISE class optimized for PyTorch.
26+
* [Evaluation](Evaluation.ipynb) notebook displays another contribution of the paper: *Causal metrics*.
27+
28+
## Examples
29+
![](https://eclique.github.io/rep-imgs/RISE/example.png)
30+
![](https://eclique.github.io/rep-imgs/RISE/goldish.gif)

explanations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def generate_masks(self, N, s, p1, savepath='masks.npy'):
3333
self.masks = torch.from_numpy(self.masks).float()
3434
self.masks = self.masks.cuda()
3535
self.N = N
36+
self.p1 = p1
3637

3738
def load_masks(self, filepath):
3839
self.masks = np.load(filepath)
@@ -54,7 +55,7 @@ def forward(self, x):
5455
CL = p.size(1)
5556
sal = torch.matmul(p.data.transpose(0, 1), self.masks.view(N, H * W))
5657
sal = sal.view((CL, H, W))
57-
sal /= N
58+
sal = sal / N / self.p1
5859
return sal
5960

6061

0 commit comments

Comments
 (0)