mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-04 17:22:39 +02:00
a simple test for fitc
This commit is contained in:
parent
d88c821c18
commit
c353ac67e6
1 changed files with 34 additions and 0 deletions
34
GPy/testing/fitc.py
Normal file
34
GPy/testing/fitc.py
Normal file
|
|
@ -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())
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue