mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-09 12:02:38 +02:00
small changes to rbf and rbf_inv
This commit is contained in:
parent
14b8fd0c7d
commit
8131a065cb
3 changed files with 6 additions and 8 deletions
|
|
@ -127,7 +127,7 @@ class GP(GPBase):
|
||||||
debug_this # @UndefinedVariable
|
debug_this # @UndefinedVariable
|
||||||
return mu, var
|
return mu, var
|
||||||
|
|
||||||
def predict(self, Xnew, which_parts='all', full_cov=False):
|
def predict(self, Xnew, which_parts='all', full_cov=False, likelihood_args=dict()):
|
||||||
"""
|
"""
|
||||||
Predict the function(s) at the new point(s) Xnew.
|
Predict the function(s) at the new point(s) Xnew.
|
||||||
Arguments
|
Arguments
|
||||||
|
|
@ -152,6 +152,6 @@ class GP(GPBase):
|
||||||
mu, var = self._raw_predict(Xnew, full_cov=full_cov, which_parts=which_parts)
|
mu, var = self._raw_predict(Xnew, full_cov=full_cov, which_parts=which_parts)
|
||||||
|
|
||||||
# now push through likelihood
|
# now push through likelihood
|
||||||
mean, var, _025pm, _975pm = self.likelihood.predictive_values(mu, var, full_cov)
|
mean, var, _025pm, _975pm = self.likelihood.predictive_values(mu, var, full_cov, **likelihood_args)
|
||||||
|
|
||||||
return mean, var, _025pm, _975pm
|
return mean, var, _025pm, _975pm
|
||||||
|
|
|
||||||
|
|
@ -166,9 +166,8 @@ class RBF(Kernpart):
|
||||||
|
|
||||||
def dpsi1_dtheta(self, dL_dpsi1, Z, mu, S, target):
|
def dpsi1_dtheta(self, dL_dpsi1, Z, mu, S, target):
|
||||||
self._psi_computations(Z, mu, S)
|
self._psi_computations(Z, mu, S)
|
||||||
denom_deriv = S[:, None, :] / (self.lengthscale ** 3 + self.lengthscale * S[:, None, :])
|
|
||||||
d_length = self._psi1[:, :, None] * (self.lengthscale * np.square(self._psi1_dist / (self.lengthscale2 + S[:, None, :])) + denom_deriv)
|
|
||||||
target[0] += np.sum(dL_dpsi1 * self._psi1 / self.variance)
|
target[0] += np.sum(dL_dpsi1 * self._psi1 / self.variance)
|
||||||
|
d_length = self._psi1[:,:,None] * ((self._psi1_dist_sq - 1.)/(self.lengthscale*self._psi1_denom) +1./self.lengthscale)
|
||||||
dpsi1_dlength = d_length * dL_dpsi1[:, :, None]
|
dpsi1_dlength = d_length * dL_dpsi1[:, :, None]
|
||||||
if not self.ARD:
|
if not self.ARD:
|
||||||
target[1] += dpsi1_dlength.sum()
|
target[1] += dpsi1_dlength.sum()
|
||||||
|
|
|
||||||
|
|
@ -159,12 +159,11 @@ class RBFInv(RBF):
|
||||||
|
|
||||||
def dpsi1_dtheta(self, dL_dpsi1, Z, mu, S, target):
|
def dpsi1_dtheta(self, dL_dpsi1, Z, mu, S, target):
|
||||||
self._psi_computations(Z, mu, S)
|
self._psi_computations(Z, mu, S)
|
||||||
##d_length = self._psi1[:, :, None] * (-0.5 * ((np.square((self._psi1_dist)/(self.inv_lengthscale * S[:,None,:] + 1))) + ((S[:, None, :])/(self.inv_lengthscale * S[:, None, :] + 1))))
|
|
||||||
tmp = 1 + S[:,None,:]*self.inv_lengthscale2
|
tmp = 1 + S[:,None,:]*self.inv_lengthscale2
|
||||||
#inv_len3 = np.power(self.inv_lengthscale,3)
|
d_inv_length_old = -self._psi1[:,:,None] * ((self._psi1_dist_sq - 1.)/(self.lengthscale*self._psi1_denom) + self.inv_lengthscale)/self.inv_lengthscale2
|
||||||
d_length = -(self._psi1[:, :, None] * ((np.square(self._psi1_dist) * self.inv_lengthscale)/(tmp**2) + (S[:,None,:]*self.inv_lengthscale)/(tmp)))
|
d_inv_length = -self._psi1[:,:,None] * ((self._psi1_dist_sq - 1.)/self._psi1_denom + self.lengthscale)
|
||||||
target[0] += np.sum(dL_dpsi1 * self._psi1 / self.variance)
|
target[0] += np.sum(dL_dpsi1 * self._psi1 / self.variance)
|
||||||
dpsi1_dlength = d_length * dL_dpsi1[:, :, None]
|
dpsi1_dlength = d_inv_length * dL_dpsi1[:, :, None]
|
||||||
if not self.ARD:
|
if not self.ARD:
|
||||||
target[1] += dpsi1_dlength.sum()#*(-self.lengthscale2)
|
target[1] += dpsi1_dlength.sum()#*(-self.lengthscale2)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue