mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-05 14:55:15 +02:00
trying to fix bugs in kerns
This commit is contained in:
parent
7fbc6935d9
commit
03c1f77c08
6 changed files with 58 additions and 37 deletions
|
|
@ -7,17 +7,17 @@ import GPy
|
|||
np.random.seed(123344)
|
||||
|
||||
N = 10
|
||||
M = 5
|
||||
Q = 3
|
||||
D = 4
|
||||
M = 3
|
||||
Q = 4
|
||||
D = 5
|
||||
#generate GPLVM-like data
|
||||
X = np.random.rand(N, Q)
|
||||
k = GPy.kern.rbf(Q) + GPy.kern.white(Q, 0.00001)
|
||||
K = k.K(X)
|
||||
Y = np.random.multivariate_normal(np.zeros(N),K,D).T
|
||||
|
||||
# k = GPy.kern.rbf(Q) + GPy.kern.bias(Q) + GPy.kern.white(Q, 0.00001)
|
||||
k = GPy.kern.linear(Q, ARD = True) + GPy.kern.white(Q, 0.00001)
|
||||
k = GPy.kern.rbf(Q) + GPy.kern.rbf(Q) + GPy.kern.white(Q)
|
||||
# k = GPy.kern.linear(Q, ARD = True) + GPy.kern.white(Q, 0.00001)
|
||||
m = GPy.models.Bayesian_GPLVM(Y, Q, kernel = k, M=M)
|
||||
m.constrain_positive('(rbf|bias|noise|white|S)')
|
||||
# m.constrain_fixed('S', 1)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import numpy as np
|
|||
import pylab as pb
|
||||
import GPy
|
||||
import pylab as plt
|
||||
np.random.seed(1)
|
||||
np.random.seed(3)
|
||||
|
||||
def plot_oil(X, theta, labels, label):
|
||||
plt.figure()
|
||||
|
|
@ -24,25 +24,27 @@ data = pickle.load(open('../../../GPy_assembla/datasets/oil_flow_3classes.pickle
|
|||
|
||||
Y = data['DataTrn']
|
||||
N, D = Y.shape
|
||||
selected = np.random.permutation(N)#[:200]
|
||||
selected = np.random.permutation(N)[:350]
|
||||
labels = data['DataTrnLbls'][selected]
|
||||
Y = Y[selected]
|
||||
N, D = Y.shape
|
||||
Y -= Y.mean(axis=0)
|
||||
#Y /= Y.std(axis=0)
|
||||
# Y /= Y.std(axis=0)
|
||||
|
||||
Q = 10
|
||||
k = GPy.kern.rbf_ARD(Q) + GPy.kern.white(Q)
|
||||
m = GPy.models.Bayesian_GPLVM(Y, Q, kernel = k, M = 12)
|
||||
m.constrain_positive('(rbf|bias|S|white|noise)')
|
||||
# m.constrain_bounded('white', 1e-6, 100.0)
|
||||
# m.constrain_bounded('noise', 1e-4, 1000.0)
|
||||
Q = 5
|
||||
k = GPy.kern.linear(Q, ARD = False) + GPy.kern.white(Q)
|
||||
m = GPy.models.Bayesian_GPLVM(Y, Q, kernel = k, M = 20)
|
||||
m.constrain_positive('(rbf|bias|S|linear|white|noise)')
|
||||
|
||||
plot_oil(m.X, np.array([1,1]), labels, 'PCA initialization')
|
||||
# m.optimize(messages = True)
|
||||
m.optimize('tnc', messages = True)
|
||||
plot_oil(m.X, m.kern.parts[0].lengthscales, labels, 'B-GPLVM')
|
||||
# pb.figure()
|
||||
# m.unconstrain('noise')
|
||||
# m.constrain_fixed('noise_precision', 50.0)
|
||||
# m.unconstrain('white')
|
||||
# m.constrain_bounded('white', 1e-6, 10.0)
|
||||
# plot_oil(m.X, np.array([1,1]), labels, 'PCA initialization')
|
||||
m.optimize(messages = True)
|
||||
# m.optimize('tnc', messages = True)
|
||||
plot_oil(m.X, m.kern.parts[0].lengthscale, labels, 'B-GPLVM')
|
||||
# # pb.figure()
|
||||
# m.plot()
|
||||
# pb.title('PCA initialisation')
|
||||
# pb.figure()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue