mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-12 05:22:38 +02:00
Merge branch 'devel' of github.com:SheffieldML/GPy into devel
This commit is contained in:
commit
888ec0ff28
4 changed files with 39 additions and 9 deletions
|
|
@ -261,6 +261,7 @@ def bgplvm_simulation(optimize='scg',
|
||||||
|
|
||||||
k = kern.linear(Q, ARD=True) + kern.bias(Q, np.exp(-2)) + kern.white(Q, np.exp(-2)) # + kern.bias(Q)
|
k = kern.linear(Q, ARD=True) + kern.bias(Q, np.exp(-2)) + kern.white(Q, np.exp(-2)) # + kern.bias(Q)
|
||||||
m = BayesianGPLVM(Y, Q, init="PCA", num_inducing=num_inducing, kernel=k, _debug=True)
|
m = BayesianGPLVM(Y, Q, init="PCA", num_inducing=num_inducing, kernel=k, _debug=True)
|
||||||
|
|
||||||
# m.constrain('variance|noise', logexp_clipped())
|
# m.constrain('variance|noise', logexp_clipped())
|
||||||
m.ensure_default_constraints()
|
m.ensure_default_constraints()
|
||||||
m['noise'] = Y.var() / 100.
|
m['noise'] = Y.var() / 100.
|
||||||
|
|
@ -327,28 +328,56 @@ def brendan_faces():
|
||||||
data_show = GPy.util.visualize.image_show(y[None, :], dimensions=(20, 28), transpose=True, invert=False, scale=False)
|
data_show = GPy.util.visualize.image_show(y[None, :], dimensions=(20, 28), transpose=True, invert=False, scale=False)
|
||||||
lvm_visualizer = GPy.util.visualize.lvm(m.X[0, :].copy(), m, data_show, ax)
|
lvm_visualizer = GPy.util.visualize.lvm(m.X[0, :].copy(), m, data_show, ax)
|
||||||
raw_input('Press enter to finish')
|
raw_input('Press enter to finish')
|
||||||
lvm_visualizer.close()
|
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
def stick_play(range=None, frame_rate=15):
|
||||||
|
data = GPy.util.datasets.stick()
|
||||||
|
# optimize
|
||||||
|
if range==None:
|
||||||
|
Y = data['Y'].copy()
|
||||||
|
else:
|
||||||
|
Y = data['Y'][range[0]:range[1], :].copy()
|
||||||
|
y = Y[0, :]
|
||||||
|
data_show = GPy.util.visualize.stick_show(y[None, :], connect=data['connect'])
|
||||||
|
GPy.util.visualize.data_play(Y, data_show, frame_rate)
|
||||||
|
return Y
|
||||||
|
|
||||||
def stick():
|
def stick():
|
||||||
data = GPy.util.datasets.stick()
|
data = GPy.util.datasets.stick()
|
||||||
m = GPy.models.GPLVM(data['Y'], 2)
|
|
||||||
|
|
||||||
# optimize
|
# optimize
|
||||||
|
m = GPy.models.GPLVM(data['Y'], 2)
|
||||||
m.ensure_default_constraints()
|
m.ensure_default_constraints()
|
||||||
m.optimize(messages=1, max_f_eval=10000)
|
m.optimize(messages=1, max_f_eval=10000)
|
||||||
m._set_params(m._get_params())
|
m._set_params(m._get_params())
|
||||||
|
plt.clf
|
||||||
ax = m.plot_latent()
|
ax = m.plot_latent()
|
||||||
y = m.likelihood.Y[0, :]
|
y = m.likelihood.Y[0, :]
|
||||||
data_show = GPy.util.visualize.stick_show(y[None, :], connect=data['connect'])
|
data_show = GPy.util.visualize.stick_show(y[None, :], connect=data['connect'])
|
||||||
lvm_visualizer = GPy.util.visualize.lvm(m.X[0, :].copy(), m, data_show, ax)
|
lvm_visualizer = GPy.util.visualize.lvm(m.X[0, :].copy(), m, data_show, ax)
|
||||||
raw_input('Press enter to finish')
|
raw_input('Press enter to finish')
|
||||||
lvm_visualizer.close()
|
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
def stick_bgplvm(model=None):
|
||||||
|
data = GPy.util.datasets.stick()
|
||||||
|
Q = 6
|
||||||
|
kernel = GPy.kern.rbf(Q, ARD=True) + GPy.kern.bias(Q, np.exp(-2)) + GPy.kern.white(Q, np.exp(-2))
|
||||||
|
m = BayesianGPLVM(data['Y'], Q, init="PCA", num_inducing=20,kernel=kernel)
|
||||||
|
# optimize
|
||||||
|
m.ensure_default_constraints()
|
||||||
|
m.optimize(messages=1, max_f_eval=3000,xtol=1e-300,ftol=1e-300)
|
||||||
|
m._set_params(m._get_params())
|
||||||
|
plt.clf, (latent_axes, sense_axes) = plt.subplots(1, 2)
|
||||||
|
plt.sca(latent_axes)
|
||||||
|
m.plot_latent()
|
||||||
|
y = m.likelihood.Y[0, :].copy()
|
||||||
|
data_show = GPy.util.visualize.stick_show(y[None, :], connect=data['connect'])
|
||||||
|
lvm_visualizer = GPy.util.visualize.lvm_dimselect(m.X[0, :].copy(), m, data_show, latent_axes=latent_axes, sense_axes=sense_axes)
|
||||||
|
raw_input('Press enter to finish')
|
||||||
|
|
||||||
|
return m
|
||||||
|
|
||||||
|
|
||||||
def cmu_mocap(subject='35', motion=['01'], in_place=True):
|
def cmu_mocap(subject='35', motion=['01'], in_place=True):
|
||||||
|
|
||||||
data = GPy.util.datasets.cmu_mocap(subject, motion)
|
data = GPy.util.datasets.cmu_mocap(subject, motion)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class Brownian(Kernpart):
|
||||||
def __init__(self,input_dim,variance=1.):
|
def __init__(self,input_dim,variance=1.):
|
||||||
self.input_dim = input_dim
|
self.input_dim = input_dim
|
||||||
assert self.input_dim==1, "Brownian motion in 1D only"
|
assert self.input_dim==1, "Brownian motion in 1D only"
|
||||||
self.num_params = 1.
|
self.num_params = 1
|
||||||
self.name = 'Brownian'
|
self.name = 'Brownian'
|
||||||
self._set_params(np.array([variance]).flatten())
|
self._set_params(np.array([variance]).flatten())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -203,6 +203,7 @@ class lvm_dimselect(lvm):
|
||||||
self.sense_axes = sense_axes
|
self.sense_axes = sense_axes
|
||||||
self.labels = labels
|
self.labels = labels
|
||||||
lvm.__init__(self,vals,Model,data_visualize,latent_axes,sense_axes,latent_index)
|
lvm.__init__(self,vals,Model,data_visualize,latent_axes,sense_axes,latent_index)
|
||||||
|
self.show_sensitivities()
|
||||||
print "use left and right mouse butons to select dimensions"
|
print "use left and right mouse butons to select dimensions"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -506,5 +507,5 @@ def data_play(Y, visualizer, frame_rate=30):
|
||||||
|
|
||||||
|
|
||||||
for y in Y:
|
for y in Y:
|
||||||
visualizer.modify(y)
|
visualizer.modify(y[None, :])
|
||||||
time.sleep(1./float(frame_rate))
|
time.sleep(1./float(frame_rate))
|
||||||
|
|
|
||||||
4
setup.py
4
setup.py
|
|
@ -5,7 +5,7 @@ import os
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
# Version number
|
# Version number
|
||||||
version = '0.3.2'
|
version = '0.4.5'
|
||||||
|
|
||||||
def read(fname):
|
def read(fname):
|
||||||
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
||||||
|
|
@ -23,7 +23,7 @@ setup(name = 'GPy',
|
||||||
package_data = {'GPy': ['GPy/examples']},
|
package_data = {'GPy': ['GPy/examples']},
|
||||||
py_modules = ['GPy.__init__'],
|
py_modules = ['GPy.__init__'],
|
||||||
long_description=read('README.md'),
|
long_description=read('README.md'),
|
||||||
install_requires=['sympy', 'numpy>=1.6', 'scipy>=0.9','matplotlib>=1.1', 'nose'],
|
install_requires=['numpy>=1.6', 'scipy>=0.9','matplotlib>=1.1', 'nose'],
|
||||||
extras_require = {
|
extras_require = {
|
||||||
'docs':['Sphinx', 'ipython'],
|
'docs':['Sphinx', 'ipython'],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue