Ejemplo n.º 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
Ejemplo n.º 2
0
    def test_init_ve(self) -> None:

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

        with pytest.raises(ValueError):
            gp = GP(kernel=mo_kernel)
Ejemplo n.º 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
Ejemplo n.º 4
0
 def init_gp(self) -> GP:
     return GP(SquaredExponentialKernel())
Ejemplo n.º 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)
Ejemplo n.º 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)