From 4d27fddd375cda05a63579706defa3af0877c4a2 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Fri, 27 Mar 2015 14:24:24 +0000 Subject: [PATCH] Small tidying up --- GPy/likelihoods/bernoulli.py | 38 ----------------------------------- GPy/likelihoods/likelihood.py | 2 +- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/GPy/likelihoods/bernoulli.py b/GPy/likelihoods/bernoulli.py index c398b3a4..f5690aa4 100644 --- a/GPy/likelihoods/bernoulli.py +++ b/GPy/likelihoods/bernoulli.py @@ -248,41 +248,3 @@ class Bernoulli(Likelihood): def exact_inference_gradients(self, dL_dKdiag,Y_metadata=None): pass - - def variational_expectations(self, Y, m, v, gh_points=None): - """ - Probit specific numerical stable integrations - """ - #Move to be faster - if self.gp_link: - pass - Yshape = Y.shape - mshape = m.shape - vshape = v.shape - Y = Y.flatten() - m = m.flatten() - v = v.flatten() - - assert Yshape == mshape - assert mshape == vshape - - Ysign = np.where(Y==1,1,-1).flatten() - gh_x, gh_w = np.polynomial.hermite.hermgauss(20) - - #Shapes a bit weird - X = gh_x[None,:]*np.sqrt(2.*v[:, None]) + (m*Ysign)[:,None] - p = stats.norm.cdf(X) - p = np.clip(p, 1e-9, 1.-1e-9) # for numerical stability - N = stats.norm.pdf(X) - F = np.log(p).dot(gh_w) - NoverP = N/p - dF_dm = (NoverP*Ysign[:,None]).dot(gh_w) - dF_dv = -0.5*(NoverP**2 + NoverP*X).dot(gh_w) - if np.any(np.isnan(dF_dv)) or np.any(np.isinf(dF_dv)): - stop - if np.any(np.isnan(dF_dm)) or np.any(np.isinf(dF_dm)): - stop - #FIXME: Might be wrong reshaping - return F.reshape(Yshape), dF_dm.reshape(mshape), dF_dv.reshape(vshape), None - - diff --git a/GPy/likelihoods/likelihood.py b/GPy/likelihoods/likelihood.py index a545d54e..022670a5 100644 --- a/GPy/likelihoods/likelihood.py +++ b/GPy/likelihoods/likelihood.py @@ -325,7 +325,7 @@ class Likelihood(Parameterized): def logpdf_sum(self, f, y, Y_metadata=None): """ Convenience function that can overridden for functions where this could - be computed more efficiently (Theano?) + be computed more efficiently """ return np.sum(self.logpdf(f, y, Y_metadata=Y_metadata))