elicit.simulations module#
- class elicit.simulations.Priors(ground_truth: bool, init_matrix_slice: Dict[str, Tensor] | None, trainer: Trainer, parameters: List[Parameter], network: NFDict | None, expert: ExpertDict, seed: int)[source]#
Bases:
Module
Initializes the hyperparameters (i.e., trainable variables)
- Parameters:
- ground_truthbool
True if expert data are simulated from a given ground truth (oracle)
- init_matrix_slicedict[str, tf.Tensor], optional
samples drawn from the initialization distribution to initialize the hyperparameter of the parametric prior distributions Only required for method=”parametric_prior” otherwise None.
- trainerdict
specification of training settings and meta-information for workflow using
elicit.elicit.trainer()
- parameterslist
list of model parameters specified with
elicit.elicit.parameter()
.- networkdict, optional
specification of neural network using a method implemented in
elicit.networks
. Only required fordeep_prior
method. Forparametric_prior
useNone
.- expertdict
provide input data from expert or simulate data from oracle with either the
data
orsimulator
method of theelicit.elicit.Expert
module.- seedint
seed used for learning.
- elicit.simulations.intialize_priors(init_matrix_slice: Dict[str, Tensor] | None, method: str, seed: int, parameters: List[Parameter], network: NFDict | None) Dict[str, Tensor] [source]#
Initialize prior distributions.
- Parameters:
- init_matrix_slicetf.Tensor, optional
samples drawn from the initialization distribution to initialize the hyperparameter of the parametric prior distributions Only for method=”parametric_prior”, otherwise None.
- methodstr
parametric_prior or deep_prior method as specified in
elicit.elicit.trainer()
- seedint
seed of current workflow run as specified in
elicit.elicit.trainer()
- parameterslist[dict]
list of model parameter specifications using
elicit.elicit.parameter()
.- networkdict, optional
specification of neural network using a method implemented in
elicit.networks
. Only required fordeep_prior
method. Forparametric_prior
useNone
.
- Returns:
- init_priordict[str, tf.Tensor]
returns initialized prior distributions ready for prior sampling.
- elicit.simulations.sample_from_priors(initialized_priors: Dict[str, Variable] | Callable, ground_truth: bool, num_samples: int, B: int, seed: int, method: str, parameters: List[Parameter], network: NFDict | None, expert: ExpertDict) Tensor [source]#
Samples from initialized prior distributions.
- Parameters:
- initialized_priorsdict[str, tf.Variable] or Callable
initialized prior distributions ready for prior sampling.
- ground_truthbool
True if expert data is simulated from ground truth.
- num_samplesint
number of samples from the prior(s).
- Bint
batch size.
- seedint
seed used for learning.
- methodstr
parametric_prior or deep_prior method as specified in
elicit.elicit.trainer()
- parameterslist
list of model parameters specified with
elicit.elicit.parameter()
.- networkdict, optional
specification of neural network using a method implemented in
elicit.networks
. Only required fordeep_prior
method. Forparametric_prior
useNone
.- expertcallable
provide input data from expert or simulate data from oracle with either the
data
orsimulator
method of theelicit.elicit.Expert
module.
- Returns:
- prior_samplestf.Tensor, shape: [B, num_samples, num_params]
Samples from prior distributions.
- elicit.simulations.simulate_from_generator(prior_samples: Tensor, seed: int, model: dict) Dict[str, Tensor] [source]#
Simulates data from the specified generative model.
- Parameters:
- prior_samplestf.Tensor, shape: [B, num_samples, num_params]
samples from prior distributions.
- seedint
seed used for learning. Specification in
elicit.elicit.trainer()
.- modeldict
specification of generative model using
elicit.elicit.model()
.
- Returns:
- model_simulationsdict[str, tf.Tensor]
simulated data from generative model.