mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-10 20:42:39 +02:00
numerical stability in variational expectations
This commit is contained in:
parent
e0d3633ec3
commit
d26beb215a
1 changed files with 4 additions and 3 deletions
|
|
@ -177,11 +177,12 @@ class Bernoulli(Likelihood):
|
||||||
(the distribution for y_i depends only on inverse link of f_i not on inverse link of f_(j!=i)
|
(the distribution for y_i depends only on inverse link of f_i not on inverse link of f_(j!=i)
|
||||||
"""
|
"""
|
||||||
#d2logpdf_dlink2 = -y/(inv_link_f**2) - (1-y)/((1-inv_link_f)**2)
|
#d2logpdf_dlink2 = -y/(inv_link_f**2) - (1-y)/((1-inv_link_f)**2)
|
||||||
state = np.seterr(divide='ignore')
|
|
||||||
# TODO check y \in {0, 1} or {-1, 1}
|
|
||||||
#d2logpdf_dlink2 = np.where(y, -1./np.square(inv_link_f), -1./np.square(1.-inv_link_f))
|
#d2logpdf_dlink2 = np.where(y, -1./np.square(inv_link_f), -1./np.square(1.-inv_link_f))
|
||||||
arg = np.where(y, inv_link_f, 1.-inv_link_f)
|
arg = np.where(y, inv_link_f, 1.-inv_link_f)
|
||||||
return -1./np.square(arg)
|
ret = -1./np.square(np.clip(arg, 1e-3, np.inf))
|
||||||
|
if np.any(np.isinf(ret)):
|
||||||
|
stop
|
||||||
|
return ret
|
||||||
|
|
||||||
def d3logpdf_dlink3(self, inv_link_f, y, Y_metadata=None):
|
def d3logpdf_dlink3(self, inv_link_f, y, Y_metadata=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue