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
@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.
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?
yeah, we could add the flag. cc: @vivekmig
Hi @vipinpillai, thanks for the feedback, adding the argument here #181.
Thanks @vivekmig
Closing this since it got fixed by: #181
Most helpful comment
Hi @vipinpillai, thanks for the feedback, adding the argument here #181.