Hello,
I am sure this is a trivial problem . I am trying to get the activation map on the final conv layer for an image in validation set while following lesson 18 for grad CAM. Here is the error;
1
w = grad[0].mean(dim=(1,2), keepdim=True)
2
gradcam_map = (w * act[0]).sum(0).detach().cpu()
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-79-76f83767f6d3> in <module>
----> 1 w = grad[0].mean(dim=(1,2), keepdim=True)
2 gradcam_map = (w * act[0]).sum(0).detach().cpu()
IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)
For info i have 8 classes so, my grad[0]:
grad[0]
tensor([0., 1., 0., 0., 0., 0., 0., 0.], device='cuda:0')
So what should I set my dim to? I set it to dim=(8,9) which is what I had expected it to be but it didn’t work.
Thanks!