示例#1
0
#Y = Y[0:10, :]
numData = Y.shape[0]
d = Y.shape[1]
#v, X = netlab.pca(Y.transpose(), q)
X = numpy.random.normal(0.0, 1e-1, (numData, 2))
Xstore = X;
Xstor = numpy.empty(Xstore.shape)
Ystore = Y;
Y = ndlwrap.fromarray(Y)
X = ndlwrap.fromarray(X)

# Set up kernel function
kern = nl.cmpndKern()

kern1 = nl.rbfKern(X)
kern2 = nl.biasKern(X)
kern3 = nl.whiteKern(X)
kern3.setVariance(1e-3)

kern.addKern(kern1)
kern.addKern(kern2)
kern.addKern(kern3)


noise = nl.gaussianNoise(Y)

# Create a GP model.
model = nl.gp(q, d, X, Y, kern, noise, nl.gp.DTCVAR, 100, 3)
model.setBetaVals(math.exp(2))
#pdb.set_trace()
model.setDefaultOptimiser(nl.gp.CG)
Y, lbls = datasets.lvmLoadData('oil100')
d = Y.shape[0]
numData = Y.shape[1]
v, X = netlab.pca(Y.transpose(), q)
X = numpy.random.normal(0.0, 1e-6, (Y.shape[0], 2))
Xstore = X;
Xstor = numpy.empty(Xstore.shape)
Ystore = Y;
Y = ndlwrap.fromarray(Y)
X = ndlwrap.fromarray(X)

# Set up kernel function
kern = ndlml.cmpndKern()

kern1 = ndlml.rbfKern(X)
kern2 = ndlml.biasKern(X)
kern3 = ndlml.whiteKern(X)

kern.addKern(kern1)
kern.addKern(kern2)
kern.addKern(kern3)


noise = ndlml.gaussianNoise(Y)

# Create an GP model.
model = ndlml.gp(2, 12, X, Y, kern, noise, ndlml.gp.FTC, 100, 3)


model.setOptimiseX(True)
model.setDefaultOptimiser(ndlml.gp.GD)
示例#3
0
X, y = datasets.mapLoadData('spgp1d')

numActive = 9

Xstore = np.array(X)
ystore = np.array(y)

X = nl.matrix(X)
y = nl.matrix(y)

# Set up kernel function
kern = nl.cmpndKern()

kern1 = nl.rbfKern(X)
kern2 = nl.biasKern(X)
kern3 = nl.whiteKern(X)
kern3.setVariance(1e-4)

kern.addKern(kern1)
kern.addKern(kern2)
kern.addKern(kern3)

noise = nl.gaussianNoise(y)

# Create a GP model.
model = nl.gp(1, 1, X, y, kern, noise, nl.gp.DTC, numActive, 3)
model.setBetaVal(math.exp(2))
model.setDefaultOptimiser(nl.gp.CG)

# Optimise the GP.
示例#4
0

# set initial values to small random numbers.
X = np.random.normal(0.0, 1e-6, (len(tr.movieIDs()), q))
X_u = np.random.normal(0.0, 1e-6, (numActive, q))

lnsigma2 = math.log(startVar)
lnbeta = -math.log(startVar)


# Set up kernel functions
kernFtc = nl.cmpndKern(q)
kernSp = nl.cmpndKern(q)

kern1 = nl.rbfKern(q)
kern2 = nl.biasKern(q)
kern3 = nl.whiteKern(q)
kern4 = nl.whitefixedKern(q)

kern2.setVariance(0.11)
kern3.setVariance(math.exp(lnsigma2))
kern4.setVariance(1e-2)

kernFtc.addKern(kern1)
kernFtc.addKern(kern2)
kernFtc.addKern(kern3)

kernSp.addKern(kern1)
kernSp.addKern(kern2)
kernSp.addKern(kern4)