mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-11 13:02:38 +02:00
random changes
This commit is contained in:
parent
68e37e8684
commit
5b433a3f73
4 changed files with 19 additions and 5 deletions
|
|
@ -98,7 +98,12 @@ class GP(GPBase):
|
||||||
|
|
||||||
Note, we use the chain rule: dL_dtheta = dL_dK * d_K_dtheta
|
Note, we use the chain rule: dL_dtheta = dL_dK * d_K_dtheta
|
||||||
"""
|
"""
|
||||||
return np.hstack((self.kern.dK_dtheta(dL_dK=self.dL_dK, X=self.X), self.likelihood._gradients(partial=np.diag(self.dL_dK))))
|
#return np.hstack((self.kern.dK_dtheta(dL_dK=self.dL_dK, X=self.X), self.likelihood._gradients(partial=np.diag(self.dL_dK))))
|
||||||
|
if not isinstance(self.likelihood,EP):
|
||||||
|
tmp = np.hstack((self.kern.dK_dtheta(dL_dK=self.dL_dK, X=self.X), self.likelihood._gradients(partial=np.diag(self.dL_dK))))
|
||||||
|
else:
|
||||||
|
tmp = np.hstack((self.kern.dK_dtheta(dL_dK=self.dL_dK, X=self.X), self.likelihood._gradients(partial=np.diag(self.dL_dK))))
|
||||||
|
return tmp
|
||||||
|
|
||||||
def _raw_predict(self, _Xnew, which_parts='all', full_cov=False,stop=False):
|
def _raw_predict(self, _Xnew, which_parts='all', full_cov=False,stop=False):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,8 @@ class EP(likelihood):
|
||||||
self.noise_model._set_params(p)
|
self.noise_model._set_params(p)
|
||||||
|
|
||||||
def _gradients(self,partial):
|
def _gradients(self,partial):
|
||||||
return np.zeros(0) # TODO: the EP likelihood might want to take some parameters...
|
#return np.zeros(0) # TODO: the EP likelihood might want to take some parameters...
|
||||||
|
return self.noise_model._gradients(partial)
|
||||||
|
|
||||||
def _compute_GP_variables(self):
|
def _compute_GP_variables(self):
|
||||||
#Variables to be called from GP
|
#Variables to be called from GP
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,10 @@ class Gaussian(NoiseDistribution):
|
||||||
def _set_params(self,p):
|
def _set_params(self,p):
|
||||||
self.variance = p
|
self.variance = p
|
||||||
|
|
||||||
|
def _gradients(self,partial):
|
||||||
|
return np.zeros(1)
|
||||||
|
#return np.sum(partial)
|
||||||
|
|
||||||
def _preprocess_values(self,Y):
|
def _preprocess_values(self,Y):
|
||||||
"""
|
"""
|
||||||
Check if the values of the observations correspond to the values
|
Check if the values of the observations correspond to the values
|
||||||
|
|
@ -57,13 +61,14 @@ class Gaussian(NoiseDistribution):
|
||||||
return 1./(1./self.variance + 1./sigma**2)
|
return 1./(1./self.variance + 1./sigma**2)
|
||||||
|
|
||||||
def _mass(self,gp,obs):
|
def _mass(self,gp,obs):
|
||||||
return std_norm_pdf( (self.gp_link.transf(gp)-obs)/np.sqrt(self.variance) )
|
#return std_norm_pdf( (self.gp_link.transf(gp)-obs)/np.sqrt(self.variance) )
|
||||||
|
return stats.norm.pdf(obs,self.gp_link.transf(gp),np.sqrt(self.variance)) #FIXME
|
||||||
|
|
||||||
def _nlog_mass(self,gp,obs):
|
def _nlog_mass(self,gp,obs):
|
||||||
return .5*((self.gp_link.transf(gp)-obs)**2/np.sqrt(self.variance) + np.log(2*np.pi*self.variance))
|
return .5*((self.gp_link.transf(gp)-obs)**2/self.variance + np.log(2.*np.pi*self.variance))
|
||||||
|
|
||||||
def _dnlog_mass_dgp(self,gp,obs):
|
def _dnlog_mass_dgp(self,gp,obs):
|
||||||
return (self.gp_link.transf(gp)-obs)/np.sqrt(self.variance) * self.gp_link.dtransf_df(gp)
|
return (self.gp_link.transf(gp)-obs)/self.variance * self.gp_link.dtransf_df(gp)
|
||||||
|
|
||||||
def _d2nlog_mass_dgp2(self,gp,obs):
|
def _d2nlog_mass_dgp2(self,gp,obs):
|
||||||
return ((self.gp_link.transf(gp)-obs)*self.gp_link.d2transf_df2(gp) + self.gp_link.dtransf_df(gp)**2)/self.variance
|
return ((self.gp_link.transf(gp)-obs)*self.gp_link.d2transf_df2(gp) + self.gp_link.dtransf_df(gp)**2)/self.variance
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,9 @@ class NoiseDistribution(object):
|
||||||
def _set_params(self,p):
|
def _set_params(self,p):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _gradients(self,partial):
|
||||||
|
return np.zeros(0)
|
||||||
|
|
||||||
def _preprocess_values(self,Y):
|
def _preprocess_values(self,Y):
|
||||||
"""
|
"""
|
||||||
In case it is needed, this function assess the output values or makes any pertinent transformation on them.
|
In case it is needed, this function assess the output values or makes any pertinent transformation on them.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue