fhvilshoj / TorchLRP

A PyTorch 1.6 implementation of Layer-Wise Relevance Propagation (LRP).
MIT License
125 stars 26 forks source link

LRP for unet with upsample or ConvTranspose2d layer model #6

Closed bugsuse closed 3 years ago

bugsuse commented 3 years ago

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!

fhvilshoj commented 3 years ago

Hi, That sounds interesting. How do you expect to use LRP on UNet? LRP is mostly intended to explain one output neuron at time, but UNet has as many output neurons as inputs, so it is not immediately apparent what your intention is? A few words on your idea would be helpful.

You could easily implement both Upsample and ConvTranspose functionality similar to how, e.g., convolution is implemented in the lrp.functional.conv.py. I even think that you can omit implementing Upsample, as standard gradient computations should be sufficient.

bugsuse commented 3 years ago

@fhvilshoj Thanks a lot! I'd like to explain the impact of intermediate layers of UNet using LRP. I will try it follow your suggestion!