elisa.infer.samplers.util#

class ModelInfo(ndim: int, init: dict[str, NDArray[floating]], init_ravel: NDArray[floating], unravel: Callable[[NDArray[floating]], dict[str, NDArray[floating]]], log_prob_fn: Callable[[dict[str, NDArray[floating]]], float], postprocess_fn: Callable[[dict[str, NDArray[floating]]], dict[str, NDArray[floating]]], params_names: list[str], params_dtype: list[tuple[str, dtype, tuple[int, ...]]], deterministic_names: list[str], deterministic_dtype: list[tuple[str, dtype, tuple[int, ...]]])[source]#

Bases: NamedTuple

Model information.

Methods

count(value, /)

Return number of occurrences of value.

index(value[, start, stop])

Return first index of value.

ndim: int#

Model dimension.

init: dict[str, ndarray[tuple[Any, ...], dtype[floating]]]#

Initial parameters values in unconstrained space.

init_ravel: ndarray[tuple[Any, ...], dtype[floating]]#

Raveled initial parameters values in unconstrained space.

unravel: Callable[[ndarray[tuple[Any, ...], dtype[floating]]], dict[str, ndarray[tuple[Any, ...], dtype[floating]]]]#

Function to unravel parameters values.

log_prob_fn: Callable[[dict[str, ndarray[tuple[Any, ...], dtype[floating]]]], float]#

Log probability function given parameters in unconstrained space.

postprocess_fn: Callable[[dict[str, ndarray[tuple[Any, ...], dtype[floating]]]], dict[str, ndarray[tuple[Any, ...], dtype[floating]]]]#

Postprocess function given parameters in unconstrained space.

params_names: list[str]#

Names of parameters.

params_dtype: list[tuple[str, dtype, tuple[int, ...]]]#

NumPy dtypes of parameters in constrained space.

deterministic_names: list[str]#

Names of deterministic sites.

deterministic_dtype: list[tuple[str, dtype, tuple[int, ...]]]#

NumPy dtypes of deterministic sites.

get_model_info(model: Callable, init_strategy: Callable = <function init_to_uniform>, model_args: tuple = (), model_kwargs: dict | None = None, forward_mode_differentiation: bool = False, validate_grad: bool = True, rng_seed: int = 42) ModelInfo[source]#

Get model information.

ravel_params_names(name: str, shape: tuple[int, ...]) list[str][source]#

Ravel parameter names.

class UniformReparam[source]#

Bases: Reparam

Reparameterize a distribution to a Uniform over the unit hypercube.

Most univariate distribution uses inverse CDF for reparameterization.

Methods

__call__(name, fn, obs)

uniform_reparam_transform(d)[source]#
uniform_reparam_transform(d: MultivariateNormal)
uniform_reparam_transform(d: BernoulliProbs)
uniform_reparam_transform(d: BernoulliLogits)
uniform_reparam_transform(d: CategoricalProbs)
uniform_reparam_transform(d: CategoricalLogits)
uniform_reparam_transform(d: Dirichlet)

A helper for UniformReparam to get the transform that maps a uniform distribution over a unit hypercube to the target distribution d.

uniform_reparam_model(model: Callable, model_args: tuple = (), model_kwargs: dict | None = None, rng_seed: int = 42) ModelInfo[source]#