/attribution-experiments

Re-Implementing recent DNN Attribution methods

Primary LanguagePython

Attribution Experiments

Implementation and tests of several attribution methods:

... and maybe some others soon.

Example

import matplotlib.pyplot as plt
from attribution.methods.grad_based import SmoothGrad
from attribution.utils.viz import Heatmap

# the model to be inspected
model = ...  # type: torch.nn.Module

# the image to analyse
img = ...  # type: torch.Tensor

# the target label to derive from, ground truth or any other
target = ...  # type: torch.Tensor

# get heatmap for this input image
method = SmoothGrad(model, std=0.2)
hmap = method.get_map(img=img, target=target)

# visualize the result
fig = plt.figure() # the figure to paint to, may be subfigure
visualizer = Heatmap()
visualizer.show(hmap=hmap, img=img, fig=fig)

Good Example

"sturgeon" attribution methods

Bad Example

"basketball" attribution methods

Information Dropout

On cluttered MNIST information dropout