Git Product home page Git Product logo

Comments (4)

ezyang avatar ezyang commented on June 30, 2024

Does it work if you use vmap instead, by any chance

from pytorch.

TheotimeLH avatar TheotimeLH commented on June 30, 2024

I'm sorry but I don't know how to use vmap instead;
I tried to vmap the autograd call, but, as stated by https://pytorch.org/tutorials/intermediate/jacobians_hessians.html << We can’t directly apply vmap to torch.autograd.grad; instead, PyTorch provides a torch.func.vjp>>

But apparently torch.func.vjp is designed to build the Jacobian but it runs the forward too.
Whereas my function is non deterministic, so I don't want to (re)run the forward to compute this autograd.grad.

Also, I tried both Cpu and Cuda,
BatchNorm and InstanceNorm work,
Only GroupNorm fails

from pytorch.

soulitzer avatar soulitzer commented on June 30, 2024

Is it possible to avoid running forward the first time? vjp returns both the forward output and the gradients.

from pytorch.

zou3519 avatar zou3519 commented on June 30, 2024

But apparently torch.func.vjp is designed to build the Jacobian but it runs the forward too.
Whereas my function is non deterministic, so I don't want to (re)run the forward to compute this autograd.grad.

You can use torch.func.vjp to run the forward once. It gives you a callable that can be used to run the backward. The idea is to vmap over said callable (this avoids re-running the forward).

from pytorch.

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.