I created a deterministic convolutional neural network for classification, and then lifted it to a probabilistic network using pyro.random_module(). I further tuned the learning rate as a hyper parameter during SVI optimization. While looping over SVI, I sampled the random network many times, e.g., sampled_models = [guide(None, None) for _ in range(num_model_samples)], to get many instances and evaluated the performance on a validation data set – I wanted to keep the best probabilistic network. What can I do to save the best model and guide?
In Pytorch, we can save the best network (call it myNet) by
I saved the guide corresponding to the best predication accuracy (about 98%) during validation, and called it guide_best. Then I generated sample neural networks from guide_best, but these networks produced very low accuracy (40%) on test data. Did I miss anything? My code is:
num_model_samples = 50
sampled_models = [guide_best(None, None) for _ in range(num_model_samples)]
yhats = [model(x).data for model in sampled_models]
Warning:
UserWarning: Couldn’t retrieve source code for container of type AutoDiagonalNormal. It won’t be checked for correctness upon loading.
Error:
TypeError: expected str, bytes or os.PathLike object, not ParamStoreDict