Replies: 5 comments 3 replies
-
Beta Was this translation helpful? Give feedback.
-
EMCEE inferenceentrypoint: 1. Build-upit works fully through inference.py. First, you build an object
static_sim_arguments = {
"snpi_df_ref": snpi_df_ref,
"hnpi_df_ref": hnpi_df_ref,
"p_draw": p_draw,
"unique_strings": unique_strings,
"transition_array": transition_array,
"proportion_array": proportion_array,
"proportion_info": proportion_info,
"initial_conditions": initial_conditions,
"seeding_data": seeding_data,
"seeding_amounts": seeding_amounts,
"outcomes_parameters": outcomes_parameters,
} 2. UsageThe function to simulate a proposal is
So
Hence one call EMCEE using sampler = emcee.EnsembleSampler(
nwalkers,
gempyor_inference.inferpar.get_dim(),
gempyor_inference.get_logloss_as_single_number, # function that takes a proposal and return a logloss
pool=pool,
backend=backend, # backend is the place where it'll save the HDF file.
moves=moves,
) NotesThis is all done in object, without performance penalty (in inference.py, there are commented lines to call get_logloss_as_single_number without using the gempyor_inference object at all anymore (using it only to build the static arguments and the different object). It did not seem faster from benchmark but might be preferred. |
Beta Was this translation helpful? Give feedback.
-
Classical inferenceIt works fully through inference.py. First, you build an object inference.GempyorInference, which will hold a ModelInfo object:
Step 1. initialize the filesIf not resume, R inference calls: gempyor_inference_runner$one_simulation(
sim_id2write=0,
load_ID=Fase) to get one run from config. This writes index 0 of all hnpi, snpi, spar, hosp, seir, ... files in the outputs. Step 2: generate proposalR inference reads the snpi, seed and hnpi files, and writes them again but this time putting proposed parameters inside, then call gempyor_inference_runner$one_simulation(
sim_id2write=this_index,
load_ID=TRUE,
sim_id2load=this_index) So gempyor does one simulation reading the files that inference has modified, and writes the same exact files, but this time also writing an hosp and seir files containing the outcomes Inside gempyor, the first time one_simulation is run, it builds the compartments structure only (this can be quite long), while all the rest (spar, snpi, ...) is read from the file at the restRinference read the hosp file, compute the llik and accept/reject it's proposed parameters. This is in a loop that update |
Beta Was this translation helpful? Give feedback.
-
The 3 ways to run everythingThere are 3 ways to run a full gempyor simulation. A reminder that this means: take a config, or a config + some files, and build all modelInfo object, run a RK4 integration to get all the model states in time, then run the observations model to get an hosp file/outcomes). Ideally these 3 way are consolidated into one so there are no bugs. The first way does not use inference.py (which could be called the interface file of gempyor), the two other does. The way simulate.py does it:# [create a modelInfo]
seir.run_parallel_SEIR(...)
outcomes.run_parallel_outcomes(...) Simply runs the two "runner functions" from the seir and outcomes module. These functions build modifiers, compartments, and all. In inference.py, The way classical inference does itIt uses The way emcee does itIt uses |
Beta Was this translation helpful? Give feedback.
-
Thanks for this. I think the keys here are:
|
Beta Was this translation helpful? Give feedback.
-
Here lie a description of how data is used and shared inside gempyor.
What remains to be written (ask and I'll):
Beta Was this translation helpful? Give feedback.
All reactions