Comments (5)
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.
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.
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.
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.
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)
- VGG16 can't assist with plain CAM? HOT 2
- IS-CAM formula error? HOT 4
- Error when clearing hooks HOT 1
- self._normalize() got NAN... HOT 7
- What is class_idx in __call__() ?? HOT 6
- What are the requirements of the model by using these visual code? HOT 10
- [demo] Automate deployment to HF Spaces
- Upcoming support for new CAM methods
- Release tracker - v0.5.0
- More NaNs HOT 7
- didn't find remove_hooks() in cam_extractor HOT 2
- RuntimeError: 'cannot register a hook on a tensor that doesn't require gradient' HOT 7
- Remove hooks once we're done with CAM extractors
- use torch-cam/scripts/cam_example.py throw a exception: HOT 5
- target_layer path error HOT 3
- Does torch-cam still support 3D resnet model? HOT 3
- SmoothGradCAMpp returning GRAD CAM with NANs for some images, not all HOT 3
- How to get CAM for custom 3D model? HOT 19
- RuntimeError: cannot register a hook on a tensor that doesn't require gradient HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from torch-cam.