sbi
sbi copied to clipboard
Is it possible to load the saved NeuralPosterior objects from C++?
Thanks for your amazing work! Is it possible to load the saved NeuralPosterior objects from C++ to allow a more efficient posterior.sample?
thanks!
No, I don't think we have this option. Have you tried increasing sampling speed using the slice_np_vectorized
option, or slice_np
with num_workers>1
?
Thanks for your suggestion!I will try that later. I am not sure about the structure of NeuralPosterior objects . Is it a kind of PyTorch Model? If so, it may be converted to torch script and then loaded in C++ with libtorch.
Hi! The NeuralPosterior
is not a pytorch module. The returned nflows
network is a torch.nn.Module
though. I.e.
net = inference.append_simulations(theta, x).train()
--> net is a nn.Module
Hope that helps! Michale
Thank you very much!
Closing this for now, feel free to re-open if new questions come up (and feel free to write here if you managed to sample in c++ ;) )