mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-10 12:32:40 +02:00
Update self.num_data in GP when X is updated
This commit is contained in:
parent
40137cc8f7
commit
1e06c6ce2f
2 changed files with 16 additions and 3 deletions
|
|
@ -235,6 +235,8 @@ class GP(Model):
|
|||
self.link_parameter(self.X, index=index)
|
||||
else:
|
||||
self.X = ObsAr(X)
|
||||
|
||||
self.num_data, self.input_dim = self.X.shape
|
||||
self.update_model(True)
|
||||
|
||||
def set_X(self,X):
|
||||
|
|
|
|||
|
|
@ -28,12 +28,15 @@ class Test(unittest.TestCase):
|
|||
Xnew = NormalPosterior(m.X.mean[:10].copy(), m.X.variance[:10].copy())
|
||||
m.set_XY(Xnew, m.Y[:10].copy())
|
||||
assert(m.checkgrad())
|
||||
|
||||
assert(m.num_data == m.X.shape[0])
|
||||
assert(m.input_dim == m.X.shape[1])
|
||||
|
||||
m.set_XY(X, self.Y)
|
||||
mu2, var2 = m.predict(m.X)
|
||||
np.testing.assert_allclose(mu, mu2)
|
||||
np.testing.assert_allclose(var, var2)
|
||||
|
||||
|
||||
def test_setxy_gplvm(self):
|
||||
k = GPy.kern.RBF(1)
|
||||
m = GPy.models.GPLVM(self.Y, 1, kernel=k)
|
||||
|
|
@ -42,6 +45,10 @@ class Test(unittest.TestCase):
|
|||
Xnew = X[:10].copy()
|
||||
m.set_XY(Xnew, m.Y[:10].copy())
|
||||
assert(m.checkgrad())
|
||||
|
||||
assert(m.num_data == m.X.shape[0])
|
||||
assert(m.input_dim == m.X.shape[1])
|
||||
|
||||
m.set_XY(X, self.Y)
|
||||
mu2, var2 = m.predict(m.X)
|
||||
np.testing.assert_allclose(mu, mu2)
|
||||
|
|
@ -54,6 +61,10 @@ class Test(unittest.TestCase):
|
|||
X = m.X.copy()
|
||||
m.set_XY(m.X[:10], m.Y[:10])
|
||||
assert(m.checkgrad())
|
||||
|
||||
assert(m.num_data == m.X.shape[0])
|
||||
assert(m.input_dim == m.X.shape[1])
|
||||
|
||||
m.set_XY(X, self.Y)
|
||||
mu2, var2 = m.predict(m.X)
|
||||
np.testing.assert_allclose(mu, mu2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue