A gradient processing and optimization library in JAX.
Actively maintained. Last release 3 weeks ago, commits in 23 of the last 26 weeks. A safe choice.
pip install optaxOptax
Introduction
Optax is a gradient processing and optimization library for JAX.
Optax is designed to facilitate research by providing building blocks that can be easily recombined in custom ways.
Our goals are to
- Provide simple, well-tested, efficient implementations of core components.
- Improve research productivity by enabling to easily combine low-level ingredients into custom optimizers (or other gradient processing components).
- Accelerate adoption of new ideas by making it easy for anyone to contribute.
We favor focusing on small composable building blocks that can be effectively combined into custom solutions. Others may build upon these basic components in more complicated abstractions. Whenever reasonable, implementations prioritize readability and structuring code to match standard equations, over code reuse.
An initial prototype of this library was made available in JAX's experimental
folder as jax.experimental.optix. Given the wide adoption across DeepMind
of optix, and after a few iterations on the API, optix was eventually moved
out of experimental as a standalone open-source library, and renamed optax.
Documentation on Optax can be found at optax.readthedocs.io.
Installation
You can install the latest released version of Optax from PyPI via:
pip install optax
or you can install the latest development version from GitHub:
pip install git+https://github.com/google-deepmind/optax.git
Quickstart
Optax contains implementations of many popular optimizers and
loss functions.
For example, the following code snippet uses the Adam optimizer from optax.adam
and the mean squared error from optax.l2_loss. We initialize the optimizer
state using the function and of the model.