Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FITC for multiple output dimensions #821

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions GPy/inference/latent_function_inference/fitc.py
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion GPy/testing/fitc.py
Expand Up @@ -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()
Expand All @@ -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())