fhvilshoj / torchlrp Goto Github PK
View Code? Open in Web Editor NEWA PyTorch 1.6 implementation of Layer-Wise Relevance Propagation (LRP).
License: MIT License
A PyTorch 1.6 implementation of Layer-Wise Relevance Propagation (LRP).
License: MIT License
Is there a simple (or simple-ish) way to obtain the relevance scores of hidden layers, i.e., what is visualized in the cell starting with "for i,l in enumerate([31,21,11,1]):" here?
https://git.tu-berlin.de/gmontavon/lrp-tutorial
The library sure computes them, but I could not find a way to recover those. Thanks!
Is there a way to get the relevance of model parameters, in addition to the inputs (and intermediate results) thereof?
The PLOS paper ("On Pixel-Wise Explanations for Non-Linear Classifier Decisions by Layer-Wise Relevance Propagation") mentions per-neuron relevance conservation, hence, I assume it would make sense to keep track of the incoming (or outgoing) relevance of each neuron (and, more generally, each DNN parameter), and make that accessible to the users of the library.
Does that make sense? Thanks!
I want to use LRP to explain the semantic segmentation task using Unet model (Pytorch). I tested the LRP in captum but not support nn.Upsample and nn.ConvTranspose2d. I would like to know if the semantic segmentation model like Unet can be supported, and if not, how should it be implemented? Any help would be appreciated!
I just found an issue with the resnet conversion. Since the backward function has not been rewritten the size of the tensors are inconsistent.
Thank for your works!
I see that you implement LRP for vgg model. But vgg is simple model with single Sequential and does not have residual connection. Could you help me to implement LRP for complex model, such as ResNet?
Thank you so much!
I implemented the excellent scripts and found that conv_transpose2d does not work properly for my own work. So I updated it in functional.conv line27 as follows:
# relevance_input = F.conv_transpose2d(relevance_output, weight, None, padding=1)
if ctx.stride[0] >= 2:
output_padding = 1
else:
output_padding = 0
relevance_input = F.conv_transpose2d(relevance_output, weight, None, stride=ctx.stride, padding=ctx.padding, output_padding=output_padding)
and also here:
def f(X1, X2, W1, W2, ctx):
# Z1 = F.conv2d(X1, W1, bias=None, stride=1, padding=1)
# Z2 = F.conv2d(X2, W2, bias=None, stride=1, padding=1)
Z1 = F.conv2d(X1, W1, None, ctx.stride, ctx.padding, ctx.dilation, ctx.groups)
Z2 = F.conv2d(X2, W2, None, ctx.stride, ctx.padding, ctx.dilation, ctx.groups)
Z = Z1 + Z2
rel_out = relevance_output / (Z + (Z==0).float()* 1e-6)
# t1 = F.conv_transpose2d(rel_out, W1, bias=None, padding=1)
# t2 = F.conv_transpose2d(rel_out, W2, bias=None, padding=1)
if ctx.stride[0] >= 2:
output_padding = 1
else:
output_padding = 0
t1 = F.conv_transpose2d(rel_out, W1, None, stride=ctx.stride, padding=ctx.padding, output_padding=output_padding)
t2 = F.conv_transpose2d(rel_out, W2, None, stride=ctx.stride, padding=ctx.padding, output_padding=output_padding)
r1 = t1 * X1
r2 = t2 * X2
return r1 + r2
Not sure if this is my own issue, but the above change fixed my problem.
HI. Thank you for your great work !
I have a question that Do you apply rho and incr function for weights of layer while calculate in forward ?
Thank you so much !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.