Captum: Relu missing in implementation of LayerGradCam.attribute()

Created on 20 Nov 2019  路  6Comments  路  Source: pytorch/captum

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

question

Most helpful comment

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

All 6 comments

@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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mostafaalishahi picture mostafaalishahi  路  4Comments

asalimih picture asalimih  路  5Comments

elboyran picture elboyran  路  5Comments

yanbek picture yanbek  路  5Comments

AvantiShri picture AvantiShri  路  5Comments