kazuto1011 / grad-cam-pytorch

PyTorch re-implementation of Grad-CAM (+ vanilla/guided backpropagation, deconvnet, and occlusion sensitivity maps)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How with Grad-CAM in my own model

yyssmm opened this issue · comments

Hi,
Thank you for sharing your work! I meet a problem when use Grad-CAM with my own model that have no FC classifier layer and no softmax layer. Would you please help me how to deal with it? Thank you very much!

  1. Define the score for which you want to investigate the causality. In the original Grad-CAM, the score is arbitrary class logit before softmax is applied.
  2. Extract the intermediate feature maps in the forward propagation.
  3. Compute gradients of the score with respect to the feature maps.
  4. Weight the feature maps by the gradient magnitudes.