FIXED DYTIL_DFHAT

This commit is contained in:
Alan Saul 2013-05-16 12:06:09 +01:00
parent 21ae81de29
commit e5d7ee9728
2 changed files with 5 additions and 5 deletions

View file

@ -105,12 +105,12 @@ class Laplace(likelihood):
#t1 += dWi_dfhat[col, col]*Ki[col,l]*self.f_hat[l, 0] #t1 += dWi_dfhat[col, col]*Ki[col,l]*self.f_hat[l, 0]
##t2 = np.zeros((1, self.N)) ##t2 = np.zeros((1, self.N))
#t2 = np.dot(self.Sigma_tilde, Ki[:, col]) #t2 = np.dot(self.Sigma_tilde, Ki[:, col])
##for k in range(self.N): ###for k in range(self.N):
##t2[:] += self.Sigma_tilde[k, k]*Ki[k, col] ###t2[:] += self.Sigma_tilde[k, k]*Ki[k, col]
#dytil_dfhat[row, col] = (t1 + t2)[row] #dytil_dfhat[row, col] = (t1 + t2)[row]
#dytil_dfhat += np.eye(self.N) #dytil_dfhat += np.eye(self.N)
dytil_dfhat = - np.dot(dWi_dfhat, np.dot(Ki, self.f_hat)) + np.dot(self.Sigma_tilde, Ki) + np.eye(self.N) dytil_dfhat = - np.diagflat(np.dot(dWi_dfhat, np.dot(Ki, self.f_hat))) + np.dot(self.Sigma_tilde, Ki) + np.eye(self.N)
#dytil_dfhat = - (np.dot(dWi_dfhat, Ki)*self.f_hat[:, None] + np.dot(self.Sigma_tilde, Ki)).sum(-1) + np.eye(self.N) #dytil_dfhat = - (np.dot(dWi_dfhat, Ki)*self.f_hat[:, None] + np.dot(self.Sigma_tilde, Ki)).sum(-1) + np.eye(self.N)
self.dytil_dfhat = dytil_dfhat self.dytil_dfhat = dytil_dfhat
return dL_dytil, dytil_dfhat return dL_dytil, dytil_dfhat

View file

@ -60,8 +60,8 @@ class LaplaceTests(unittest.TestCase):
def setUp(self): def setUp(self):
real_var = 0.1 real_var = 0.1
#Start a function, any function #Start a function, any function
#self.X = np.linspace(0.0, 10.0, 30)[:, None] self.X = np.linspace(0.0, 10.0, 30)[:, None]
self.X = np.random.randn(9,1) #self.X = np.random.randn(,1)
#self.X = np.ones((10,1)) #self.X = np.ones((10,1))
Y = np.sin(self.X) + np.random.randn(*self.X.shape)*real_var Y = np.sin(self.X) + np.random.randn(*self.X.shape)*real_var
self.Y = Y/Y.max() self.Y = Y/Y.max()