captum icon indicating copy to clipboard operation
captum copied to clipboard

TracIn: sample_wise_grads_per_batch: add_hooks(model) is not clearly documented

Open felixmeyjr opened this issue 3 years ago • 1 comments

❓ Questions and Help

In the constructor of TracIn is the flag sample_wise_grads_per_batch. In the “main” method _compute_jacobian_wrt_params_with_sample_wise_trick for this trick is the comment, that the user must add_hooks(model) before calling this function. The documentation is not clear because this comment is only in the docstring of that mentioned method. I assume that I need to use add_hooks(model) of autograd-hacks before constructing TracInCP? What happens if I don't add the hooks? Thank

felixmeyjr avatar Jun 30 '22 15:06 felixmeyjr

Hi @felixmeyjr Thank you for pointing this out - you do not need to call add_hooks - that is effectively done for you in _compute_jacobian_wrt_params_with_sample_wise_trick - we apologize for its incorrect documentation and will correct it. In general you do not need to worry about hooks when using TracIn.

99warriors avatar Jul 02 '22 14:07 99warriors