Giter Site home page Giter Site logo

Comments (2)

mfkasim1 avatar mfkasim1 commented on June 12, 2024

Hi, thanks for raising the issue. This type of bugs usually occurs when a dependency on a variable disappear in the first grad. For example, if the function is f = a*x+b, the derivative df/da=x which does not depend on a nor b. In that case, taking the second derivative w.r.t. a or b will raise that error. The fix from the xitorch side is just to set allow_unused=False, but you can also do a workaround by adding more dependency on the vars, e.g., f = a*x + b + a^2*0 + b^2*0

from xitorch.

floatingCatty avatar floatingCatty commented on June 12, 2024

Hello, thanks for your help, but I noticed that here dfdy somehow is related to V, since variables V in xitorch is used to calculated the dfdy, as realized in jachess:
Here for dfdy,
with torch.enable_grad():
yout = fcn(*params) # (*nout)
v = torch.ones_like(yout).to(yout.device).requires_grad_() # (*nout)
dfdy, = torch.autograd.grad(yout, (yparam,), grad_outputs=v, create_graph=True) # (*nin)

and for grad to v.
for i in range(nbatch):
dfdyf, = torch.autograd.grad(dfdy, (v,), grad_outputs=gy1[i].reshape(self.inshape),
retain_graph=True, create_graph=torch.is_grad_enabled()) # (*nout)
I cannot figure out why here the second derivative to v is unavailable. Since v is not explicit available to fcn function, adding dependencies seems difficult to conduct. Is there anything I can do for this?

Thanks again for helping!

from xitorch.

Related Issues (18)

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.