sicara / tf-explain

Interpretability Methods for tf.keras models with Tensorflow 2.x
https://tf-explain.readthedocs.io
MIT License
1.02k stars 110 forks source link

update the grad_cam to return gradient masks similar to other methods #104

Closed ghazalee70 closed 4 years ago

ghazalee70 commented 4 years ago

Current implementation of gradcam returns the image overlayed by gradient mask and not following the same structure as the other methods (e.g. smooth_grad or intergrated_grad) in which the actual gradient masks are created as the output. As such, to keep it all following the same standard and usable in the same manner, I have adapted the grad_cam function so that the output is the gradient mask if the weight is set to 0. If one desires to have it as the current implementation, the weight value can be set to 0.7 as before.

RaphaelMeudec commented 4 years ago

Thanks for your PR! Indeed there's an issue at the moment, because the attribution maps is merged with the input image and does not let the user decide what to do with it. However, setting image_weight to 0 automatically prevent the visualization from building. We probably want to add image_weight as argument of the grad cam method also (with a default value to 0.7 as it is today), so user can choose either to apply on input or not.

RaphaelMeudec commented 4 years ago

@ghazalee70 Can you update the docstring of grad cam accordingly (new argument image_weight)? Sorry for the trouble, last step so I can merge it!

RaphaelMeudec commented 4 years ago

@ghazalee70 Thanks for the PR!