def obs_gp(self) -> GP: x = torch.tensor([[0.0, 0.0], [1.0, 1.0], [2.0, 2.0]]) y = torch.tensor([[0.0], [1.0], [2.0]]) gp = GP(SquaredExponentialKernel()) gp.observe(x, y) return gp
def test_init_ve(self) -> None: mo_kernel = MOKernel([ SquaredExponentialKernel(), SquaredExponentialKernel(), SquaredExponentialKernel() ]) with pytest.raises(ValueError): gp = GP(kernel=mo_kernel)
def test_call(self) -> None: x = torch.tensor([[0.0], [1.0], [2.0]]) y = torch.tensor([[0.0], [1.0], [2.0]]) gp = GP(SquaredExponentialKernel()) | (x, y) x_call = 3.0 x_post = torch.tensor([[3.0]]) p_call = gp(x_call) p_post = gp(x_post) assert torch.allclose(p_call.mean, p_post.mean) assert p_call.mean.shape == p_post.mean.shape
def init_gp(self) -> GP: return GP(SquaredExponentialKernel())
def model_nd() -> GP: x = torch.tensor([[-3.0, -3.0], [-2.0, -2.0], [1.0, 1.0], [2.0, 2.0]]) y = -torch.sum(x**2, dim=1).view(-1, 1) return GP(SquaredExponentialKernel()) | (x, y)
def model() -> GP: x = torch.tensor([-5.0, -4.0, -3.0, -2.0, -1.0, 1.0]) y = torch.sin(x) return GP(SquaredExponentialKernel()) | (x, y)