Mutation updates an existing tensor or array object directly instead of constructing a replacement. JAX rejects this in-place style because it conflicts with stateless computation; updates therefore return a new tensor. section 3.5.3
Replacing an element in JAX
Given `x = jnp.array([1, 2, 3], dtype="float32")`, write `new_x = x.at[0].set(10)`. The expression changes the desired value in the returned array while following JAX’s non-mutating update model. section 3.5.3
Use these rules when translating array code to JAX:
- Do not assign directly into a JAX array. section 3.5.3
- Use `at()` with `set()` to express an indexed update and bind the resulting tensor to a new name. section 3.5.3
Listing 3.31 Modifying values in a JAX array
>>> x = jnp.array([1, 2, 3], dtype="float32") >>> new_x = x.at[0].set(10)
Inspect the compact JAX example showing an indexed update that produces `new_x`. section 3.5.3











