mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-17 15:35:20 +02:00
Corrected Multivariate Gaussian prior (#775)
* Corrected MultivariateGaussian prior Some corrections including adapting to current version of pdinv, correcting the expressions of constant, pdf and its gradient, and adding the printing function. After some tests, seems to run as expected, similarly to the Gaussian prior which was already working. * Added test of MultivariateGaussian prior Simple unit test for creating a kernel with Multivariate Gaussian prior over the lengthscales, then performing GP regression. * Took care of case where x of shape (n, 1) for multivariate Gaussian prior * Got rid of unnecessary asserts in Multivariate Gaussian prior since loss of time Co-authored-by: and <buisson-fenet@is.mpg.de>
This commit is contained in:
parent
46ce7c1680
commit
ff82f12c3d
2 changed files with 56 additions and 14 deletions
|
|
@ -936,6 +936,34 @@ class GradientTests(np.testing.TestCase):
|
|||
#import ipdb;ipdb.set_trace()
|
||||
#m.constrain_fixed('.*rbf_var', 1.)
|
||||
self.assertTrue(m.checkgrad())
|
||||
|
||||
def test_simple_MultivariateGaussian_prior(self):
|
||||
X = np.random.multivariate_normal(
|
||||
[1, 5], np.diag([0.5, 0.3]), (100, 1)).reshape(100, 2)
|
||||
Y = X + np.random.randn(100, 2) * 0.05
|
||||
kernel = GPy.kern.RBF(input_dim=2, variance=1,lengthscale=1, ARD=True)
|
||||
kernel.unconstrain()
|
||||
kernel.variance.set_prior(GPy.priors.Gaussian(150, 5))
|
||||
kernel.lengthscale.set_prior(GPy.priors.MultivariateGaussian(
|
||||
np.array([20, 20]), np.diag([5, 5])))
|
||||
m = GPy.models.GPRegression(X, Y, kernel=kernel)
|
||||
m.optimize()
|
||||
print(m.kern.variance)
|
||||
print(m.kern.lengthscale)
|
||||
|
||||
def test_simple_MultivariateGaussian_prior_matrixmean(self):
|
||||
X = np.random.multivariate_normal(
|
||||
[1, 5], np.diag([0.5, 0.3]), (100, 1)).reshape(100, 2)
|
||||
Y = X + np.random.randn(100, 2) * 0.05
|
||||
kernel = GPy.kern.RBF(input_dim=2, variance=1,lengthscale=1, ARD=True)
|
||||
kernel.unconstrain()
|
||||
kernel.variance.set_prior(GPy.priors.Gaussian(150, 5))
|
||||
kernel.lengthscale.set_prior(GPy.priors.MultivariateGaussian(
|
||||
np.array([[20, 20]]), np.diag([5, 5])))
|
||||
m = GPy.models.GPRegression(X, Y, kernel=kernel)
|
||||
m.optimize()
|
||||
print(m.kern.variance)
|
||||
print(m.kern.lengthscale)
|
||||
|
||||
def test_multioutput_sparse_regression_1D(self):
|
||||
X1 = np.random.rand(500, 1) * 8
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue