Skip to content

Type annotation for PRNG keys #27577

Answered by jakevdp
carlosgmartin asked this question in Q&A
Discussion options

You must be logged in to vote

The right annotation is jax.Array – this was decided here: https://docs.jax.dev/en/latest/jep/9263-typed-keys.html#type-annotations-for-prng-keys

New-style typed keys (produced by jax.random.key) are defined by their dtype, and JAX does not offer any dtype-specific array annotations, so Array is the only appropriate annotation. Old-style keys (produced by jax.random.PRNGKey) are just arrays with dtype uint32 and a trailing dimension of a particular size depending on the default PRNG impl, and so Array is the only appropriate annotation.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jakevdp
Comment options

Answer selected by carlosgmartin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants