mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-29 15:59:41 +02:00
pretty much the version running on ec2
This commit is contained in:
parent
6a6cbb58c8
commit
6959751149
1 changed files with 7 additions and 7 deletions
|
|
@ -123,13 +123,15 @@ class opt_SGD(Optimizer):
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def step_with_missing_data(self, f_fp, X, Y, step, shapes):
|
def step_with_missing_data(self, f_fp, X, step, shapes):
|
||||||
N, Q = X.shape
|
N, Q = X.shape
|
||||||
samples = self.non_null_samples(self.model.Y)
|
samples = self.non_null_samples(self.model.Y)
|
||||||
j = self.subset_parameter_vector(self.x_opt, samples, shapes)
|
j = self.subset_parameter_vector(self.x_opt, samples, shapes)
|
||||||
self.model.N = samples.sum()
|
self.model.N = samples.sum()
|
||||||
self.model.X = X[samples]
|
self.model.X = X[samples]
|
||||||
self.model.Y = self.model.Y[samples]
|
self.model.Y = self.model.Y[samples]
|
||||||
|
# self.model.Y -= self.model.Y.mean() # <----------------- WARNING!!!!
|
||||||
|
# self.model.Y /= self.model.Y.std()
|
||||||
model_name = self.model.__class__.__name__
|
model_name = self.model.__class__.__name__
|
||||||
|
|
||||||
if model_name == 'Bayesian_GPLVM':
|
if model_name == 'Bayesian_GPLVM':
|
||||||
|
|
@ -142,11 +144,7 @@ class opt_SGD(Optimizer):
|
||||||
|
|
||||||
momentum_term = self.momentum * step[j]
|
momentum_term = self.momentum * step[j]
|
||||||
|
|
||||||
try:
|
f, fp = f_fp(self.x_opt[j])
|
||||||
f, fp = f_fp(self.x_opt[j])
|
|
||||||
except Exception:
|
|
||||||
return 0, step, self.model.N
|
|
||||||
|
|
||||||
step[j] = self.learning_rate[j] * fp
|
step[j] = self.learning_rate[j] * fp
|
||||||
self.x_opt[j] -= step[j] + momentum_term
|
self.x_opt[j] -= step[j] + momentum_term
|
||||||
|
|
||||||
|
|
@ -183,8 +181,10 @@ class opt_SGD(Optimizer):
|
||||||
self.model.Y = Y[:, j]
|
self.model.Y = Y[:, j]
|
||||||
# self.model.trYYT = np.sum(np.square(self.model.Y))
|
# self.model.trYYT = np.sum(np.square(self.model.Y))
|
||||||
if missing_data:
|
if missing_data:
|
||||||
|
if self.model.Y.std() == 0.0 or self.model.Y.shape[0] == 0:
|
||||||
|
continue
|
||||||
shapes = self.get_param_shapes(N, Q)
|
shapes = self.get_param_shapes(N, Q)
|
||||||
f, step, Nj = self.step_with_missing_data(f_fp, X, Y, step, shapes)
|
f, step, Nj = self.step_with_missing_data(f_fp, X, step, shapes)
|
||||||
else:
|
else:
|
||||||
Nj = N
|
Nj = N
|
||||||
momentum_term = self.momentum * step # compute momentum using update(t-1)
|
momentum_term = self.momentum * step # compute momentum using update(t-1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue