From c353ac67e6a43b50686e80ff66e49afcfa2ba7c4 Mon Sep 17 00:00:00 2001 From: James Hensman Date: Thu, 20 Mar 2014 09:23:52 +0000 Subject: [PATCH] a simple test for fitc --- GPy/testing/fitc.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 GPy/testing/fitc.py diff --git a/GPy/testing/fitc.py b/GPy/testing/fitc.py new file mode 100644 index 00000000..58f009d2 --- /dev/null +++ b/GPy/testing/fitc.py @@ -0,0 +1,34 @@ +# Copyright (c) 2014, James Hensman +# Licensed under the BSD 3-clause license (see LICENSE.txt) + +import unittest +import numpy as np +import GPy + +class FITCtest(unittest.TestCase): + def setUp(self): + ###################################### + # # 1 dimensional example + + N = 20 + # sample inputs and outputs + self.X1D = np.random.uniform(-3., 3., (N, 1)) + self.Y1D = np.sin(self.X1D) + np.random.randn(N, 1) * 0.05 + + ###################################### + # # 2 dimensional example + + # 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 + + def test_fitc_1d(self): + m = GPy.models.SparseGPRegression(self.X1D, self.Y1D) + m.inference_method=GPy.inference.latent_function_inference.FITC() + self.assertTrue(m.checkgrad()) + + def test_fitc_2d(self): + m = GPy.models.SparseGPRegression(self.X2D, self.Y2D) + m.inference_method=GPy.inference.latent_function_inference.FITC() + self.assertTrue(m.checkgrad()) +