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

AttributeError: 'NoneType' object has no attribute 'relevance_input' #1238

Open
Pei4579 opened this issue Feb 2, 2024 · 4 comments
Open

Comments

@Pei4579
Copy link

Pei4579 commented Feb 2, 2024

I'm using LRP for my resnet model by loading in .pth file. However, it raises "AttributeError: 'NoneType' object has no attribute 'relevance_input'" while I'm trying to apply the following code.
lrp = LRP(down_model)
attribution = lrp.attribute((use1, use2), target = np.argmax(dataset[a][-1]))
I've checked the type of everything is the same as the tutorial you provided, the only difference is the model, but the model works well when I apply it to Saliency as the following code:

saliency = Saliency(down_model)
attribution = saliency.attribute((use1, use2), target = np.argmax(dataset[a][-1]))

Thanks in advance!

@YUN-MAN
Copy link

YUN-MAN commented Feb 2, 2024

I had same problem 😬😬

@krebso
Copy link

krebso commented Feb 6, 2024

Hello there, do you set the rules beforhand? If you are using custom layers, this might be an issue. From docs - Custom rules for a given layer need to be defined as attribute module.rule and need to be of type PropagationRule.

@Pei4579
Copy link
Author

Pei4579 commented Feb 8, 2024

Thanks for the quick reply.
Yes, I found that the rule is the key to solving.
Should I write a new rule similar to the Propagation Rule for replacing it or do I need to modify the source code? Do you have any custom model rules samples or example experiments for reference?
Thanks!

@krebso
Copy link

krebso commented Feb 14, 2024

Hey, I used composite LRP from this paper for VGG-16. Both Gamma and Epsilon rule are part of captum and I did not bother with the input layer rule yet. I ended using AlphaBeta in the end, instead of the Gamma tho.

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

3 participants