Skip to content

Issue with computing Hessian vector products using gradients obtained via hooks in PyTorch #261

Answered by caihuaiguang
caihuaiguang asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @frgfm,

I want to let you know that I have resolved the issue. The reason the self.hook_g.grad_fn was None was that I was inputting layer4 as the value of target parameter instead of specifying a particular layer. The following command worked fine:

 python scripts/cam_example.py --savefig "./resnet18_layer4_1_conv2" --arch resnet18  --target layer4.1.conv2 --rows 1

Additionally, I have observed a phenomenon in my experiments: when the target layer is set to conv2 (the layer before batch normalization), some CAM methods do not seem to perform well. Is this behavior normal?

As a contradiction, the output when using layer4.1.bn2 is:

Thank you for your assistance!

Best regards

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@caihuaiguang
Comment options

Answer selected by caihuaiguang
Comment options

You must be logged in to vote
1 reply
@caihuaiguang
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants