-
Notifications
You must be signed in to change notification settings - Fork 32
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
Layer-wise LRP score #167
Comments
Hey Shivam, check out out the documentation, there is a section on how-to extract the attribution scores per layer. |
Thanks Christopher for the documentation. I can now obtain activation gradients for each intermediate layer. Is it possible to get relevance scores for weight matrices in each layer in a similar fashion? I want to quantify the relevance/importance of each weight value. |
Hey Shivam, turns out it is currently a little more involved to do in Zennit. Since yesterday I have looked a bit deeper into how this could be done in a more general way in Zennit, and decided to change the Hook implementation in such a way that the attribution scores for multiple inputs and parameters can be computed. Feel free to play around with the implementation and report any problems that you get. import torch
import zennit
from torchvision.models import vgg11
# model = torch.nn.Linear(4, 4).eval()
model = vgg11().eval()
data = torch.randn(1, 3, 224, 224, requires_grad=True)
# composite = zennit.composites.NameMapComposite([([''], zennit.rules.Epsilon())])
composite = zennit.composites.EpsilonPlusFlat()
with composite.context(model):
out = model(data)
# relevance, = torch.autograd.grad(out, data, torch.ones_like(out))
out.sum().backward()
print(model.features[0].weight.grad) Edit: You can try it out directly by installing from github using pip: $ pip install git+https://github.com/chr5tphr/zennit.git@hook-multi-input-param |
Hi @chr5tphr , thank you for providing this feature. I have been working with this version of Zennit to get relevance scores for w.r.t parameters. However, when using a ResNet20 architecture, I encounter the following error which I cannot really explain:
originating from |
Hey @MaxH1996 I noticed I forgot to add the |
Hey @chr5tphr, thank you very much for you response, and your quick fix of Too bad about ResNet, but thanks for taking the time to work on it. Could you perhaps let me know when you fixed this particular issue? That would help me a lot. |
Hi,
Thanks a lot for the awesome work! May I know how I can extract layer-wise LRP attribution scores for ResNet-18?
The text was updated successfully, but these errors were encountered: