mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-08 15:05:15 +02:00
[heteroscedastic gauss] Implemented Heteroscedastic Guassian Lik with @ric70x7
This commit is contained in:
parent
9ededd5a45
commit
0d32652c88
1 changed files with 28 additions and 0 deletions
|
|
@ -48,6 +48,7 @@ class Gaussian(Likelihood):
|
|||
|
||||
def betaY(self,Y,Y_metadata=None):
|
||||
#TODO: ~Ricardo this does not live here
|
||||
print "Iam Here"
|
||||
return Y/self.gaussian_variance(Y_metadata)
|
||||
|
||||
def gaussian_variance(self, Y_metadata=None):
|
||||
|
|
@ -321,3 +322,30 @@ class Gaussian(Likelihood):
|
|||
dF_dv = np.ones_like(v)*(-0.5/lik_var)
|
||||
dF_dtheta = -0.5/lik_var + 0.5*(np.square(Y) + np.square(m) + v - 2*m*Y)/(lik_var**2)
|
||||
return F, dF_dmu, dF_dv, dF_dtheta.reshape(1, Y.shape[0], Y.shape[1])
|
||||
|
||||
class Heteroscedastic_Gaussian(Gaussian):
|
||||
def __init__(self, Y_metadata, gp_link=None, variance=1., name='het_Gauss'):
|
||||
if gp_link is None:
|
||||
gp_link = link_functions.Identity()
|
||||
|
||||
if not isinstance(gp_link, link_functions.Identity):
|
||||
print("Warning, Exact inference is not implemeted for non-identity link functions,\
|
||||
if you are not already, ensure Laplace inference_method is used")
|
||||
|
||||
super(Heteroscedastic_Gaussian, self).__init__(gp_link, np.ones(Y_metadata['output_index'].shape[0])*variance, name)
|
||||
|
||||
def exact_inference_gradients(self, dL_dKdiag,Y_metadata=None):
|
||||
return dL_dKdiag[Y_metadata['output_index']][:,0]
|
||||
|
||||
def gaussian_variance(self, Y_metadata=None):
|
||||
return self.variance[Y_metadata['output_index']]
|
||||
|
||||
def predictive_values(self, mu, var, full_cov=False, Y_metadata=None):
|
||||
if full_cov:
|
||||
if var.ndim == 2:
|
||||
var += np.eye(var.shape[0])*self.variance
|
||||
if var.ndim == 3:
|
||||
var += np.atleast_3d(np.eye(var.shape[0])*self.variance)
|
||||
else:
|
||||
var += self.variance
|
||||
return mu, var
|
||||
Loading…
Add table
Add a link
Reference in a new issue