swiss_roll example

This commit is contained in:
Max Zwiessele 2013-05-14 11:47:19 +01:00
parent a0df861e8c
commit d6c790ae9c
3 changed files with 19 additions and 18 deletions

View file

@ -87,19 +87,19 @@ class Bayesian_GPLVM(sparse_GP, GPLVM):
return x
def _set_params(self, x, save_old=True, save_count=0):
try:
# try:
N, Q = self.N, self.Q
self.X = x[:self.X.size].reshape(N, Q).copy()
self.X_variance = x[(N * Q):(2 * N * Q)].reshape(N, Q).copy()
sparse_GP._set_params(self, x[(2 * N * Q):])
self.oldps = x
except (LinAlgError, FloatingPointError, ZeroDivisionError):
print "\rWARNING: Caught LinAlgError, continueing without setting "
if self._debug:
self._savederrors.append(self.f_call)
if save_count > 10:
raise
self._set_params(self.oldps[-1], save_old=False, save_count=save_count + 1)
# self.oldps = x
# except (LinAlgError, FloatingPointError, ZeroDivisionError):
# print "\rWARNING: Caught LinAlgError, continueing without setting "
# if self._debug:
# self._savederrors.append(self.f_call)
# if save_count > 10:
# raise
# self._set_params(self.oldps[-1], save_old=False, save_count=save_count + 1)
def dKL_dmuS(self):
dKL_dS = (1. - (1. / (self.X_variance))) * 0.5

View file

@ -93,7 +93,7 @@ class MRD(model):
self.NQ = self.N * self.Q
self.MQ = self.M * self.Q
model.__init__(self) # @UndefinedVariable
model.__init__(self) # @UndefinedVariable
@property
def X(self):
@ -255,7 +255,7 @@ class MRD(model):
X[:, qs] = PCA(Y, len(qs))[0]
elif init in "PCA_concat":
X = PCA(numpy.hstack(Ylist), self.Q)[0]
else: # init == 'random':
else: # init == 'random':
X = numpy.random.randn(Ylist[0].shape[0], self.Q)
self.X = X
return X