flâneur — a map of the web's best reading

Key Concepts — JAX documentation

jax.readthedocs.io · 1,705 words · saved by 1 readers

The default array implementation in JAX is jax.Array. In many ways it is similar to the numpy.ndarray type that you may be familar with from the NumPy package, but it has some important differences. We typically don’t call the jax.Array constructor directly, but rather create arrays via JAX API functions. For example, jax.numpy provides familar NumPy-style array construction functionality such as jax.numpy.zeros(), jax.numpy.linspace(), jax.numpy.arange(), etc. If you use Python type annotations in your code, jax.Array is the appropriate annotation for jax array objects (see jax.typing for more discussion). JAX Array objects have a devices method that lets you inspect where the contents of the array are stored. In the simplest cases, this will be a single CPU device: In general, an array may be sharded across multiple devices, in a manner that can be inspected via the sharding attribute: Here the array is on a single device, but in general a JAX array can be sharded across multiple dev

Key concepts # This section briefly introduces some key concepts of the JAX package. Transformations # Along with functions to operate on arrays, JAX includes a number of transformations which operate on JAX functions. These include jax.jit() : Just-in-time (JIT) compilation; see Just-in-time compilation jax.vmap() : Vectorizing transform; see Automatic vectorization jax.grad() : Gradient transform; see Automatic differentiation as well as several others. Transformations accept a function as an argument, and return a new transformed function. For example, here’s how you might JIT-compile a sim

Explore this link on the map →

related reading