raghakot / keras-vis

Neural network visualization toolkit for keras
https://raghakot.github.io/keras-vis
MIT License
2.97k stars 664 forks source link

InceptionV3 issue #98

Closed Jonas1312 closed 5 years ago

Jonas1312 commented 6 years ago

Hi, I'm currently trying to generate heatmap using grad-cam from my InceptionV3 model but I'm getting weird results: capture

Here is my code: https://gist.github.com/Jonas1312/e74cb8b0b39ddebb5c5666a3fa59299f

And the end of the network summary: capture

Jonas1312 commented 6 years ago

@Abhijit-2592 and @sakares Can you take a look at my code please? Thanks

Abhijit-2592 commented 6 years ago

@Jonas1312. Mmm.. Check whether class: "0" belongs to cat, and class: "1" belongs to dog (or can be vice versa, it is important to know which number is what class), And more over in this line, you have mentioned 0 for both the cases (filter_indices takes in the index of the class you are trying to visualise). If it still fails first verify whether your network has learned something.

I would recommend you first try it with imagenet classes so that you can understand how to visualize grad-cam using keras-vis. Then using it on your custom project becomes easier

Jonas1312 commented 6 years ago

@Abhijit-2592 Thanks for your quick answer

Actually my code is really similar to the InceptionV3 model, I just replaced the 1000 classes by 2 classes (cats and dogs). I retrained the network by freezing the InceptionV3 base_model layers and I reached 99% accuracy in less than 3 epochs.

I tried both filter_indices=0 and filter_indices=1 with cats and dogs images but the result is still the same...

Images with filter_indices=1: sans tditre sans titre

And yes "0" belongs to cat, and class: "1" belongs to dog, I double-checked it.

Abhijit-2592 commented 6 years ago

Training or validation or testing accuracy of 99? Try running a quick model.predict() on a set of test images to check if the network has learnt. set by_name = False while loading the weights. I suspect the weight loading being a prob