Package: optax
OptaxIntroductionOptax 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 toProvide simple, well-tested, efficient implementations of core components.Improve research productivity by enabling to easily combine low-level
ingredients into custom optimisers (or other gradient processing components).Accelerate adoption of new ideas by making it easy for anyone to contribute.We favour 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 prioritise
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 asjax.experimental.optix. Given the wide adoption across DeepMind
ofoptix, and after a few iterations on the API,optixwas eventually moved
out ofexperimentalas a standalone open-source library, and renamedoptax.Documentation on Optax can be found atoptax.readthedocs.io.InstallationYou can install the latest released version of Optax from PyPI via:pipinstalloptaxor you can install the latest development version from GitHub:pipinstallgit+https://github.com/google-deepmind/optax.gitQuickstartOptax contains implementations ofmany popular optimizersandloss functions.
For example, the following code snippet uses the Adam optimizer fromoptax.adamand the mean squared error fromoptax.l2_loss. We initialize the optimizer
state using theinitfunction andparamsof the model.optimizer=optax.adam(learning_rate)# Obtain the `opt_state` that contains statistics for the optimizer.params={'w':jnp.ones((num_weights,))}opt_state=optimizer.init(params)To write the update loop we need a loss function that can be differentiated by
Jax (withjax.gradin this
example) to obtain the gradients.compute_loss=lambdaparams,x,y:optax.l2_loss(params['w'].dot(x),y)grads=jax.grad(compute_loss)(params,xs,ys)The gradients are then converted viaoptimizer.updateto obtain the updates
that should be applied to the current parameters to obtain the new ones.optax.apply_updatesis a convenience utility to do this.updates,opt_state=optimizer.update(grads,opt_state)params=optax.apply_updates(params,updates)You can continue the quick start inthe Optax quickstart notebook.Citing OptaxThis repository is part of the DeepMind JAX Ecosystem, to cite Optax
please use the citation:@software{deepmind2020jax,title={The {D}eep{M}ind {JAX} {E}cosystem},author={DeepMind and Babuschkin, Igor and Baumli, Kate and Bell, Alison and Bhupatiraju, Surya and Bruce, Jake and Buchlovsky, Peter and Budden, David and Cai, Trevor and Clark, Aidan and Danihelka, Ivo and Dedieu, Antoine and Fantacci, Claudio and Godwin, Jonathan and Jones, Chris and Hemsley, Ross and Hennigan, Tom and Hessel, Matteo and Hou, Shaobo and Kapturowski, Steven and Keck, Thomas and Kemaev, Iurii and King, Michael and Kunesch, Markus and Martens, Lena and Merzic, Hamza and Mikulik, Vladimir and Norman, Tamara and Papamakarios, George and Quan, John and Ring, Roman and Ruiz, Francisco and Sanchez, Alvaro and Sartran, Laurent and Schneider, Rosalia and Sezener, Eren and Spencer, Stephen and Srinivasan, Srivatsan and Stanojevi\'{c}, Milo\v{s} and Stokowiec, Wojciech and Wang, Luyu and Zhou, Guangyao and Viola, Fabio},url={http://github.com/google-deepmind},year={2020},}