Git Product home page Git Product logo

Comments (3)

AlexeyKurakin avatar AlexeyKurakin commented on May 18, 2024
  1. Compute Jacobian.

You can reimplement object-oriented version of jacfwd or jacrev similarly how objax.GradValues is implemented.

Another option is to use combination of objax.Vectorize and objax.GradValues, in other words vectorize computation of gradient. DPSGD gradient module to some extend does it:

def _make_clipped_grad_fn_simple(self, f: Callable, gv: GradValues, vc: VarCollection) -> Callable:

  1. Why not mixing JAX and Objax

You can not use functional jax transformations with Objax (like jax.vmap, jax.pmap, jax.grad, etc...). In other words those transformations which takes function and returns a new function.
You can use other jax operations (for example all stuff from jax.numpy.*) safely with Objax.

All JAX primitives are stateless and pure functional (i.e. don't have and don't assume side-effects). Objax provides wrappers for JAX primitives to simplify state management and make is more natural for machine learning applications.

So if you try to mix JAX functional tranformations with Objax primitives it will break the state management and either code won't work at all or will work incorrectly.

  1. Difference between JAX and Objax primitives

As I mentioned above, Objax provides wrappers which simplify state management.
So for example objax.Vectorize is a wrapper over jax.vmap which does the state management and enables usage of stateful Objax primitives with stateless JAX.

from objax.

smao-astro avatar smao-astro commented on May 18, 2024

I see, thank you for your explanation!

from objax.

chaoming0625 avatar chaoming0625 commented on May 18, 2024
  1. Compute Jacobian.

You can reimplement object-oriented version of jacfwd or jacrev similarly how objax.GradValues is implemented.

It is hard to implement object-oriented version of jacfwd or jacrev, because jacfwd or jacrev do not support return auxiliary data. Is there solution? Thanks!

from objax.

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.