Code Monkey home page Code Monkey logo

Comments (3)

papamarkou avatar papamarkou commented on August 16, 2024

P.S. What I don't understand very well yet, after reading the documentation, is whether GradientConfig can help make my above example more efficient in some way.

from reversediff.jl.

papamarkou avatar papamarkou commented on August 16, 2024

If I understand things well, it seems that it is impossible to use a tape indeed in this example, simply because the tape needs to change at each re-evaluation (iteration in my own loop), but still, I can at least exploit GradientConfig, as follows:

rcfg = ReverseDiff.GradientConfig(x);

z.a = 4.9;

ForwardDiff.gradient!(fresult, f, x);

ReverseDiff.gradient!(rresult, f, x, rcfg);

DiffBase.value(fresult)
DiffBase.value(rresult)

DiffBase.gradient(fresult)
DiffBase.gradient(rresult)

Although a tape wouldn't be of use in this situation, using GradientConfig avoids some re-allocation at least. If this is correct, maybe we can close the issue. Thanks for the support and advice.

from reversediff.jl.

jrevels avatar jrevels commented on August 16, 2024

The naive answer is no at the moment; I believe this issue is a dupe of #36. For now, you either have to re-record every time (which you can do with a pre-allocated GradientConfig to save a little bit of memory) or include the parameters you don't actually care about in the differentiation.

Note that in your original example, you're using a custom type; it's not likely that we'll ever be able to support pre-recording with non-array/non-scalar types unless Julia allows getfield overloading.

Closing as a dupe of #36.

from reversediff.jl.

Related Issues (20)

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.