How to implement Grad-CAM on my model instead of VGG?

Hi,

I’ve found a lot of different examples of implementing Grad-CAM on VGG or other pre-trained models in torchvision, and I want to integrate it with my own trained model in order to visualize the feature importance. But the example code all used features and classifier method in VGG, which my model does not have. Is there any way to do it without having these two methods? Because I don’t want to retrained the model again.

    self.model.features.zero_grad()
    self.model.classifier.zero_grad()

Thanks

Hi, I made this simple example based on this post.