def test_initialize_offset(self): kernel = ExponentialDecayKernel() kernel.initialize(offset=1) actual_value = torch.tensor(1.0).view_as(kernel.offset) self.assertLess(torch.norm(kernel.offset - actual_value), 1e-5)
def test_initialize_offset_batch(self): kernel = ExponentialDecayKernel(batch_shape=torch.Size([2])) off_init = torch.tensor([1.0, 2.0]) kernel.initialize(offset=off_init) actual_value = off_init.view_as(kernel.offset) self.assertLess(torch.norm(kernel.offset - actual_value), 1e-5)
def test_initialize_lengthscale_batch(self): kernel = ExponentialDecayKernel(batch_shape=torch.Size([2])) ls_init = torch.tensor([1.0, 2.0]) kernel.initialize(lengthscale=ls_init) actual_value = ls_init.view_as(kernel.lengthscale) self.assertLess(torch.norm(kernel.lengthscale - actual_value), 1e-5)