mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-24 14:15:14 +02:00
pseudo_EM modified
This commit is contained in:
parent
fa035ac39e
commit
ab6a87a4d5
1 changed files with 3 additions and 6 deletions
|
|
@ -449,7 +449,7 @@ class Model(Parameterised):
|
||||||
:type optimzer: string TODO: valid strings?
|
:type optimzer: string TODO: valid strings?
|
||||||
|
|
||||||
"""
|
"""
|
||||||
assert isinstance(self.likelihood, likelihoods.EP), "EPEM is only available for EP likelihoods"
|
assert isinstance(self.likelihood, likelihoods.EP), "pseudo_EM is only available for EP likelihoods"
|
||||||
ll_change = epsilon + 1.
|
ll_change = epsilon + 1.
|
||||||
iteration = 0
|
iteration = 0
|
||||||
last_ll = -np.inf
|
last_ll = -np.inf
|
||||||
|
|
@ -461,16 +461,13 @@ class Model(Parameterised):
|
||||||
while not stop:
|
while not stop:
|
||||||
last_approximation = self.likelihood.copy()
|
last_approximation = self.likelihood.copy()
|
||||||
last_params = self._get_params()
|
last_params = self._get_params()
|
||||||
|
|
||||||
self.likelihood.restart()
|
|
||||||
self.update_likelihood_approximation()
|
self.update_likelihood_approximation()
|
||||||
|
|
||||||
new_ll = self.log_likelihood()
|
new_ll = self.log_likelihood()
|
||||||
ll_change = new_ll - last_ll
|
ll_change = new_ll - last_ll
|
||||||
|
|
||||||
if ll_change < 0:
|
if ll_change < 0:
|
||||||
self.likelihood = last_approximation # restore previous likelihood approximation
|
self.likelihood = last_approximation # restore previous likelihood approximation
|
||||||
self._set_params(last_params) # restore Model parameters
|
self._set_params(last_params) # restore model parameters
|
||||||
print "Log-likelihood decrement: %s \nLast likelihood update discarded." % ll_change
|
print "Log-likelihood decrement: %s \nLast likelihood update discarded." % ll_change
|
||||||
stop = True
|
stop = True
|
||||||
else:
|
else:
|
||||||
|
|
@ -481,4 +478,4 @@ class Model(Parameterised):
|
||||||
iteration += 1
|
iteration += 1
|
||||||
if stop:
|
if stop:
|
||||||
print "%s iterations." % iteration
|
print "%s iterations." % iteration
|
||||||
|
self.update_likelihood_approximation()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue