mackelab/delfi

Saving/restoring posteriors

rat-h opened this issue · 2 comments

rat-h commented

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?

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

Thank you! I'll try sbi, sure.