Hey @djpecot, sorry for the delay. My code at the moment is kinda dependent on Resnet structure, and vgg19 structure is vastly different but all you need to provide is a target layer so that the gradient can be calculated with respect to this layer. For vgg19 you can choose this layer in learn.model[0] aka the vgg body, e.g. learn.model[0][-1]
is the last layer of the body (AdaptiveAvgPool2d) or learn.model[0][0][52]
is the layer right before the AdaptiveAvgPool2d. In fact you have 53 layers to do some experiments on
To fix the error above you need to go into gradcam.py and manually edit the line at 152 by putting in the layer of your choice, e.g. target_layer = m[0][-1]
or target_layer = m[0][0][52]
. It works on my end so I bet it works on yours too.