jacobgil / keras-grad-cam

An implementation of Grad-CAM with keras
MIT License
658 stars 237 forks source link

Optimization and refactoring #13

Open eclique opened 6 years ago

eclique commented 6 years ago

Hi @jacobgil Thanks for sharing the code. I've been working with it and here's a version I ended up with. Please feel free to edit it and correct me if my reasoning if wrong.

Here's a list of major changes:

There are some minor optimizations, such as computing GradCAM with dot product instead of the loop, accessing model's layer directly by it's name.

One difference with the paper that remains is l2-normalization in grad_cam. I believe authors didn't use it, but I kept it, because it helped in my case.

Modules versions: keras (2.0.8), tensorflow (1.3.0)