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

LayerDeepLift Hook Fix #415

Closed
wants to merge 4 commits into from
Closed

Conversation

vivekmig
Copy link
Contributor

This avoids adding a hook to the target layer non-linearity when using LayerDeepLift if attributing with respect to layer output. This fixes an issue with in-place modules caused by skipping cloning and adds a corresponding test case.

@vivekmig vivekmig requested a review from NarineK June 24, 2020 21:56
Copy link
Contributor

@NarineK NarineK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Minor, naming suggestion

@@ -496,8 +496,10 @@ def _can_register_hook(self, module: Module) -> bool:
or not self._is_non_linear(module)
)

def _register_hooks(self, module: Module) -> None:
if not self._can_register_hook(module):
def _register_hooks(self, module: Module, skip_target_layer: bool = False) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: target layer can be confusing because we also have target output. Perhaps, we can use the same naming for attributing to input or output. attribute_to_layer_input=True

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vivekmig has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vivekmig has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vivekmig has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@vivekmig merged this pull request in 9bcf257.

NarineK pushed a commit to NarineK/captum-1 that referenced this pull request Nov 19, 2020
Summary:
This avoids adding a hook to the target layer non-linearity when using LayerDeepLift if attributing with respect to layer output. This fixes an issue with in-place modules caused by skipping cloning and adds a corresponding test case.
Pull Request resolved: pytorch#415

Reviewed By: edward-io

Differential Revision: D22241851

Pulled By: vivekmig

fbshipit-source-id: 771a7cbb3cf77438bba901237defe937a26c415c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants