Main article: Automatic differentiation
The below code demonstrates the grad function's automatic differentiation.
The final line should outputː
The below code demonstrates the jit function's optimization through fusion.
The computation time for jit_cube (line #17) should be noticeably shorter than that for cube (line #16). Increasing the values on line #7, will further exacerbate the difference.
Main article: Array programming
The below code demonstrates the vmap function's vectorization.
The GIF on the right of this section illustrates the notion of vectorized addition.
The below code demonstrates the pmap function's parallelization for matrix multiplication.
The final line should print the valuesː
Bradbury, James; Frostig, Roy; Hawkins, Peter; Johnson, Matthew James; Leary, Chris; MacLaurin, Dougal; Necula, George; Paszke, Adam; Vanderplas, Jake; Wanderman-Milne, Skye; Zhang, Qiao (2022-06-18), "JAX: Autograd and XLA", Astrophysics Source Code Library, Google, Bibcode:2021ascl.soft11002B, archived from the original on 2022-06-18, retrieved 2022-06-18 https://web.archive.org/web/20220618205214/https://github.com/google/jax ↩
Frostig, Roy; Johnson, Matthew James; Leary, Chris (2018-02-02). "Compiling machine learning programs via high-level tracing" (PDF). MLsys: 1–3. Archived (PDF) from the original on 2022-06-21.{{cite journal}}: CS1 maint: date and year (link) https://mlsys.org/Conferences/doc/2018/146.pdf ↩
"Using JAX to accelerate our research". www.deepmind.com. Archived from the original on 2022-06-18. Retrieved 2022-06-18. https://www.deepmind.com/blog/using-jax-to-accelerate-our-research ↩
Lynley, Matthew. "Google is quietly replacing the backbone of its AI product strategy after its last big push for dominance got overshadowed by Meta". Business Insider. Archived from the original on 2022-06-21. Retrieved 2022-06-21. https://web.archive.org/web/20220621143905/https://www.businessinsider.com/facebook-pytorch-beat-google-tensorflow-jax-meta-ai-2022-6 ↩
"Why is Google's JAX so popular?". Analytics India Magazine. 2022-04-25. Archived from the original on 2022-06-18. Retrieved 2022-06-18. https://analyticsindiamag.com/why-is-googles-jax-so-popular/ ↩
"Quickstart — JAX documentation". https://docs.jax.dev/en/latest/quickstart.html ↩