diff --git a/GPy/examples/dimensionality_reduction.py b/GPy/examples/dimensionality_reduction.py index d7610acb..7095c55f 100644 --- a/GPy/examples/dimensionality_reduction.py +++ b/GPy/examples/dimensionality_reduction.py @@ -55,3 +55,31 @@ def GPLVM_oil_100(): print(m) m.plot_latent(labels=data['Y'].argmax(axis=1)) return m + + +def BGPLVM_oil(): + data = GPy.util.datasets.oil() + Y, X = data['Y'], data['X'] + X -= X.mean(axis=0) + # X /= X.std(axis=0) + + Q = 10 + M = 30 + + kernel = GPy.kern.rbf(Q, ARD = True) + GPy.kern.bias(Q) + GPy.kern.white(Q) + m = GPy.models.Bayesian_GPLVM(X, Q, kernel=kernel, M=M) + m.scale_factor = 10000.0 + m.constrain_positive('(white|noise|bias|X_variance|rbf_variance|rbf_length)') + from sklearn import cluster + km = cluster.KMeans(M, verbose=10) + Z = km.fit(m.X).cluster_centers_ + # Z = GPy.util.misc.kmm_init(m.X, M) + m.set('iip', Z) + # optimize + # m.ensure_default_constraints() + + import pdb; pdb.set_trace() + m.optimize('tnc', messages=1) + print m + m.plot_latent(labels=data['Y'].argmax(axis=1)) + return m diff --git a/GPy/inference/SGD.py b/GPy/inference/SGD.py index 4fb12b28..b4228bff 100644 --- a/GPy/inference/SGD.py +++ b/GPy/inference/SGD.py @@ -242,8 +242,8 @@ class opt_SGD(Optimizer): f, step, Nj = self.step_with_missing_data(f_fp, X, step, shapes, sparse_matrix) else: Nj = N - # momentum_term = self.momentum * step # compute momentum using update(t-1) f, fp = f_fp(self.x_opt) + # momentum_term = self.momentum * step # compute momentum using update(t-1) # step = self.learning_rate * fp # compute update(t) # self.x_opt -= step + momentum_term step = self.momentum * step + self.learning_rate * fp diff --git a/GPy/models/Bayesian_GPLVM.py b/GPy/models/Bayesian_GPLVM.py index 8f9759c3..6b80329c 100644 --- a/GPy/models/Bayesian_GPLVM.py +++ b/GPy/models/Bayesian_GPLVM.py @@ -27,7 +27,7 @@ class Bayesian_GPLVM(sparse_GP, GPLVM): X = self.initialise_latent(init, Q, Y) if S is None: - S = np.ones_like(X) * 1e-2# + S = np.ones_like(X) * 0.5 + np.random.randn(*X.shape) * 1e-3 if Z is None: Z = np.random.permutation(X.copy())[:M]