From 78b50db138beff11ea528e6155d2a1bd28554d2c Mon Sep 17 00:00:00 2001 From: Zhenwen Dai Date: Mon, 3 Nov 2014 13:38:28 +0000 Subject: [PATCH 1/5] add new inference X --- GPy/core/parameterization/variational.py | 6 + .../latent_function_inference/inferenceX.py | 127 ++++++++++++++++++ GPy/models/bayesian_gplvm.py | 16 +++ 3 files changed, 149 insertions(+) create mode 100644 GPy/inference/latent_function_inference/inferenceX.py diff --git a/GPy/core/parameterization/variational.py b/GPy/core/parameterization/variational.py index 251ec7db..e2a24008 100644 --- a/GPy/core/parameterization/variational.py +++ b/GPy/core/parameterization/variational.py @@ -94,6 +94,9 @@ class VariationalPosterior(Parameterized): if self.has_uncertain_inputs(): assert self.variance.shape == self.mean.shape, "need one variance per sample and dimenion" + def set_gradients(self, grad): + self.mean.gradient, self.variance.gradient = grad + def _raveled_index(self): index = np.empty(dtype=int, shape=0) size = 0 @@ -158,6 +161,9 @@ class SpikeAndSlabPosterior(VariationalPosterior): self.gamma = Param("binary_prob",binary_prob, Logistic(1e-10,1.-1e-10)) self.link_parameter(self.gamma) + def set_gradients(self, grad): + self.mean.gradient, self.variance.gradient, self.gamma.gradient = grad + def __getitem__(self, s): if isinstance(s, (int, slice, tuple, list, np.ndarray)): import copy diff --git a/GPy/inference/latent_function_inference/inferenceX.py b/GPy/inference/latent_function_inference/inferenceX.py new file mode 100644 index 00000000..9828c4a1 --- /dev/null +++ b/GPy/inference/latent_function_inference/inferenceX.py @@ -0,0 +1,127 @@ +""" +""" +import numpy as np +from ...core import Model +from ...core.parameterization import variational + +def infer_newX(model, Y_new, optimize=True, init='L2'): + """ + Infer the distribution of X for the new observed data *Y_new*. + + :param model: the GPy model used in inference + :type model: GPy.core.Model + :param Y_new: the new observed data for inference + :type Y_new: numpy.ndarray + :param optimize: whether to optimize the location of new X (True by default) + :type optimize: boolean + :return: a tuple containing the estimated posterior distribution of X and the model that optimize X + :rtype: (GPy.core.parameterization.variational.VariationalPosterior, GPy.core.Model) + """ + infr_m = InferenceX(model, Y_new, init=init) + + if optimize: + infr_m.optimize() + + return infr_m.X, infr_m + +class InferenceX(Model): + """ + The class for inference of new X with given new Y. (do_test_latent) + + :param model: the GPy model used in inference + :type model: GPy.core.Model + :param Y: the new observed data for inference + :type Y: numpy.ndarray + """ + def __init__(self, model, Y, name='inferenceX', init='L2'): + if np.isnan(Y).any(): + assert Y.shape[0]==1, "The current implementation of inference X only support one data point at a time with missing data!" + self.missing_data = True + self.valid_dim = np.logical_not(np.isnan(Y[0])) + else: + self.missing_data = False + super(InferenceX, self).__init__(name) + self.likelihood = model.likelihood.copy() + self.kern = model.kern.copy() + if model.kern.useGPU: + from ...models import SSGPLVM + if isinstance(model, SSGPLVM): + self.kern.GPU_SSRBF(True) + else: + self.kern.GPU(True) + from copy import deepcopy + self.posterior = deepcopy(model.posterior) + self.variational_prior = model.variational_prior.copy() + self.Z = model.Z.copy() + self.Y = Y + self.X = self._init_X(model, Y, init=init) + self.compute_dL() + + self.link_parameter(self.X) + + def _init_X(self, model, Y_new, init='L2'): + # Initialize the new X by finding the nearest point in Y space. + + Y = model.Y + if self.missing_data: + Y = Y[:,self.valid_dim] + Y_new = Y_new[:,self.valid_dim] + dist = -2.*Y_new.dot(Y.T) + np.square(Y_new).sum(axis=1)[:,None]+ np.square(Y).sum(axis=1)[None,:] + else: + if init=='L2': + dist = -2.*Y_new.dot(Y.T) + np.square(Y_new).sum(axis=1)[:,None]+ np.square(Y).sum(axis=1)[None,:] + elif init=='NCC': + dist = Y_new.dot(Y.T) + idx = dist.argmin(axis=1) + + from ...models import SSGPLVM + from ...util.misc import param_to_array + if isinstance(model, SSGPLVM): + X = variational.SpikeAndSlabPosterior(param_to_array(model.X.mean[idx]), param_to_array(model.X.variance[idx]), param_to_array(model.X.gamma[idx])) + if model.group_spike: + X.gamma.fix() + else: + X = variational.NormalPosterior(param_to_array(model.X.mean[idx]), param_to_array(model.X.variance[idx])) + + return X + + def compute_dL(self): + # Common computation + beta = 1./np.fmax(self.likelihood.variance, 1e-6) + output_dim = self.Y.shape[-1] + wv = self.posterior.woodbury_vector + if self.missing_data: + wv = wv[:,self.valid_dim] + output_dim = self.valid_dim.sum() + self.dL_dpsi2 = beta*(output_dim*self.posterior.woodbury_inv - np.einsum('md,od->mo',wv, wv))/2. + self.dL_dpsi1 = beta*np.dot(self.Y[:,self.valid_dim], wv.T) + self.dL_dpsi0 = -output_dim * beta/2.* np.ones(self.Y.shape[0]) + else: + self.dL_dpsi2 = beta*(output_dim*self.posterior.woodbury_inv - np.einsum('md,od->mo',wv, wv))/2. + self.dL_dpsi1 = beta*np.dot(self.Y, wv.T) + self.dL_dpsi0 = -output_dim * beta/2.* np.ones(self.Y.shape[0]) + + def parameters_changed(self): + psi0 = self.kern.psi0(self.Z, self.X) + psi1 = self.kern.psi1(self.Z, self.X) + psi2 = self.kern.psi2(self.Z, self.X) + + self._log_marginal_likelihood = (self.dL_dpsi2*psi2).sum()+(self.dL_dpsi1*psi1).sum()+(self.dL_dpsi0*psi0).sum() + X_grad = self.kern.gradients_qX_expectations(variational_posterior=self.X, Z=self.Z, dL_dpsi0=self.dL_dpsi0, dL_dpsi1=self.dL_dpsi1, dL_dpsi2=self.dL_dpsi2) + self.X.set_gradients(X_grad) + + from ...core.parameterization.variational import SpikeAndSlabPrior + if isinstance(self.variational_prior, SpikeAndSlabPrior): + # Update Log-likelihood + KL_div = self.variational_prior.KL_divergence(self.X, N=self.Y.shape[0]) + # update for the KL divergence + self.variational_prior.update_gradients_KL(self.X, N=self.Y.shape[0]) + else: + # Update Log-likelihood + KL_div = self.variational_prior.KL_divergence(self.X) + # update for the KL divergence + self.variational_prior.update_gradients_KL(self.X) + + def log_likelihood(self): + return self._log_marginal_likelihood + diff --git a/GPy/models/bayesian_gplvm.py b/GPy/models/bayesian_gplvm.py index c4d0b6e9..b2eed718 100644 --- a/GPy/models/bayesian_gplvm.py +++ b/GPy/models/bayesian_gplvm.py @@ -175,6 +175,22 @@ class BayesianGPLVM(SparseGP_MPI): resolution, ax, marker, s, fignum, plot_inducing, legend, plot_limits, aspect, updates, predict_kwargs, imshow_kwargs) + + def infer_newX(self, Y_new, optimize=True, ): + """ + Infer the distribution of X for the new observed data *Y_new*. + + :param model: the GPy model used in inference + :type model: GPy.core.Model + :param Y_new: the new observed data for inference + :type Y_new: numpy.ndarray + :param optimize: whether to optimize the location of new X (True by default) + :type optimize: boolean + :return: a tuple containing the estimated posterior distribution of X and the model that optimize X + :rtype: (GPy.core.parameterization.variational.VariationalPosterior, GPy.core.Model) + """ + from ..inference.latent_function_inference.inferenceX import infer_newX + return infer_newX(self, Y_new, optimize=optimize) def do_test_latents(self, Y): """ From 24ad425a1ba75ddfbdad8c546307d69657527b36 Mon Sep 17 00:00:00 2001 From: Zhenwen Dai Date: Mon, 3 Nov 2014 14:11:46 +0000 Subject: [PATCH 2/5] bug fix for inferenceX --- GPy/inference/latent_function_inference/inferenceX.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/GPy/inference/latent_function_inference/inferenceX.py b/GPy/inference/latent_function_inference/inferenceX.py index 9828c4a1..7480c910 100644 --- a/GPy/inference/latent_function_inference/inferenceX.py +++ b/GPy/inference/latent_function_inference/inferenceX.py @@ -95,11 +95,11 @@ class InferenceX(Model): output_dim = self.valid_dim.sum() self.dL_dpsi2 = beta*(output_dim*self.posterior.woodbury_inv - np.einsum('md,od->mo',wv, wv))/2. self.dL_dpsi1 = beta*np.dot(self.Y[:,self.valid_dim], wv.T) - self.dL_dpsi0 = -output_dim * beta/2.* np.ones(self.Y.shape[0]) + self.dL_dpsi0 = - beta/2.* np.ones(self.Y.shape[0]) else: self.dL_dpsi2 = beta*(output_dim*self.posterior.woodbury_inv - np.einsum('md,od->mo',wv, wv))/2. self.dL_dpsi1 = beta*np.dot(self.Y, wv.T) - self.dL_dpsi0 = -output_dim * beta/2.* np.ones(self.Y.shape[0]) + self.dL_dpsi0 = -beta/2.* np.ones(self.Y.shape[0]) #self.dL_dpsi0[:] = 0 def parameters_changed(self): psi0 = self.kern.psi0(self.Z, self.X) @@ -121,6 +121,7 @@ class InferenceX(Model): KL_div = self.variational_prior.KL_divergence(self.X) # update for the KL divergence self.variational_prior.update_gradients_KL(self.X) + self._log_marginal_likelihood += -KL_div def log_likelihood(self): return self._log_marginal_likelihood From 871405e3e4721ae4f31efb5add8dc0e6d48500df Mon Sep 17 00:00:00 2001 From: Zhenwen Dai Date: Mon, 3 Nov 2014 14:22:01 +0000 Subject: [PATCH 3/5] add test cases for inference new X for bayesian GPLVM --- GPy/testing/inference_tests.py | 71 ++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 GPy/testing/inference_tests.py diff --git a/GPy/testing/inference_tests.py b/GPy/testing/inference_tests.py new file mode 100644 index 00000000..c7efa821 --- /dev/null +++ b/GPy/testing/inference_tests.py @@ -0,0 +1,71 @@ + +""" +The test cases for various inference algorithms +""" + +import unittest, itertools +import numpy as np +import GPy + + +class InferenceXTestCase(unittest.TestCase): + + def genData(self): + D1,D2,N = 12,12,50 + np.random.seed(1234) + + x = np.linspace(0, 4 * np.pi, N)[:, None] + s1 = np.vectorize(lambda x: np.sin(x)) + s2 = np.vectorize(lambda x: np.cos(x)**2) + s3 = np.vectorize(lambda x:-np.exp(-np.cos(2 * x))) + sS = np.vectorize(lambda x: np.cos(x)) + + s1 = s1(x) + s2 = s2(x) + s3 = s3(x) + sS = sS(x) + + s1 -= s1.mean(); s1 /= s1.std(0) + s2 -= s2.mean(); s2 /= s2.std(0) + s3 -= s3.mean(); s3 /= s3.std(0) + sS -= sS.mean(); sS /= sS.std(0) + + S1 = np.hstack([s1, sS]) + S2 = np.hstack([s3, sS]) + + P1 = np.random.randn(S1.shape[1], D1) + P2 = np.random.randn(S2.shape[1], D2) + + Y1 = S1.dot(P1) + Y2 = S2.dot(P2) + + Y1 += .01 * np.random.randn(*Y1.shape) + Y2 += .01 * np.random.randn(*Y2.shape) + + Y1 -= Y1.mean(0) + Y2 -= Y2.mean(0) + Y1 /= Y1.std(0) + Y2 /= Y2.std(0) + + slist = [s1, s2, s3, sS] + slist_names = ["s1", "s2", "s3", "sS"] + Ylist = [Y1, Y2] + + return Ylist + + def test_inferenceX_BGPLVM(self): + Ys = self.genData() + m = GPy.models.BayesianGPLVM(Ys[0],5,kernel=GPy.kern.Linear(5,ARD=True)) + + x,mi = m.infer_newX(m.Y, optimize=False) + self.assertTrue(mi.checkgrad()) + + m.optimize(max_iters=10000) + x,mi = m.infer_newX(m.Y) + + self.assertTrue(np.allclose(m.X.mean, mi.X.mean)) + self.assertTrue(np.allclose(m.X.variance, mi.X.variance)) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file From 13fd45e31f146faef9a921b591a8b24e6788db9e Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Mon, 3 Nov 2014 14:39:17 +0000 Subject: [PATCH 4/5] Minor doc changes, fixed MPI dependency and 'stop' in var_dtc --- .../latent_function_inference/var_dtc.py | 2 +- GPy/util/parallel.py | 11 +- ...Py.inference.latent_function_inference.rst | 8 + doc/GPy.inference.mcmc.rst | 30 +++ doc/GPy.kern.parts.rst | 246 ------------------ doc/GPy.likelihoods.noise_models.rst | 70 ----- doc/GPy.models.rst | 16 ++ doc/GPy.testing.rst | 8 + ...atent_space_visualizations.controllers.rst | 30 --- doc/GPy.util.latent_space_visualizations.rst | 17 -- doc/conf.py | 10 +- 11 files changed, 74 insertions(+), 374 deletions(-) create mode 100644 doc/GPy.inference.mcmc.rst delete mode 100644 doc/GPy.kern.parts.rst delete mode 100644 doc/GPy.likelihoods.noise_models.rst delete mode 100644 doc/GPy.util.latent_space_visualizations.controllers.rst delete mode 100644 doc/GPy.util.latent_space_visualizations.rst diff --git a/GPy/inference/latent_function_inference/var_dtc.py b/GPy/inference/latent_function_inference/var_dtc.py index 0459132a..cfc2bb47 100644 --- a/GPy/inference/latent_function_inference/var_dtc.py +++ b/GPy/inference/latent_function_inference/var_dtc.py @@ -167,7 +167,7 @@ class VarDTC(LatentFunctionInference): woodbury_vector = Cpsi1Vf # == Cpsi1V else: print 'foobar' - stop + import ipdb; ipdb.set_trace() psi1V = np.dot(Y.T*beta, psi1).T tmp, _ = dtrtrs(Lm, psi1V, lower=1, trans=0) tmp, _ = dpotrs(LB, tmp, lower=1) diff --git a/GPy/util/parallel.py b/GPy/util/parallel.py index fd8791d4..bc847c95 100644 --- a/GPy/util/parallel.py +++ b/GPy/util/parallel.py @@ -4,11 +4,10 @@ The module of tools for parallelization (MPI) try: from mpi4py import MPI + def get_id_within_node(comm=MPI.COMM_WORLD): + rank = comm.rank + nodename = MPI.Get_processor_name() + nodelist = comm.allgather(nodename) + return len([i for i in nodelist[:rank] if i==nodename]) except: pass - -def get_id_within_node(comm=MPI.COMM_WORLD): - rank = comm.rank - nodename = MPI.Get_processor_name() - nodelist = comm.allgather(nodename) - return len([i for i in nodelist[:rank] if i==nodename]) diff --git a/doc/GPy.inference.latent_function_inference.rst b/doc/GPy.inference.latent_function_inference.rst index c47da33a..98d16705 100644 --- a/doc/GPy.inference.latent_function_inference.rst +++ b/doc/GPy.inference.latent_function_inference.rst @@ -44,6 +44,14 @@ GPy.inference.latent_function_inference.fitc module :undoc-members: :show-inheritance: +GPy.inference.latent_function_inference.inferenceX module +--------------------------------------------------------- + +.. automodule:: GPy.inference.latent_function_inference.inferenceX + :members: + :undoc-members: + :show-inheritance: + GPy.inference.latent_function_inference.laplace module ------------------------------------------------------ diff --git a/doc/GPy.inference.mcmc.rst b/doc/GPy.inference.mcmc.rst new file mode 100644 index 00000000..273658b7 --- /dev/null +++ b/doc/GPy.inference.mcmc.rst @@ -0,0 +1,30 @@ +GPy.inference.mcmc package +========================== + +Submodules +---------- + +GPy.inference.mcmc.hmc module +----------------------------- + +.. automodule:: GPy.inference.mcmc.hmc + :members: + :undoc-members: + :show-inheritance: + +GPy.inference.mcmc.samplers module +---------------------------------- + +.. automodule:: GPy.inference.mcmc.samplers + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: GPy.inference.mcmc + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/GPy.kern.parts.rst b/doc/GPy.kern.parts.rst deleted file mode 100644 index ec0661b4..00000000 --- a/doc/GPy.kern.parts.rst +++ /dev/null @@ -1,246 +0,0 @@ -GPy.kern.parts package -====================== - -Submodules ----------- - -GPy.kern.parts.Brownian module ------------------------------- - -.. automodule:: GPy.kern.parts.Brownian - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.Matern32 module ------------------------------- - -.. automodule:: GPy.kern.parts.Matern32 - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.Matern52 module ------------------------------- - -.. automodule:: GPy.kern.parts.Matern52 - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.bias module --------------------------- - -.. automodule:: GPy.kern.parts.bias - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.coregionalize module ------------------------------------ - -.. automodule:: GPy.kern.parts.coregionalize - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.exponential module ---------------------------------- - -.. automodule:: GPy.kern.parts.exponential - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.finite_dimensional module ----------------------------------------- - -.. automodule:: GPy.kern.parts.finite_dimensional - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.fixed module ---------------------------- - -.. automodule:: GPy.kern.parts.fixed - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.gibbs module ---------------------------- - -.. automodule:: GPy.kern.parts.gibbs - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.hetero module ----------------------------- - -.. automodule:: GPy.kern.parts.hetero - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.hierarchical module ----------------------------------- - -.. automodule:: GPy.kern.parts.hierarchical - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.independent_outputs module ------------------------------------------ - -.. automodule:: GPy.kern.parts.independent_outputs - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.kernpart module ------------------------------- - -.. automodule:: GPy.kern.parts.kernpart - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.linear module ----------------------------- - -.. automodule:: GPy.kern.parts.linear - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.mlp module -------------------------- - -.. automodule:: GPy.kern.parts.mlp - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.periodic_Matern32 module ---------------------------------------- - -.. automodule:: GPy.kern.parts.periodic_Matern32 - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.periodic_Matern52 module ---------------------------------------- - -.. automodule:: GPy.kern.parts.periodic_Matern52 - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.periodic_exponential module ------------------------------------------- - -.. automodule:: GPy.kern.parts.periodic_exponential - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.poly module --------------------------- - -.. automodule:: GPy.kern.parts.poly - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.prod module --------------------------- - -.. automodule:: GPy.kern.parts.prod - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.prod_orthogonal module -------------------------------------- - -.. automodule:: GPy.kern.parts.prod_orthogonal - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.rational_quadratic module ----------------------------------------- - -.. automodule:: GPy.kern.parts.rational_quadratic - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.rbf module -------------------------- - -.. automodule:: GPy.kern.parts.rbf - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.rbf_inv module ------------------------------ - -.. automodule:: GPy.kern.parts.rbf_inv - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.rbfcos module ----------------------------- - -.. automodule:: GPy.kern.parts.rbfcos - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.spline module ----------------------------- - -.. automodule:: GPy.kern.parts.spline - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.symmetric module -------------------------------- - -.. automodule:: GPy.kern.parts.symmetric - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.sympykern module -------------------------------- - -.. automodule:: GPy.kern.parts.sympykern - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.parts.white module ---------------------------- - -.. automodule:: GPy.kern.parts.white - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.kern.parts - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/GPy.likelihoods.noise_models.rst b/doc/GPy.likelihoods.noise_models.rst deleted file mode 100644 index d1a4f451..00000000 --- a/doc/GPy.likelihoods.noise_models.rst +++ /dev/null @@ -1,70 +0,0 @@ -GPy.likelihoods.noise_models package -==================================== - -Submodules ----------- - -GPy.likelihoods.noise_models.binomial_noise module --------------------------------------------------- - -.. automodule:: GPy.likelihoods.noise_models.binomial_noise - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.noise_models.exponential_noise module ------------------------------------------------------ - -.. automodule:: GPy.likelihoods.noise_models.exponential_noise - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.noise_models.gamma_noise module ------------------------------------------------ - -.. automodule:: GPy.likelihoods.noise_models.gamma_noise - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.noise_models.gaussian_noise module --------------------------------------------------- - -.. automodule:: GPy.likelihoods.noise_models.gaussian_noise - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.noise_models.gp_transformations module ------------------------------------------------------- - -.. automodule:: GPy.likelihoods.noise_models.gp_transformations - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.noise_models.noise_distributions module -------------------------------------------------------- - -.. automodule:: GPy.likelihoods.noise_models.noise_distributions - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.noise_models.poisson_noise module -------------------------------------------------- - -.. automodule:: GPy.likelihoods.noise_models.poisson_noise - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.likelihoods.noise_models - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/GPy.models.rst b/doc/GPy.models.rst index 5ee7e3a9..cb043afa 100644 --- a/doc/GPy.models.rst +++ b/doc/GPy.models.rst @@ -12,6 +12,14 @@ GPy.models.bayesian_gplvm module :undoc-members: :show-inheritance: +GPy.models.bayesian_gplvm_minibatch module +------------------------------------------ + +.. automodule:: GPy.models.bayesian_gplvm_minibatch + :members: + :undoc-members: + :show-inheritance: + GPy.models.bcgplvm module ------------------------- @@ -116,6 +124,14 @@ GPy.models.sparse_gp_coregionalized_regression module :undoc-members: :show-inheritance: +GPy.models.sparse_gp_minibatch module +------------------------------------- + +.. automodule:: GPy.models.sparse_gp_minibatch + :members: + :undoc-members: + :show-inheritance: + GPy.models.sparse_gp_multioutput_regression module -------------------------------------------------- diff --git a/doc/GPy.testing.rst b/doc/GPy.testing.rst index 2d1132d7..45bb307f 100644 --- a/doc/GPy.testing.rst +++ b/doc/GPy.testing.rst @@ -28,6 +28,14 @@ GPy.testing.index_operations_tests module :undoc-members: :show-inheritance: +GPy.testing.inference_tests module +---------------------------------- + +.. automodule:: GPy.testing.inference_tests + :members: + :undoc-members: + :show-inheritance: + GPy.testing.kernel_tests module ------------------------------- diff --git a/doc/GPy.util.latent_space_visualizations.controllers.rst b/doc/GPy.util.latent_space_visualizations.controllers.rst deleted file mode 100644 index a88c1f5c..00000000 --- a/doc/GPy.util.latent_space_visualizations.controllers.rst +++ /dev/null @@ -1,30 +0,0 @@ -GPy.util.latent_space_visualizations.controllers package -======================================================== - -Submodules ----------- - -GPy.util.latent_space_visualizations.controllers.axis_event_controller module ------------------------------------------------------------------------------ - -.. automodule:: GPy.util.latent_space_visualizations.controllers.axis_event_controller - :members: - :undoc-members: - :show-inheritance: - -GPy.util.latent_space_visualizations.controllers.imshow_controller module -------------------------------------------------------------------------- - -.. automodule:: GPy.util.latent_space_visualizations.controllers.imshow_controller - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.util.latent_space_visualizations.controllers - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/GPy.util.latent_space_visualizations.rst b/doc/GPy.util.latent_space_visualizations.rst deleted file mode 100644 index d8cbd843..00000000 --- a/doc/GPy.util.latent_space_visualizations.rst +++ /dev/null @@ -1,17 +0,0 @@ -GPy.util.latent_space_visualizations package -============================================ - -Subpackages ------------ - -.. toctree:: - - GPy.util.latent_space_visualizations.controllers - -Module contents ---------------- - -.. automodule:: GPy.util.latent_space_visualizations - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/conf.py b/doc/conf.py index 7b71a897..f051c986 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -11,6 +11,9 @@ # All configuration values have a default; values that are commented out # serve to show the default. +autodoc_default_flags = ['members', 'show-inheritance', 'private-members', 'special-members'] +autodoc_member_order = "source" + import sys import os @@ -114,7 +117,7 @@ for mod_name in MOCK_MODULES: # ----------------------- READTHEDOCS ------------------ on_rtd = os.environ.get('READTHEDOCS', None) == 'True' -on_rtd = True +#on_rtd = True if on_rtd: sys.path.append(os.path.abspath('../GPy')) @@ -126,7 +129,8 @@ if on_rtd: proc = subprocess.Popen("ls ../", stdout=subprocess.PIPE, shell=True) (out, err) = proc.communicate() print "program output:", out - proc = subprocess.Popen("sphinx-apidoc -f -o . ../GPy", stdout=subprocess.PIPE, shell=True) + #proc = subprocess.Popen("sphinx-apidoc -f -o . ../GPy", stdout=subprocess.PIPE, shell=True) + proc = subprocess.Popen("make html", stdout=subprocess.PIPE, shell=True) (out, err) = proc.communicate() print "program output:", out #proc = subprocess.Popen("whereis numpy", stdout=subprocess.PIPE, shell=True) @@ -397,5 +401,3 @@ epub_copyright = u'2013, Author' # Allow duplicate toc entries. #epub_tocdup = True - -autodoc_member_order = "source" From 71523427e4a2c805f97794b8fe915c72e1dec18c Mon Sep 17 00:00:00 2001 From: Neil Lawrence Date: Mon, 3 Nov 2014 14:43:38 +0000 Subject: [PATCH 5/5] Removed ordinal.py (to Symbolic). --- GPy/likelihoods/ordinal.py | 47 -------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 GPy/likelihoods/ordinal.py diff --git a/GPy/likelihoods/ordinal.py b/GPy/likelihoods/ordinal.py deleted file mode 100644 index b6855e54..00000000 --- a/GPy/likelihoods/ordinal.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (c) 2014 The GPy authors (see AUTHORS.txt) -# Licensed under the BSD 3-clause license (see LICENSE.txt) - - -import sympy as sym -from GPy.util.symbolic import gammaln, normcdfln, normcdf, IndMatrix, create_matrix -import numpy as np -import link_functions -from symbolic import Symbolic -from scipy import stats - -class Ordinal(Symbolic): - """ - Ordinal - - .. math:: - p(y_{i}|\pi(f_{i})) = \left(\frac{r}{r+f_i}\right)^r \frac{\Gamma(r+y_i)}{y!\Gamma(r)}\left(\frac{f_i}{r+f_i}\right)^{y_i} - - .. Note:: - Y takes non zero integer values.. - link function should have a positive domain, e.g. log (default). - - .. See also:: - symbolic.py, for the parent class - """ - def __init__(self, categories=3, gp_link=None): - if gp_link is None: - gp_link = link_functions.Identity() - - dispersion = sym.Symbol('width', positive=True, real=True) - y_0 = sym.Symbol('y_0', nonnegative=True, integer=True) - f_0 = sym.Symbol('f_0', positive=True, real=True) - log_pdf = create_matrix('log_pdf', 1, categories) - log_pdf[0] = normcdfln(-f_0) - if categories>2: - w = create_matrix('w', 1, categories) - log_pdf[categories-1] = normcdfln(w.sum() + f_0) - for i in range(1, categories-1): - log_pdf[i] = sym.log(normcdf(w[0, 0:i-1].sum() + f_0) - normcdf(w[0, 0:i].sum()-f_0) ) - else: - log_pdf[1] = normcdfln(f_0) - log_pdf.index_var = y_0 - super(Ordinal, self).__init__(log_pdf=log_pdf, gp_link=gp_link, name='Ordinal') - - # TODO: Check this. - self.log_concave = True -