From 68b68864a5098f9f42d0e1d9b0474a7bcc2c1995 Mon Sep 17 00:00:00 2001 From: thang Date: Mon, 12 Jun 2017 14:45:49 +0100 Subject: [PATCH] testing #19 for gpr aep -- not working --- examples/gpr_aep_examples.py | 17 ++++++++++------- geepee/base_models.py | 4 ---- tests/test_grads_aep.py | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/examples/gpr_aep_examples.py b/examples/gpr_aep_examples.py index 1d2be3b..ebc2250 100644 --- a/examples/gpr_aep_examples.py +++ b/examples/gpr_aep_examples.py @@ -9,7 +9,7 @@ from .datautils import step, spiral from .context import aep -def run_regression_1D(): +def run_regression_1D(nat_param=True): np.random.seed(42) print "create dataset ..." @@ -37,10 +37,12 @@ def plot(m): # inference print "create model and optimize ..." M = 20 - model = aep.SGPR(X, Y, M, lik='Gaussian') - model.optimise(method='L-BFGS-B', alpha=0.1, maxiter=50000) - plot(model) - plt.show() + model = aep.SGPR(X, Y, M, lik='Gaussian', nat_param=nat_param) + model.update_hypers(model.init_hypers(Y)) + print model.objective_function(model.get_hypers(), N, 0.1) + model.optimise(method='L-BFGS-B', alpha=0.1, maxiter=1) + # plot(model) + # plt.show() def run_banana(): @@ -307,11 +309,12 @@ def run_boston(): if __name__ == '__main__': - # run_regression_1D() + run_regression_1D(True) + run_regression_1D(False) # run_banana() # run_step_1D() # run_spiral() # run_boston() # run_regression_1D_stoc() - run_banana_stoc() + # run_banana_stoc() diff --git a/geepee/base_models.py b/geepee/base_models.py index d9ef4ad..4b072df 100644 --- a/geepee/base_models.py +++ b/geepee/base_models.py @@ -505,9 +505,6 @@ def compute_posterior_grad_u(self, dmu, dSu): return deta1_R, deta2, dKuuinv - - - def init_hypers(self, x_train=None, key_suffix=''): """Summary @@ -575,7 +572,6 @@ def init_hypers(self, x_train=None, key_suffix=''): triu_ind = np.triu_indices(M) diag_ind = np.diag_indices(M) R[diag_ind] = np.log(R[diag_ind]) - np.log(R[diag_ind]) eta1_d = R[triu_ind].reshape((M * (M + 1) / 2,)) eta2_d = theta2.reshape((M,)) eta1_R[d, :] = eta1_d diff --git a/tests/test_grads_aep.py b/tests/test_grads_aep.py index 5841d3f..8997235 100644 --- a/tests/test_grads_aep.py +++ b/tests/test_grads_aep.py @@ -5135,7 +5135,7 @@ def plot_gpssm_linear_aep_gaussian_stochastic(): # plot_gplvm_aep_probit_stochastic() # plot_gplvm_aep_gaussian_stochastic() - test_gpr_aep_gaussian(True) + # test_gpr_aep_gaussian(True) test_gpr_aep_gaussian(False) # test_gpr_aep_probit() # test_gpr_aep_gaussian_scipy()