Using Class Activation Maps (CAM) for visualization

(Arka Sadhu) #1

I wrote a small notebook on how to go about visualizing CAM here https://github.com/TheShadow29/FAI-notes/blob/master/notebooks/Using-CAM-for-CNN-Visualization.ipynb

It also covers when you have a hidden layer after the Adaptive Concat Pooling. Grad-CAM work is still in progress.

Cheers!

9 Likes

(Benoit) #2

Thank you @TheShadow29 I use your code to do the same things with ResNext50 : https://github.com/trancept/deep_learning_tests/blob/master/015-HeatMap.ipynb

1 Like

(Arka Sadhu) #3

Nice. I will add a link to this in my repo as well :slight_smile:

0 Likes

(Bumblebee) #4

Hi @Benoit_c / @TheShadow29 ,

I have one query regarding class activation maps. If i have a trained model which was initialized using convlearner.pretrained. Now i can load the saved model replace the last layers as per cam and then train the last layers. Is this okay ? or the idea is to retrain the whole network with modified last layers? looking forward to your response.

-bumblebee

0 Likes

(Arka Sadhu) #5

I am not sure unfortunately. I think you can use grad-cam https://arxiv.org/pdf/1610.02391.pdf instead of replacing the last layers.

0 Likes

(Bumblebee) #6

ok. cool. Thanks for prompt response. So need to do a small poc on that part. @Benoit_c any thoughts on this?

Apart from that have you been able to do a small poc on Grand Cam ?

0 Likes

(Benoit) #7

Hi, sorry, I have to retrained the whole model. It will be better if we could visualize an existing model…

0 Likes

#8

@TheShadow29, thanks a lot for sharing the code. I was trying to visualize CAM for a WideResNet model but was facing some issues in the same. Unlike Resnet, the dimensions of the fully connected layer and the last convolutional layer don’t match in the Wideresnet_50 model and hence, taking a matrix product is impossible.

Any idea on how do we go about visualizing CAM for a Wideresnet_50 model? Is it even possible?

0 Likes