Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

Grad CAM Eval Mode #11

Open
dkosm opened this issue May 4, 2020 · 1 comment
Open

Grad CAM Eval Mode #11

dkosm opened this issue May 4, 2020 · 1 comment

Comments

@dkosm
Copy link

dkosm commented May 4, 2020

Hi,

thank you very much for the nice library. Some very useful implementations to current Saliency methods :)

This may be more a suggestion rather than an issue, but well let's get into it:

My version: torchray 1.0.0.2

As with all torch ray methods, the Grad Cam implementation supports two versions, "simple" and "manual".
During usage of the simple version, the convenient
torchray.attribution.grad_cam.grad_cam(*args, saliency_layer, gradient_to_saliency=, **kwargs) method is used, which itself returns results from torchray.attribution.common.saliency(). This saliency method correctly puts the model in eval mode and everything goes as planned.

On the other hand, the "manual" version uses:
get_example_data()
get_module()
Probe()
gradient_to_grad_cam_saliency()

taken from torchray.attribution.common and torchray.attribution.grad_cam. Going with the example model from get_example_data(), everything is fine, too, since the model is put to eval() mode before being returned be get_example_data. Though, if one wishes to use their own trained models, this change to eval() mode has to happen manually, since it is not done by any method/class used in the "manual" version, namely get_module, Probe, gradient_to_grad_cam.
Only the nice wrapper methods like e.g., gradient_to_grad_cam_saliency ,which use the saliency() method, handle this for the user.

Although, knowledge about the necessity of changing your model to eval mode is something that could be expected by most torch users, it might be helpful to display this info in combination with the "manual" versions, more prominent inside the docs. A way of doing this could be a warning/note next to the "manual" methods. This might helpful to new users of torchray.

I hope I did not miss something inside the docs about this very topic.
Keep up the nice work and thanks for this lib!

@ruthcfong
Copy link

@dkosm Thanks for this suggestion; I'm currently writing up my thesis but we will update the docs accordingly once I've submitted.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants