-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GSoC 2021: Support of the simulation-based inference with the model fitting toolbox #64
Conversation
Add sbi wrapper class
Update tests
Thanks for summarizing everything so nicely, this looks great! It'll take me some time to review everything in detail before doing a final merge and the release, but I am already very happy with the results of this GSoC 😊 |
Apologies that this review is taking ages... There are still a few things that I'd like to work on (mostly the tests and trying it out on real-life examples), but I can do this in the master branch as well, so I'll take the important symbolic step of merging this pull request now 😄 |
This pull request summarizes all the work done during the Google Summer of Code (GSoC) 2021 with International Neuroinformatics Coordinating Facility (INCF) for the project:
Support of the simulation-based inference with the model fitting toolbox
Synopsis
Unlike traditional inverse identification tools that rely on gradient and gradient-free methods, simulation-based inference has been established as the powerful alternative approach that yields twofold improvement over such methods. Firstly, it does not only result in a single set of optimal parameters, rather simulation-based inference acts as if the actual statistical inference is performed and provides an estimate of the full posterior distribution over parameters. Secondly, it exploits prior system knowledge sparsely, using only the most important features to identify mechanistic models which are consistent with the measured data. The aim of the project is to support the simulation-based inference in the
brian2modelfitting
toolbox by linking it to thesbi
[1], PyTorch-based library for simulation-based inference, development of which is coordinated at the Macke lab.Main results
The entire work done during the GSoC is presented in great detail on the blog on my personal webpage, which is available here. This blog post covers everything: from the work done during the community bonding period, over weekly reports that outline the work done weekly in great detail, to my own experience during the entire period of the project.
Summary of the main results (under each major contribution, there is a short code snippet that describes it):
development of the
Inferencer
class that offers an API very similar to that of theFitter
class, but instead of fitting, a neural density estimator is trained under the hood. - PR #49This density estimator learns probabilistic mapping between the sampled prior over unknown parameters, and the output data.
Output data may be either a list of summary features or the time-series of the dynamics of observed state variable(s) in the model. In the case of the latter, the automatic feature extraction is performed where either default or custom embedding network is employed to extract meaningful features from the data traces, thus lowering the overall dimensionality of the output data.
The
Inferencer
class supports all currently available estimation methods insbi
:So, the only thing that the user has to do is to instantiate the
Inferencer
class with required arguments such as the input and output data, and a few optional ones:The inference process starts when
infer
method is called:Overall idea is to distance the user from the
sbi
package (and the use of the PyTorch library), and achieve an API very similar to the one to which thebrian2modelfitting
users are already accustomed through theFitter
class.Loading/storing of the training data and the estimated posterior. - PR #52
and
Support for visual analysis of the estimated posterior over free parameters. - PR #58
Multi-objective optimization support. - PR #59
Inference by observing spikes either instead or together with the dynamics of different state variables in the model. - PR #60
GPU support for the inference process. - PR #61
This feature should be used carefully as discussed in the PR and relevant issues mentioned in the PR.
Updated documentation with examples and the comprehensive tutorial, currently available here.
Added examples:
IF_sbi.py
- inference of two unknown parameters of an integrate-and-fire neuron model by observing only spike trainshh_sbi_simple_interface.py
- inference on real data traces by using a Hodgkin-Huxley model with three unknown parameters with simple interface by usinginfer
method in theInferencer
classhh_sbi_flexible_interface.py
- multi-round inference on real data traces by using the Hodgkin-Huxley model with three unknown parameters with flexible interface by usinginfer_step
method in theInferencer
class manuallyhh_sbi_synthetic_traces.py
- automatic feature extraction and inference on synthetic data traces by using the Hodgkin-Huxley modelUpdated tests.
What's left to do
Even though all the features defined at the very beginning of the project, both through the project proposal, available here, and internally between Marcel and me, are done, the test suite for the
Inferencer
class is far from comprehensive and updates and refinement are needed.Additional work
Additional development, testing and various examples that are not officially included in the PR are located in the gsoc_dump_repo on my personal GitHub account, available here.
Progress tracker
During the project (period of 10 weeks), the entire work is accompanied by weekly reports that outline in detail what has been done during the current week, what is planned for the next week and whether there are any obstacles. The reports are available here.
For a more concise review, it is sufficient to refer to Projects ->
sbi
integration (GSoC 2021) in thebrian2modelfitting
GitHub repository, available here. Under Done section, there are listed all issues and pull requests that resolve those issues, described earlier in the section Main results. This PR will be listed under the In progress section 🙂Thanks
Many thanks to @mstimberg for his immense patience and time for my (often silly) questions 🙇♂️
References
[1] Alvaro Tejero-Cantero, Jan Boelts, Michael Deistler, Jan-Matthis Lueckmann, Conor Durkan, Pedro J Goncalves, David S Greenberg, Jakob H Macke. sbi: A toolkit for simulation-based inference, 2020, Journal of Open Source Software 5:2505, doi:10.21105/joss.02505.
[2] David S. Greenberg, Marcel Nonnenmacher, Jakob H. Macke. Automatic posterior transformation for likelihood-free inference, 2019, 36th International Conference on Machine Learning, PMLR 97:2404-2414.
[3] George Papamakarios, David C. Sterratt, Iain Murray. Sequential neural likelihood: Fast likelihood-free inference with autoregressive flows, 2019, 22nd International Conference on Artificial Intelligence and Statistics, PMLR 89:837-848.
[4] Conor Durkan, Iain Murray, George Papamakarios. On contrastive learning for likelihood-free inference, 2020, 37th International Conference on Machine Learning, PMLR 119:2771-2781.