marcoancona / DeepExplain

A unified framework of perturbation and gradient-based attribution methods for Deep Neural Networks interpretability. DeepExplain also includes support for Shapley Values sampling. (ICLR 2018)
https://arxiv.org/abs/1711.06104
MIT License
729 stars 133 forks source link

index 0 is out of bounds for axis 0 with size 0 #42

Open sherlock42 opened 5 years ago

sherlock42 commented 5 years ago

I am trying to to do it for 3 channel images with 2 classes. on running the following code

from utils import plot, plt
%matplotlib inline
n_cols = 4
n_rows = int(len(attributions_gradin) / 2)
fig, axes = plt.subplots(nrows=n_rows, ncols=n_cols, figsize=(3*n_cols, 3*n_rows))

for i, a1 in enumerate(attributions_gradin):
    row, col = divmod(i, 2)
    plot(xs[i].reshape(224,224,3), cmap='Greys', axis=axes[row, col*3]).set_title('Original')
    plot(a1.reshape(224,224,3), xi = xs[i], axis=axes[row,col*3+1]).set_title('Grad*Input')
#     plot(a2.reshape(28,28), xi = xs[i], axis=axes[row,col*3+2]).set_title('Shapley Values')`

I am getting the error

IndexError                                Traceback (most recent call last)
<ipython-input-74-77779a4b2a3b> in <module>()
      8 for i, a1 in enumerate(attributions_gradin):
      9     row, col = divmod(i, 2)
---> 10     plot(xs[i].reshape(224,224,3), cmap='Greys', axis=axes[row, col*3]).set_title('Original')
     11     plot(a1.reshape(224,224,3), xi = xs[i], axis=axes[row,col*3+1]).set_title('Grad*Input')
     12 #     plot(a2.reshape(28,28), xi = xs[i], axis=axes[row,col*3+2]).set_title('Shapley Values')

IndexError: index 0 is out of bounds for axis 0 with size 0
marcoancona commented 5 years ago

This does not look like a problem with the library but rather a problem with access to axes