-
Notifications
You must be signed in to change notification settings - Fork 480
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
Final convolutional layer tensor for activation map with Grad-CAM #64
Comments
Should be either |
Both of them have shape |
@nguyenhoa93 , did you finally managed to run Grad-Cam?
If I print the watched variables, there is no variables watched, so I am pretty new to tensorflow and a bit lost yet. I'll appreciate any help. |
@borjaMinano Edit: After reading @haydengunraj 's comment, I read again the document of tf.GradientTap() and realized that it's available in Eager Execution - TF 1.15 as well. Like @haydengunraj said, we need to First, define
I did the activation map already but want to make sure that I select the last convolutional layer correctly. You can see my code here: https://gist.github.com/nguyenhoa93/d49564875234f6722ff89e65db34a00b
I took This is the GradCAM result of COVID-19 when the model predict the image as COVID-19. |
@borjaMinano I don't have much experience with Grad-CAM, but the main issue in the code snippet you posted above is more of a general Tensorflow thing. When you use TL;DR, you need to do something like: with tf.GradientTape() as tape:
tape.watch(image_tensor)
loss_tensor = ...define your loss tensor here
grad_tensor = tape.gradient(loss_tensor, conv_op)
grads = sess.run(grad_tensor, feed_dict={image_tensor: np.expand_dims(x, axis=0)}) |
Thank you very much for your help. |
My pleasure, @borjaMinano |
hi @nguyenhoa93 i was referring your code on line no. 144 what is 'im' ? I got below error : thanks |
@ankitdata it should be |
Thanks @nguyenhoa93, it worked for me. Any idea what will be the 'final convolutional layer tensor' for Model: COVIDNet-CXR3-A
I checked tensors with below code
which tensor will work from the list ? Thanks |
@ankitdata |
@nguyenhoa93 Do you have any plan to build network for COVIDNet-CXR3-A ? thanks . |
You can use the same code that I shared and change the name of final conv to The code will work for all TensorFlow models (TF 1.15). |
Hi @nguyenhoa93 I tried with 3 models (small ,Large & COVIDNet-CXR3-A) heatmaps i shared below for small model and large model sensitivity is higher for COVID-19 so prediction is COVID-19 what is your suggestion on this ? Heatmaps input-image - assets/ex-covid.jpeg |
@ankitdata , I tried with the three new models (and also with Large model) and I see the same detection problem with model-A, but not with models B and C, even though the heatmaps are different from Large model. I think the Large model's heatmap is the most accurate, watching at the raw image. |
@nguyenhoa93 Hello! I was wondering if you had done this with model: COVIDNet-CXR4-A The naming convention for the convolutional layers seems quite different and I was wondering what to use for the final conv layer name. any help would be so much appreciated! Thank you. |
using @nguyenhoa93 gradcam code these are the results I get using these input specifications: using model COVIDNet-CXR4-A from: { using this model running on image: /data/test/0088be53-27f2-4c30-882b-a73a3a5c8c71.png I get these results It could be that my final convolutional layer name is incorrect, can anyone verify? @lindawangg @haydengunraj EDIT: ok so I also tried it with: { and actually got some result that looks like an actual heatmap, but I just wanted to confirm that "conv_7b/convolution:0" is the final conv layer and the correct layer for computing gradcams in model COVIDNet-CXR4-A? @lindawangg @haydengunraj @nguyenhoa93 |
@borjaMinano what tensornames did you use for final_conv_tensor for the models CXR3 B and C because they seem to be named different from CXR3 A |
Hi Ankit,
Is there any way for you to confirm the layers I posted about and whether
they are the final conv layers? I also asked a question in another issue
about the training tensors for the small and large models. It would be
extremely helpful.
Best,
Robbie Sadre
…On Sun, Jan 3, 2021 at 10:50 AM Ankit Chilkalwar ***@***.***> wrote:
Thanks for sharing this information.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#64 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AP7YI3TDWTJFZ57C7WJH7WDSYC37LANCNFSM4NBAZGCQ>
.
|
For Large Model: final conv layer for heatmaps if you want list all tensors use below code. I am not sure on sharing information about small model. thanks.! |
Hello,
Thank you for sharing your work!
I am trying to make the activation map to see the important features from your two trained models (COVIDNet-CXR Small and COVIDNet-CXR Large).
To do that I would like to know the name of the final convolutional layer tensor. I have checked your document train_eval_inference.md but have found that tensor name.
I listed all tensor names in your models by this code:
And this is a subset of the tensor names:
Based on that, I guess the final convolutional layer tensor is
conv5_block3_out/add:0
and make the activation map based on that.To confirm what I have done, my question: Is the final convolutional layer tensor is actually
conv5_block3_out/add:0
?Thank you for your time.
The text was updated successfully, but these errors were encountered: