albermax / innvestigate

A toolbox to iNNvestigate neural networks' predictions!
Other
1.25k stars 233 forks source link

Does these methods works for only CNN models? #220

Closed Dipanjan-chatterjee closed 3 years ago

Dipanjan-chatterjee commented 3 years ago

Hi,

I am trying to use the methods for interpreting a model which consists both the CNN and GRU layer. I understand there are few methods that support only CNN layer ex: Pattern.Net. My question is, "are these methods only designed to work for CNN models only or can be used in other classification models with both the CNN and GRU in it?"

Thank You Dipanjan

rachtibat commented 3 years ago

Hi,

As far as I know, INNvestigate supports no RNN-like layers unfortunately.

Best

Dipanjan-chatterjee commented 3 years ago

Hi,

Thanks for your reply.

I've installed 'innvestigate' package with pip and then trying to use the analyzer. My environment does not support GPU, and my model is built on the CPU. I'm able to run the innvestigate in GPU based environment(ex, Google colab). But when I'm trying this code in CPU environment :

analyzer = innvestigate.create_analyzer("input_t_gradient", model)

It gives me following error : AttributeError: module 'innvestigate' has no attribute 'create_analyzer'

Can you please let me know why this is happening. The version of innvestigate I'm using is 1.0.8.

Thank You, Dipanjan

rachtibat commented 3 years ago

Hi,

I have looked at the error. I recommend using the new (UNOFFICIAL) version of innvestigate 2.0. You can find it on the branch updates_toward_tf2.0.

Just run the code:

Analyser = innvestigate.analyzer.InputTimesGradient(model=model_wo_sm)

analysis = Analyser.analyze(X=x_test[:50]) analysis = next(iter(analysis.values()))

plt.figure("Heatmap") plt.imshow(analysis[0].squeeze(-1), cmap="jet") plt.show()

Hope it helps

rachtibat commented 3 years ago

But please keep in mind, that there might be some bugs and not all methods are implemented yet. But luckily InputTimesGradient can be found (: