From ac84f4f34c337d0001898db6dc4135d01af2970e Mon Sep 17 00:00:00 2001 From: James Hensman Date: Thu, 6 Dec 2012 11:30:12 -0800 Subject: [PATCH] changed the name of GP_EP (from simple) in the unit test, added a messages option for full EP --- GPy/inference/Expectation_Propagation.py | 4 +++- GPy/testing/unit_tests.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/GPy/inference/Expectation_Propagation.py b/GPy/inference/Expectation_Propagation.py index c281578e..05453f1d 100644 --- a/GPy/inference/Expectation_Propagation.py +++ b/GPy/inference/Expectation_Propagation.py @@ -51,7 +51,7 @@ class Full(EP_base): self.K = K self.N = self.K.shape[0] EP_base.__init__(self,likelihood,*args,**kwargs) - def fit_EP(self): + def fit_EP(self,messages=False): """ The expectation-propagation algorithm. For nomenclature see Rasmussen & Williams 2006 (pag. 52-60) @@ -115,6 +115,8 @@ class Full(EP_base): epsilon_np2 = np.mean(self.v_tilde-self.np2[-1]**2) self.np1.append(self.tau_tilde.copy()) self.np2.append(self.v_tilde.copy()) + if messages: + print "EP iteration %i, epsiolon %d"%(self.iterations,epsilon_np1) class FITC(EP_base): """ diff --git a/GPy/testing/unit_tests.py b/GPy/testing/unit_tests.py index 9191cedd..02a63feb 100644 --- a/GPy/testing/unit_tests.py +++ b/GPy/testing/unit_tests.py @@ -139,13 +139,13 @@ class GradientTests(unittest.TestCase): m.constrain_positive('(linear|bias|white)') self.assertTrue(m.checkgrad()) - def test_simple_GP_EP(self): + def test_GP_EP(self): N = 20 X = np.hstack([np.random.rand(N/2)+1,np.random.rand(N/2)-1])[:,None] k = GPy.kern.rbf(1) + GPy.kern.white(1) Y = np.hstack([np.ones(N/2),-np.ones(N/2)])[:,None] likelihood = GPy.inference.likelihoods.probit(Y) - m = GPy.models.simple_GP_EP(X,likelihood,k) + m = GPy.models.GP_EP(X,likelihood,k) m.constrain_positive('(var|len)') m.approximate_likelihood() self.assertTrue(m.checkgrad())