mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-08 15:05:15 +02:00
migrate svgp_tests to pytest
This commit is contained in:
parent
a9e65c965b
commit
4b427de8fa
1 changed files with 9 additions and 6 deletions
|
|
@ -2,12 +2,12 @@ import numpy as np
|
|||
import GPy
|
||||
|
||||
|
||||
class SVGP_nonconvex(np.testing.TestCase):
|
||||
class TestSVGP_nonconvex:
|
||||
"""
|
||||
Inference in the SVGP with a student-T likelihood
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
def setup(self):
|
||||
X = np.linspace(0, 10, 100).reshape(-1, 1)
|
||||
Z = np.linspace(0, 10, 10).reshape(-1, 1)
|
||||
Y = np.sin(X) + np.random.randn(*X.shape) * 0.1
|
||||
|
|
@ -18,15 +18,16 @@ class SVGP_nonconvex(np.testing.TestCase):
|
|||
self.m = GPy.core.SVGP(X, Y, Z=Z, likelihood=lik, kernel=k)
|
||||
|
||||
def test_grad(self):
|
||||
self.setup()
|
||||
assert self.m.checkgrad(step=1e-4)
|
||||
|
||||
|
||||
class SVGP_classification(np.testing.TestCase):
|
||||
class TestSVGP_classification:
|
||||
"""
|
||||
Inference in the SVGP with a Bernoulli likelihood
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
def setup(self):
|
||||
X = np.linspace(0, 10, 100).reshape(-1, 1)
|
||||
Z = np.linspace(0, 10, 10).reshape(-1, 1)
|
||||
Y = np.where((np.sin(X) + np.random.randn(*X.shape) * 0.1) > 0, 1, 0)
|
||||
|
|
@ -36,15 +37,16 @@ class SVGP_classification(np.testing.TestCase):
|
|||
self.m = GPy.core.SVGP(X, Y, Z=Z, likelihood=lik, kernel=k)
|
||||
|
||||
def test_grad(self):
|
||||
self.setup()
|
||||
assert self.m.checkgrad(step=1e-4)
|
||||
|
||||
|
||||
class SVGP_Poisson_with_meanfunction(np.testing.TestCase):
|
||||
class TestSVGP_Poisson_with_meanfunction:
|
||||
"""
|
||||
Inference in the SVGP with a Bernoulli likelihood
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
def setup(self):
|
||||
X = np.linspace(0, 10, 100).reshape(-1, 1)
|
||||
Z = np.linspace(0, 10, 10).reshape(-1, 1)
|
||||
latent_f = np.exp(0.1 * X * 0.05 * X**2)
|
||||
|
|
@ -57,4 +59,5 @@ class SVGP_Poisson_with_meanfunction(np.testing.TestCase):
|
|||
self.m = GPy.core.SVGP(X, Y, Z=Z, likelihood=lik, kernel=k, mean_function=mf)
|
||||
|
||||
def test_grad(self):
|
||||
self.setup()
|
||||
assert self.m.checkgrad(step=1e-4)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue