Skip to content
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

Interfacing with GradCAM? #9

Closed
AND2797 opened this issue Aug 5, 2020 · 9 comments
Closed

Interfacing with GradCAM? #9

AND2797 opened this issue Aug 5, 2020 · 9 comments
Labels
Good issue for better understanding

Comments

@AND2797
Copy link

AND2797 commented Aug 5, 2020

Is it possible to update the documentation or provide some instructions on how we can reproduce GradCAM like visualizations with the code that is provided?

@dongliangchang
Copy link
Member

dongliangchang commented Aug 6, 2020

You can find the related code at pytorch-cnn-visualizations. Due to a channel group is belonging to a certain class in our method , we can directly visualize the channels without Gradient-weighted. (e.g., as the 1-3 channels belonging to the first class, we can directly visualize those channels without Gradient-weighted). Just revise the related code for you need.

@AND2797
Copy link
Author

AND2797 commented Aug 6, 2020

So the activation maps from MCLoss are essentially the same as what we get from GradCAM?

@dongliangchang
Copy link
Member

No, there has a typo. We don't use vanilla GradCAM to visualize the channels (fig 5 & 7), we directly visualuze the channels beonging to a certain class. Sorry for this.

@dongliangchang
Copy link
Member

E.g., for the first class, we known that the first channel group (1-3 channels) belonging to it. So, we don't need to use the grad to weighted all channels (GradCAM).

@dongliangchang dongliangchang pinned this issue Aug 6, 2020
@AND2797
Copy link
Author

AND2797 commented Aug 6, 2020

Sorry, I am a little confused so just to confirm I will summarize what I have understood and please correct me if it is wrong. The MCLoss code gives us a feature map of all class activations. For eg: there are 50 classes and 3 channels, the feature map will total have 150 activation maps, and if we know that the correct class is class 1, then channels 1 - 3 will tell us what are the discriminant parts for that class. So the MCLoss code already gives us these activation maps and we can directly use this to visualize the channels and gradCAM Is not required.

If this is the case then do we super-impose the activation maps on the input image by upsampling the activation maps to 224 x 224?

@dongliangchang
Copy link
Member

dongliangchang commented Aug 6, 2020

There is no problem with your understanding for visualization.

Yes, just revise the code of gradCAM, remove the channel weighted, and then chose one channel to visualizaiton.
Here is a example:
for GradCAM:
heatmap = a_1 * channel_1 + a_2 * channel_2+ ... + a_n * channel_n.
for us (the first class, and /xi=3):

channels = [channel_1 ,channel_2,...,channel_n]

heatmap_0 = channels[0]
heatmap_1 = channels[1]
heatmap_2 = channels[2]

some details are omitted here

@dongliangchang dongliangchang added the Good issue for better understanding label Aug 6, 2020
@AND2797 AND2797 closed this as completed Aug 6, 2020
@AND2797 AND2797 reopened this Aug 30, 2020
@AND2797
Copy link
Author

AND2797 commented Aug 30, 2020

I was curious if you tried guided gradcam along with gradcam in your experiments?

@dongliangchang
Copy link
Member

No. the attention map attained by the guided gradcam, maybe can used to guidance the MC-Loss.

@AND2797
Copy link
Author

AND2797 commented Sep 1, 2020

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good issue for better understanding
Projects
None yet
Development

No branches or pull requests

2 participants