Hello,
I am sure this is a trivial problem . I am following a tutorial for grad CAMS  which is a binary classification problem. I have 8 classes so my dimensions are different:
grad[0]

tensor([0., 1., 0., 0., 0., 0., 0., 0.], device='cuda:0')

I set my dim to (8,9) which is what I had expected it to be but it didn’t work. If i change the dim to this < or leave it as default from tutorial, I get the following 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)

So what should I set my dim to?
Thanks!