changed the name of GP_EP (from simple) in the unit test, added a messages option for full EP

This commit is contained in:
James Hensman 2012-12-06 11:30:12 -08:00
parent 9af637e214
commit ac84f4f34c
2 changed files with 5 additions and 3 deletions

View file

@ -51,7 +51,7 @@ class Full(EP_base):
self.K = K self.K = K
self.N = self.K.shape[0] self.N = self.K.shape[0]
EP_base.__init__(self,likelihood,*args,**kwargs) EP_base.__init__(self,likelihood,*args,**kwargs)
def fit_EP(self): def fit_EP(self,messages=False):
""" """
The expectation-propagation algorithm. The expectation-propagation algorithm.
For nomenclature see Rasmussen & Williams 2006 (pag. 52-60) 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) epsilon_np2 = np.mean(self.v_tilde-self.np2[-1]**2)
self.np1.append(self.tau_tilde.copy()) self.np1.append(self.tau_tilde.copy())
self.np2.append(self.v_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): class FITC(EP_base):
""" """

View file

@ -139,13 +139,13 @@ class GradientTests(unittest.TestCase):
m.constrain_positive('(linear|bias|white)') m.constrain_positive('(linear|bias|white)')
self.assertTrue(m.checkgrad()) self.assertTrue(m.checkgrad())
def test_simple_GP_EP(self): def test_GP_EP(self):
N = 20 N = 20
X = np.hstack([np.random.rand(N/2)+1,np.random.rand(N/2)-1])[:,None] 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) k = GPy.kern.rbf(1) + GPy.kern.white(1)
Y = np.hstack([np.ones(N/2),-np.ones(N/2)])[:,None] Y = np.hstack([np.ones(N/2),-np.ones(N/2)])[:,None]
likelihood = GPy.inference.likelihoods.probit(Y) 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.constrain_positive('(var|len)')
m.approximate_likelihood() m.approximate_likelihood()
self.assertTrue(m.checkgrad()) self.assertTrue(m.checkgrad())