I am studying CNN visualization and understanding, with saliency map.
I use this tutorial from mxnet to performs Grad CAM and get the saliency maps :
everything fine, I also test it with a densenet network.
But now, what I want to do is for a given class (any of the 1000 from Imagenet), I want to get the saliency map for that class.
For example, even if I have a photo of a dog, I want the saliency map of what it could recognize as a cat. (Even if it’s not there and yes, of course, this is better on images where both cat and dog are, but anyway)
Like in this paper, they can chose the saliency map for cat lass or dog class :
In gradcam.py (from the link above), there is a “class_id” attribute for _get_grad method. I modify it to take a class_id that I choose instead of the class_id predict from the image, then the one_hot Ndarray is created from that class_id, but the saliency map is very similar (there is no visual difference, but I saw values of th saliency map and they differ slightly…)
If you want the code that I modify to better understanding, tell me.
What can I do to have saliency map for every class that I choose ?