model = GPModel(inducing_points=checkpoint['model_state_dict']['variational_strategy.inducing_points'].double().cuda(), use_ard=True).double().cuda()
model.load_state_dict(checkpoint['model_state_dict'])
Strange thing happened, the performance of the loaded model in the tests of testing is much worse than its performance in the tests during training (tests during testing and training, which means the model was being evaluated in both cases). After a long time of debugging, I found in the forward method, variables like x, mean_x, and covar_xall have the same values in the tests during testing and training, and the model's parameters are checked to be all the same (for example, covar_module.raw_outputscale, covar_module.base_kernel.raw_lengthscale_constraint.upper_bound, variational_strategy.variational_params_initialized and etc.) as well.
However, the returned gpytorch.distributions.MultivariateNormal(mean_x, covar_x) gave different results (different multivariate distributions) which is quite confusing. Specifically, I checked the returned distribution's mean and covariance values which are different between testing and training. I'm wondering what might be the problem?
Besides, during training, I observed a warning: PATH/lib/python3.8/site-packages/gpytorch/distributions/multivariate_normal.py:259: NumericalWarning: Negative variance values detected. This is likely due to numerical instabilities. Rounding negative variances up to 1e-10. Would this lead to the problem of different test results of gpytorch.distributions.MultivariateNormal(mean_x, covar_x) during testing (using the saved model) and training?
(Update: I checked this, when there is no warning of negative variances during training, the distribution's values are still different during tests between training and testing. This is so wired problem.)
🐛 Bug
My GPyTorch is version 1.4.2, PyTorch is version 1.8.0, and Computer OS of Ubuntu 20.04.
I defined an approximate GP model as:
And I used the following code to save and load the model:
and
Strange thing happened, the performance of the loaded model in the tests of testing is much worse than its performance in the tests during training (tests during testing and training, which means the model was being evaluated in both cases). After a long time of debugging, I found in the
forward
method, variables likex
,mean_x
, andcovar_x
all have the same values in the tests during testing and training, and the model's parameters are checked to be all the same (for example,covar_module.raw_outputscale
,covar_module.base_kernel.raw_lengthscale_constraint.upper_bound
,variational_strategy.variational_params_initialized
and etc.) as well.However, the returned
gpytorch.distributions.MultivariateNormal(mean_x, covar_x)
gave different results (different multivariate distributions) which is quite confusing. Specifically, I checked the returned distribution's mean and covariance values which are different between testing and training. I'm wondering what might be the problem?Besides, during training, I observed a warning:
PATH/lib/python3.8/site-packages/gpytorch/distributions/multivariate_normal.py:259: NumericalWarning: Negative variance values detected. This is likely due to numerical instabilities. Rounding negative variances up to 1e-10.
Would this lead to the problem of different test results ofgpytorch.distributions.MultivariateNormal(mean_x, covar_x)
during testing (using the saved model) and training? (Update: I checked this, when there is no warning of negative variances during training, the distribution's values are still different during tests between training and testing. This is so wired problem.)Look forward to your help! Thank you!
Best regards, Pengzhi