-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with keras ResNet50 CAM visualisation #53
Comments
You need to specify You can search for its layer_idx using.
Let me know if that worked for you. Also consider submitting a PR to add that as an example :) |
Thank you for your reply. So I specified the |
Hmm. All blue means gradients are all 0s which seems unlikely. Could be a bug. I will try to investigate it. |
Did the same as @alecoutre1 but using a different network - At this point I can confirm the blue zero gradient map when using visualize_cam(backprop_modifier=None) |
@ahmedhosny Perhaps your penultimate layer has a spatial resolution of (1, 1)? Can you give the specifics of network structure? |
ok scratch that - my network is 3d and had other resizing issues (see #54 and #55) here is my network anyway - using layer dropout_4 as the penultimate
|
Cool. If it is not proprietary, would you mind adding an example of 3D visualization? I think it would be nice to have this as an example. |
promise to share once I have them, currently just viewing 2d slices from the 3d volume - its a tough one as the best viz method in this case would be volumetric rendering. |
Thanks :). I will help you out if needed. |
@alecoutre1 I debugged this for half a day now and couldn't find any obvious issues that might cause all blue heatmap. All the gradients are coming out negative which causes relu(heatmap) step to zero out everything. The only suspect at this point is issues with gradient computation under modified backprop. Once i have the theano implementation for this, i would be able to compare the two to see if this is a problem with gradient computation. It might very well be the case that resnet architecture too deep for saliency computation to be meaningful. I am adding a help wanted tag to see if someone who is an expert at tensorflow can help debug the issue. |
@raghakot any headway to confirm that the gradients are correct when compared with Theano? |
I did not implement theano version yet :( |
I encountered the same problem. For one of my two classes, all results using |
Hi, there. I created PR( #122 ) so please refer to it :-) |
Fix: Problem with keras ResNet50 CAM visualisation #53
Hi,
First of all, thank you for the great package, very useful and interesting.
I wanted to use the pre-trained models provided by keras at (https://keras.io/applications), using the weights from ImageNet. But when using the code of the example notebook attention.ipynb, and only replacing the model by the keras model (and adjusting the image sizes and layer_idx if necessary), it seems that the CAM visualisation doesn't work well with the ResNet50 architecture. It returns a completly blue map.
Is there something particular in the architecture of this network that could be problematic with cam visualisation ?
The text was updated successfully, but these errors were encountered: