Optax is a gradient processing and optimization library designed for JAX. It provides a rich set of optimizers (Adam, SGD, etc.), learning rate schedules, and gradient transformations that can be composed to build custom optimization pipelines. It's actively developed by DeepMind/Google, with the current stable version being 0.2.8, and follows a release cadence tied to JAX ecosystem developments, often releasing minor versions for bug fixes and new features.
pip install optax jax jaxlibVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a basic training loop with Optax and JAX. It defines a simple linear model and a mean squared error loss. An Adam optimizer is initialized, and a `train_step` function is created, leveraging `jax.grad` to compute gradients and Optax to apply updates. The `train_step` is `jax.jit`-compiled for efficiency. The loop iteratively updates parameters and optimizer state to minimize the loss.
Ensure your `optimizer.update` calls pass the current model parameters as the third argument. If you're coming from an older version, add `params` to your `update` function signature.
Always reassign the optimizer state and parameters after calling `optimizer.update` and `optax.apply_updates` respectively, as demonstrated in the quickstart example.
Ensure that your model parameters and the gradients produced by `jax.grad` are consistent PyTree structures. When composing optimizers or transformations, confirm that intermediate results maintain PyTree compatibility.
No dependency data recorded yet.