add test to for recusive initialize
@@ -82,6 +82,24 @@ class TestSimpleGPRegression(unittest.TestCase):
if torch.cuda.is_available():
self.test_prior(cuda=True)
+ def test_recursive_initialize(self, cuda=False):
+ train_x, test_x, train_y, test_y = self._get_data(cuda=cuda)
+
+ likelihood_1 = GaussianLikelihood()
+ gp_model_1 = ExactGPModel(train_x, train_y, likelihood_1)
+
+ likelihood_2 = GaussianLikelihood()
+ gp_model_2 = ExactGPModel(train_x, train_y, likelihood_2)
+
+ gp_model_1.initialize(**{"likelihood.noise": 1e-2,
+ "covar_module.base_kernel.lengthscale": 1e-1})
+ gp_model_2.likelihood.initialize(noise=1e-2)
+ gp_model_2.covar_module.base_kernel.initialize(lengthscale=1e-1)
+ self.assertTrue(torch.equal(gp_model_1.likelihood.noise,
+ gp_model_2.likelihood.noise))
+ self.assertTrue(torch.equal(gp_model_1.covar_module.base_kernel.lengthscale,
+ gp_model_2.covar_module.base_kernel.lengthscale))
+
def test_posterior_latent_gp_and_likelihood_without_optimization(self, cuda=False):
train_x, test_x, train_y, test_y = self._get_data(cuda=cuda)
# We're manually going to set the hyperparameters to be ridiculous
