示例#1
0
    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
示例#2
0
    def test_init_ve(self) -> None:

        mo_kernel = MOKernel([
            SquaredExponentialKernel(),
            SquaredExponentialKernel(),
            SquaredExponentialKernel()
        ])

        with pytest.raises(ValueError):
            gp = GP(kernel=mo_kernel)
示例#3
0
    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
示例#4
0
 def init_gp(self) -> GP:
     return GP(SquaredExponentialKernel())
示例#5
0
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)
示例#6
0
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)