Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relu missing in implementation of LayerGradCam.attribute() #179

Closed
vipinpillai opened this issue Nov 19, 2019 · 6 comments
Closed

Relu missing in implementation of LayerGradCam.attribute() #179

vipinpillai opened this issue Nov 19, 2019 · 6 comments
Assignees
Labels
question Further information is requested

Comments

@vipinpillai
Copy link

I was looking at the code in grad_cam.py for LayerGradCam.attribute() and noticed that there is no Relu operation applied after computing the summed_grads * layer_eval here: https://github.com/pytorch/captum/blob/master/captum/attr/_core/layer/grad_cam.py#L177

@NarineK
Copy link
Contributor

NarineK commented Nov 20, 2019

@vipinpillai, we did it on purpose in order to be more flexible and show negative attribution as well. See doc: https://github.com/pytorch/captum/blob/master/captum/attr/_core/layer/grad_cam.py#L47
You need to apply relu externally if you need to.

@NarineK NarineK added the question Further information is requested label Nov 20, 2019
@vipinpillai
Copy link
Author

Thanks @NarineK. I got confused because of the return variable being named non_neg_scaled_act.

I think it might be confusing for anyone expecting a GradCAM visualization from this API without explicitly applying relu. Wouldn't it be better to have an argument specifying whether the caller needs a relu / non-relu version of the attribution?

@NarineK
Copy link
Contributor

NarineK commented Nov 20, 2019

yeah, we could add the flag. cc: @vivekmig

@vivekmig
Copy link
Contributor

Hi @vipinpillai, thanks for the feedback, adding the argument here #181.

@vipinpillai
Copy link
Author

Thanks @vivekmig

@NarineK
Copy link
Contributor

NarineK commented Nov 30, 2019

Closing this since it got fixed by: #181

@NarineK NarineK closed this as completed Nov 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants