Skip to content

Doubt about Grad-CAM++ weights computation #2

@lucasdavid

Description

@lucasdavid

Hello!
Thanks for the repository. Very pretty code and I'm learning a lot from it :-)

I have a question about the way you implemented Grad-CAM++.
More specifically, in the denominator computation at cam.py#L220:

ag = activations * gradients.pow(3)
denominator += ag.view(n, c, -1).sum(-1, keepdim=True).view(n, c, 1, 1)

So, if I understood correctly, you are:

  1. weighting each element of the gradient matrix gradients.pow(3) by the pixel activation activations
  2. sum over each pixel, for each channel

However, in the article, the authors state that the sum indices are not the same as the indices in the partial derivative (attached image). I assumed that meant we should first sum all activations and then multiply by the grads^3.

Am I missing something here?
Thank you very much!

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions