pytorch/captum

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

Pei4579 opened this issue · 4 comments

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!

I had same problem 😬😬

krebso commented

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.

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!

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.