def test_mrd(self): from GPy.inference.latent_function_inference import InferenceMethodList, VarDTC from GPy.likelihoods import Gaussian Y1 = np.random.normal(0, 1, (40, 13)) Y2 = np.random.normal(0, 1, (40, 6)) Y3 = np.random.normal(0, 1, (40, 8)) Q = 5 m = GPy.models.MRD(dict(data1=Y1, data2=Y2, data3=Y3), Q, ) m.randomize() self.assertTrue(m.checkgrad()) m = GPy.models.MRD(dict(data1=Y1, data2=Y2, data3=Y3), Q, initx='PCA_single', initz='random', kernel=[GPy.kern.RBF(Q, ARD=1) for _ in range(3)], inference_method=InferenceMethodList([VarDTC() for _ in range(3)]), likelihoods = [Gaussian(name='Gaussian_noise'.format(i)) for i in range(3)]) m.randomize() self.assertTrue(m.checkgrad()) m = GPy.models.MRD(dict(data1=Y1, data2=Y2, data3=Y3), Q, initx='random', initz='random', kernel=GPy.kern.RBF(Q, ARD=1), ) m.randomize() self.assertTrue(m.checkgrad()) m = GPy.models.MRD(dict(data1=Y1, data2=Y2, data3=Y3), Q, X=np.random.normal(0,1,size=(40,Q)), X_variance=False, kernel=GPy.kern.RBF(Q, ARD=1), likelihoods = [Gaussian(name='Gaussian_noise'.format(i)) for i in range(3)]) m.randomize() self.assertTrue(m.checkgrad())
def __init__(self, X, Y, kernel, Y_variance, Z=None, num_inducing=25): # likelihood defaults to Gaussian likelihood = Gaussian(Y, variance=Y_variance) # Z defaults to a subset of the data if Z is None: i = np.random.permutation(X.shape[0])[:num_inducing] Z = X[i].copy() else: assert Z.shape[1] == X.shape[1] SparseGP.__init__(self, X, likelihood, kernel, Z) self.ensure_default_constraints()
def __init__(self, X, Y, kernel, Y_variance): # likelihood defaults to Gaussian likelihood = Gaussian(Y, variance=Y_variance) GP.__init__(self, X, likelihood, kernel) self.ensure_default_constraints()