mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-12 13:32:39 +02:00
Mods to visualize and dimensionality to make stick demos work for summer school.
This commit is contained in:
parent
d3a4f99b89
commit
7071dff030
2 changed files with 37 additions and 7 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)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import numpy as np
|
||||||
import matplotlib as mpl
|
import matplotlib as mpl
|
||||||
import time
|
import time
|
||||||
import Image
|
import Image
|
||||||
#import visual
|
import visual
|
||||||
|
|
||||||
class data_show:
|
class data_show:
|
||||||
"""
|
"""
|
||||||
|
|
@ -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))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue