Giter Club home page Giter Club logo

Comments (5)

Fu0511 avatar Fu0511 commented on June 3, 2024 1

Thank you for your attention to our work.
Since resnet18 is a GAP-CNN whose penultimate layer is a global average pooling (GAP) layer, it is natural that Grad-CAM and XGrad-CAM achieve the same performance on resnet18. The reason has been described in our paper, it can be proved that Grad-CAM and XGrad-CAM are exactly the same in the case of GAP-CNNs (refer to Appendix C for the detailed proof). For the visualization of other models such as VGG16, our XGrad-CAM outperforms the Grad-CAM.
The significance of our paper is providing a clear mathematical explanation to fill the gap in interpretability for CAM visualization methods.
Hope that explanation helps.

from torch-cam.

frgfm avatar frgfm commented on June 3, 2024

Hey @lars-nieradzik 👋

Thanks for notifying me! I think you are correct actually. In the paper, I used equations 7 and 8. But I didn't take equation 5 into account correctly.

I'm not entirely sure how to do this here! Perhaps the author @Fu0511 could enlighten us?

Here is how Grad CAM weight is computed:

grad.flatten(2).mean(-1)

and here is how XGradCAM weight is computed:

(grad * act).flatten(2).sum(-1) / act.flatten(2).sum(-1).add(eps)

But how do we integrate equation 5 in there?

Cheers!

from torch-cam.

frgfm avatar frgfm commented on June 3, 2024

Thanks a lot @Fu0511 🙏
One question though: in the paper, the XGradCAM weight expression above is implementing equation 7 & 8, assuming that Sc is the output score for class c. Is that correct? (cf. your first paragraph in section 3.1)
Is that's the case, I think the implementation stands

Now I remember yes, and I tried the same snippet @lars-nieradzik with vgg16, the difference is marginally bigger. So it looks like this makes sense.

from torch-cam.

Fu0511 avatar Fu0511 commented on June 3, 2024

Yes, that is right.
The weight of each feature map in XGrad-CAM is defined as a weighted average of its gradients by solving an optimization problem, while Grad-CAM uses the arithmetic average.

from torch-cam.

frgfm avatar frgfm commented on June 3, 2024

Thanks for the clarifications 🙏
Closing the issue then, feel free to reopen if you encounter a problem @lars-nieradzik 👌

from torch-cam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.