Git Product home page Git Product logo

Comments (5)

fhvilshoj avatar fhvilshoj commented on May 20, 2024

I guess that this is actually a bit cumbersome. One way would be to break the network up into multiple lrp.Sequentials and then use the intermediate outputs to reference their output.grad variables.

It relates to this post about obtaining grads (explanations in our case) and this post about getting intermediate outputs of pretrained networks.

I would be happy to discuss if there is a better way to structure this code such that similar tasks become easier.

from torchlrp.

francescomalandrino avatar francescomalandrino commented on May 20, 2024

hey, thanks for the answer!

yes, "cumbersome" is the right word here!

pull request #3 gets the job done, but it's kind of hack-ish... not sure if there's a better/more elegant way to do it!

from torchlrp.

fhvilshoj avatar fhvilshoj commented on May 20, 2024

I have merged your pull request although I never liked global variables. In this case, however, it does make sense to some extend. Thanks for the contribution!
I will integrate your code a bit more and push an update soon.
In particular, the trace should be done in all backward computations and not only for the Epsilon rule.

from torchlrp.

francescomalandrino avatar francescomalandrino commented on May 20, 2024

The best way would be to pass a list to fill with the trace when calling backward -- that way, we would not need global variables:

tl=[]
y_hat.backward(trace_list=tl)

However, I think backward up there calls PyTrorch's backward first, which then calls your own backward. If this is the case, PyTorch's function will throw a TypeError exception upon seeing the extra parameter.

from torchlrp.

fhvilshoj avatar fhvilshoj commented on May 20, 2024

Yes, this is exactly the issue.

from torchlrp.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.