Open jscott-gauss opened 1 year ago
Have the same problem with a binary classifier with the fully connected output layer of size (B, 1), when I select this layer as the target, in combination with BinaryClassifierOutputTarget.
If I use the last convolution layer in the model before FC layers, it works. Also it works if I resize the output to (B, 1, 1, 1), but it produces meaninless heatmaps.
Looks like grad-cam expects spatial dimensions in the output. But according to the paper: our approach is a generalization of CAM [59] and is applicable to a significantly broader range of CNN model families: (1) CNNs with fully-connected layers (e.g. VGG).
Or am I doing something wrong? What is the right way of handling fully connected layers?
I meet the same question, do you solve it? thanks
Related issues: https://github.com/jacobgil/pytorch-grad-cam/issues/254 https://github.com/jacobgil/pytorch-grad-cam/issues/394 (maybe)
Model is
resnest14d
fromtimm
and I am regressing to a single scalar valueDebugger printout input args right before here: https://github.com/jacobgil/pytorch-grad-cam/blob/2183a9cbc1bd5fc1d8e134b4f3318c3b6db5671f/pytorch_grad_cam/grad_cam.py#L16
Stack Trace