mackelab / delfi

Density estimation likelihood-free inference. No longer actively developed see https://github.com/mackelab/sbi instead
http://www.mackelab.org/delfi
Other
71 stars 28 forks source link

Saving/restoring posteriors #71

Closed rat-h closed 3 years ago

rat-h commented 3 years ago

Hi all, I'm playing with delfi as an alternative to my old GA methods. I usually run an optimization overnight on the cluster/external nodes (lots of cores and powerful GPUs) and then download the results and run the best locally.

I understand that I can pick the posterior[-1] object, run a sample generator, and save samples. However, is it possible to serialize all parameters used in the generator somehow (better in JSON format) and reconstruct the generator somewhere else?

It seems I can save the inference object and reconstruct it on a local computer using delfi.io, but I cannot find a way to get back posteriors from it without calling the run() function again.

Could you please provide an example of how to save and restore the result of delfi's inference: posteriors?

jan-matthis commented 3 years ago

If you save a posterior object using io.save_pkl, you should subsequently be able to reload it using io.load_pkl. Having said that, I would highly recommend checking out sbi, which replaces delfi: https://github.com/mackelab/sbi

rat-h commented 3 years ago

Thank you! I'll try sbi, sure.