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

Add support for Tuples of Modules in LayerLRP #1329

Open
Quoding opened this issue Aug 15, 2024 · 0 comments
Open

Add support for Tuples of Modules in LayerLRP #1329

Quoding opened this issue Aug 15, 2024 · 0 comments

Comments

@Quoding
Copy link

Quoding commented Aug 15, 2024

🚀 Feature

It seems to me there is no reason why LayerLRP is restricted to lists only. It seems any ordered iterable should do the trick here. I would like us to be able to run LayerLRP with a tuple directly.

Motivation

This avoid a confusing error I encountered, namely:

  File "/home/allar/code/gfn-explain/scripts/experiments/complex_nn/inception/r_captum.py", line 74, in main
    layer_vals = layer_explainer.attribute(
  File "/home/allar/.pyenv/versions/gfn/lib/python3.10/site-packages/captum/attr/_core/layer/layer_lrp.py", line 233, in attribute
    relevances = self._get_output_relevance(output)
  File "/home/allar/.pyenv/versions/gfn/lib/python3.10/site-packages/captum/attr/_core/layer/layer_lrp.py", line 282, in _get_output_relevance
    return self._get_single_output_relevance(self.layer, output)
  File "/home/allar/.pyenv/versions/gfn/lib/python3.10/site-packages/captum/attr/_core/layer/layer_lrp.py", line 258, in _get_single_output_relevance
    normalized_relevances = layer.rule.relevance_output
AttributeError: 'tuple' object has no attribute 'rule'

Pitch

Simply add checks / modify the if statements of the class where there is a type check for list to account for tuples also.

Alternatives

N/A

Additional context

N/A

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

No branches or pull requests

1 participant