Open natarajanmolecule opened 4 years ago
@natarajanmolecule I'll look in to this -- looks like maybe the hypers all got updated to be the same or something strange.
@natarajanmolecule I am able to get correct looking predictions if I save and load in the following way:
...
mcmc_run.run(train_x, train_y)
model.pyro_load_from_samples(mcmc_run.get_samples())
torch.save([mcmc_run.get_samples(), model.state_dict()], 'model_state.pth')
## reinit model likelihood = gpytorch.likelihoods.GaussianLikelihood(noise_constraint=gpytorch.constraints.Positive())
model = ExactGPModel(train_x, train_y, likelihood)
model.mean_module.register_prior("mean_prior", UniformPrior(-1, 1), "constant") model.covar_module.base_kernel.register_prior("lengthscale_prior", UniformPrior(0.01, 0.5), "lengthscale")
model.covar_module.base_kernel.register_prior("period_length_prior", UniformPrior(0.05, 2.5), "period_length")
model.covar_module.register_prior("outputscale_prior", UniformPrior(1, 2), "outputscale") likelihood.register_prior("noise_prior", UniformPrior(0.05, 0.3), "noise")
mcmc_samples, model_state = torch.load('model_state.pth')
model.pyro_load_from_samples(mcmc_samples)
model.load_state_dict(model_state)
Is this a workable solution for you? If so, this is probably a better way to load samples. I realized that actually the strict shape thing doesn't work at all, because it doesn't update batch_shape
for the underlying modules. So I'll probably remove it and add this as the proper tutorial.
🐛 Bug
I have raised an issue earlier regarding how to load previously saved full Bayesian GP models from disk. Thanks so much for that PR. Now I am trying to load a previously saved model from disk and trying to make predictions with it. But it seems like it is only using the first sample from the MCMC in the predictions and not using all the samples. Please see the code below. I have modified the example code in the full Bayesian GP section to perform predictions. Am I missing something?
To reproduce
Code snippet to reproduce
Stack trace/error message
Expected Behavior
System information
Please complete the following information: