How to save density _estimator after the NN is trained? #931
-
Hello! Thanks for the amazing package and the documentation. I am using SNRE to get the posterior and looking into different samplers following this example. https://sbi-dev.github.io/sbi/tutorial/11_sampler_interface/ I would like to save the However, I am not sure how to do this given that the neural network class is built and hidden in This is the code I have with an embedding network for my inputs
Is there a way to do something like:
Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi there, it should be possible to pickle the density estimator. I.e. import pickle
# Write.
with open("path.pkl", "wb") as handle:
pickle.dump(density_estimator, handle)
# Read.
with open("path.pkl", "rb") as handle:
density_estimator = pickle.load(handle) (tested this on CPU only, please let me know if it leads to issues for you) |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot, Michael! |
Beta Was this translation helpful? Give feedback.
Hi there, it should be possible to pickle the density estimator. I.e.
(tested this on CPU only, please let me know if it leads to issues for you)