pytorch / captum

Model interpretability and understanding for PyTorch
https://captum.ai
BSD 3-Clause "New" or "Revised" License
4.8k stars 485 forks source link

Documentation on `baseline` argument in DeepLiftShap #34

Closed AvantiShri closed 4 years ago

AvantiShri commented 4 years ago

Hi all,

Thank you so much for the invitation to captum. Very grateful to all of you for putting this together! I had a quick question regarding the documentation. Currently, in the arguments description for DeepLiftShap, it says "The first dimension in baseline tensors defines the distribution from which we randomly draw samples" (https://github.com/pytorch/captum/blob/6447777f8f63be7994feb031a3872d87dab5d972/captum/attr/_core/deep_lift.py#L313). However, when I look at the code, it seems as though all the baselines are used for all the inputs (i.e. I'm not seeing any code that I would associate with sampling). Is my understanding correct? I actually prefer the deterministic behavior because in my lab we typically supply multiple baselines per input and we want all the baselines to be used.

Thanks, Avanti

NarineK commented 4 years ago

Hi Avanti, thank you very much for looking into the codebase. It is a mistake in the documentation. For DeepLift it uses all input baselines provided in the argument. In fact we can also support function as a baseline in the future.

I copied the documentation from GradientShap, where it does draw from the distribution and forgot to fix it. Thank you for pointing out to it :)

AvantiShri commented 4 years ago

Ah a function as a baseline would be an awesome feature because in our lab we generate the baselines dynamically by shuffling each input sequence. Thank you!