param(name, init_value=None, **kwargs)¶
Annotate the given site as an optimizable parameter for use with
jax.experimental.optimizers. For an example of how param statements can be used in inference algorithms, refer to
value for the parameter. Unless wrapped inside a handler like
substitute, this will simply return the initial value.
sample(name, fn, obs=None, rng_key=None, sample_shape=())¶
Returns a random sample from the stochastic function fn. This can have additional side effects when wrapped inside effect handlers like
By design, sample primitive is meant to be used inside a NumPyro model. Then
seedhandler is used to inject a random state to fn. In those situations, rng_key keyword will take no effect.
sample from the stochastic fn.
plate(name, size, subsample_size=None, dim=None)¶
Construct for annotating conditionally independent variables. Within a plate context manager, sample sites will be automatically broadcasted to the size of the plate. Additionally, a scale factor might be applied by certain inference algorithms if subsample_size is specified.
- name (str) – Name of the plate.
- size (int) – Size of the plate.
- subsample_size (int) – Optional argument denoting the size of the mini-batch. This can be used to apply a scaling factor by inference algorithms. e.g. when computing ELBO using a mini-batch.
- dim (int) – Optional argument to specify which dimension in the tensor is used as the plate dim. If None (default), the leftmost available dim is allocated.
module(name, nn, input_shape=None)¶
a apply_fn with bound parameters that takes an array as an input and returns the neural network transformed output array.