Ejemplo n.º 1
0
 def test_inverse_wishart_prior(self):
     prior = InverseWishartPrior(self.nu, self.K)
     self.assertFalse(prior.log_transform)
     self.assertEqual(prior.shape, self.K.shape)
     self.assertTrue(torch.equal(prior.K, self.K))
     self.assertEqual(prior.nu, self.nu)
     self.assertEqual(prior.C, -2 * math.log(2) - log_mv_gamma(2, 1))
     self.assertTrue(prior.is_in_support(self.K))
     self.assertFalse(prior.is_in_support(self.K_bad))
     self.assertAlmostEqual(prior.log_prob(self.K).item(),
                            -3.531024,
                            places=4)
 def __init__(self, train_x, train_y, likelihood):
     super(MultitaskGPModel, self).__init__(train_x, train_y, likelihood)
     self.mean_module = ConstantMean(prior=SmoothedBoxPrior(-1, 1))
     self.covar_module = RBFKernel(log_lengthscale_prior=SmoothedBoxPrior(
         exp(-6), exp(6), sigma=0.1, log_transform=True))
     self.task_covar_module = IndexKernel(n_tasks=2,
                                          rank=1,
                                          prior=InverseWishartPrior(
                                              nu=2, K=torch.eye(2)))
 def __init__(self, train_x, train_y, likelihood):
     super(HadamardMultitaskGPModel, self).__init__(train_x, train_y, likelihood)
     # Default bounds on mean are (-1e10, 1e10)
     self.mean_module = ConstantMean()
     # We use the very common RBF kernel
     self.covar_module = RBFKernel()
     # We learn an IndexKernel for 2 tasks
     # (so we'll actually learn 2x2=4 tasks with correlations)
     self.task_covar_module = IndexKernel(n_tasks=2, rank=1, prior=InverseWishartPrior(nu=2, K=torch.eye(2)))
Ejemplo n.º 4
0
 def test_inverse_wishart_prior_invalid_params(self):
     with self.assertRaises(ValueError):
         InverseWishartPrior(0, self.K)
     with self.assertRaises(ValueError):
         InverseWishartPrior(1, self.K_bad)