Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use full backward hook for compatibility with torch >= 1.8.0. #1927

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ShokuninSan
Copy link

Since torch version 1.8.0 using register_backward_hook is deprecated.

On adding gradient handles in PyTorchDeep using torch 1.8.0, we get the following warning:
Using a non-full backward hook when the forward contains multiple autograd Nodes is deprecated and will be removed in future versions. This hook will be missing some grad_input. Please use register_full_backward_hook to get the documented behavior.

@ShokuninSan
Copy link
Author

Hi @slundberg, since torch 1.8.0 we get deprecation warnings for register_backward_hook. At first, it seemed a naive replacement by register_full_backward_hook would do the trick, which is not the case obviously.

The tests fail because no grads are going to be added to the complex_module_gradients anymore and we get this:

    def deeplift_tensor_grad(grad):
>       return_grad = complex_module_gradients[-1]
E       IndexError: list index out of range

Affected tests:

  • test_pytorch_custom_nested_models
  • test_pytorch_single_output
  • test_pytorch_multiple_inputs

Can u please give a hint? Thank you.

@ShokuninSan ShokuninSan marked this pull request as ready for review April 12, 2021 07:59
@SimonKurz
Copy link

Any news here? I'd also like to use the DeepExplainer along with pyTorch.

@ilyes495
Copy link

Any news? I'm stuck at this problem, I hope someone can help me to fix this issue

@ockaro
Copy link

ockaro commented Jun 20, 2023

Are there any news @dsgibbons ?

@dsgibbons
Copy link
Collaborator

dsgibbons commented Jun 20, 2023

@ockaro I briefly tried this PR over at my fork: dsgibbons#94, but it broke some of the tests. I don't know what the problem is yet. At the very least, this PR needs updating to use the latest changes from master.

Since torch version 1.8.0 using register_backward_hook is deprecated.
@jessicapatricoski
Copy link

Are there any updates here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants