Exemplo n.º 1
0
 def test_nongrid_nongrid(self):
     base_kernel = RBFKernel()
     data = torch.randn(5, 2)
     kernel = GridKernel(base_kernel, grid)
     grid_eval = kernel(data, data).evaluate()
     actual_eval = base_kernel(data, data).evaluate()
     self.assertLess(torch.norm(grid_eval - actual_eval), 1e-5)
Exemplo n.º 2
0
 def test_grid_grid(self):
     base_kernel = RBFKernel()
     kernel = GridKernel(base_kernel, grid)
     grid_covar = kernel(grid_data, grid_data).evaluate_kernel()
     self.assertIsInstance(grid_covar, KroneckerProductLazyTensor)
     grid_eval = kernel(grid_data, grid_data).evaluate()
     actual_eval = base_kernel(grid_data, grid_data).evaluate()
     self.assertLess(torch.norm(grid_eval - actual_eval), 1.2e-5)
Exemplo n.º 3
0
 def test_nongrid_nongrid(self, toeplitz=True):
     with gpytorch.settings.use_toeplitz(toeplitz):
         base_kernel = RBFKernel(ard_num_dims=2)
         data = torch.randn(5, d)
         kernel = GridKernel(base_kernel, grid)
         grid_eval = kernel(data, data).evaluate()
         actual_eval = base_kernel(data, data).evaluate()
         self.assertLess(torch.norm(grid_eval - actual_eval), 1e-5)
Exemplo n.º 4
0
 def test_grid_grid(self, toeplitz=True):
     with gpytorch.settings.use_toeplitz(toeplitz):
         base_kernel = RBFKernel(ard_num_dims=2)
         kernel = GridKernel(base_kernel, grid)
         grid_covar = kernel(grid_data, grid_data).evaluate_kernel()
         self.assertIsInstance(grid_covar, KroneckerProductLazyTensor)
         grid_eval = kernel(grid_data, grid_data).evaluate()
         actual_eval = base_kernel(grid_data, grid_data).evaluate()
         self.assertLess(torch.norm(grid_eval - actual_eval), 2e-5)
Exemplo n.º 5
0
 def test_non_stationary_base(self):
     base_kernel = LinearKernel()
     with self.assertRaisesRegex(
             RuntimeError,
             "The base_kernel for GridKernel must be stationary."):
         GridKernel(base_kernel, grid)
Exemplo n.º 6
0
 def test_grid_grid(self):
     base_kernel = RBFKernel()
     kernel = GridKernel(base_kernel, grid)
     grid_eval = kernel(grid, grid).evaluate()
     actual_eval = base_kernel(grid_data, grid_data).evaluate()
     self.assertLess(torch.norm(grid_eval - actual_eval), 1e-5)