From e976e01c435e814b3a9b2ffe5a93b6cc342addfa Mon Sep 17 00:00:00 2001 From: and Date: Fri, 27 Mar 2020 18:54:48 +0100 Subject: [PATCH] Fixed FITC inference for sparse GP regression with multiple input and output dimensions (was only working for multiple input but single output dimension) --- GPy/inference/latent_function_inference/fitc.py | 4 ++-- GPy/testing/fitc.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/GPy/inference/latent_function_inference/fitc.py b/GPy/inference/latent_function_inference/fitc.py index f38eb52b3..f69d18162 100644 --- a/GPy/inference/latent_function_inference/fitc.py +++ b/GPy/inference/latent_function_inference/fitc.py @@ -68,13 +68,13 @@ def inference(self, kern, X, Z, likelihood, Y, mean_function=None, Y_metadata=No # Compute dL_dKmm - vvT_P = tdot(v.reshape(-1,1)) + P + vvT_P = tdot(v) + P dL_dK = 0.5*(Kmmi - vvT_P) KiU = np.dot(Kmmi, U.T) dL_dK += np.dot(KiU*dL_dR, KiU.T) # Compute dL_dU - vY = np.dot(v.reshape(-1,1),Y.T) + vY = np.dot(v, Y.T) dL_dU = vY - np.dot(vvT_P, U.T) dL_dU *= beta_star dL_dU -= 2.*KiU*dL_dR diff --git a/GPy/testing/fitc.py b/GPy/testing/fitc.py index 58f009d27..7c5819ea5 100644 --- a/GPy/testing/fitc.py +++ b/GPy/testing/fitc.py @@ -16,12 +16,18 @@ def setUp(self): self.Y1D = np.sin(self.X1D) + np.random.randn(N, 1) * 0.05 ###################################### - # # 2 dimensional example + # # 2 dimensional example with 1 dimensional output # sample inputs and outputs self.X2D = np.random.uniform(-3., 3., (N, 2)) self.Y2D = np.sin(self.X2D[:, 0:1]) * np.sin(self.X2D[:, 1:2]) + np.random.randn(N, 1) * 0.05 + ###################################### + # # 2 dimensional example with 2 dimensional output + + # sample inputs and outputs + self.Y2D2D = np.sin(self.X2D) + np.random.randn(N, 2) * 0.05 + def test_fitc_1d(self): m = GPy.models.SparseGPRegression(self.X1D, self.Y1D) m.inference_method=GPy.inference.latent_function_inference.FITC() @@ -32,3 +38,8 @@ def test_fitc_2d(self): m.inference_method=GPy.inference.latent_function_inference.FITC() self.assertTrue(m.checkgrad()) + def test_fitc_2d2d(self): + m = GPy.models.SparseGPRegression(self.X2D, self.Y2D2D) + m.inference_method=GPy.inference.latent_function_inference.FITC() + self.assertTrue(m.checkgrad()) +