mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-12 13:32:39 +02:00
all kernels working fine with the psi statistics now
This commit is contained in:
parent
16d9536027
commit
de665361a7
5 changed files with 14 additions and 18 deletions
|
|
@ -90,22 +90,19 @@ class linear(kernpart):
|
|||
|
||||
def psi0(self,Z,mu,S,target):
|
||||
self._psi_computations(Z,mu,S)
|
||||
target += np.sum(self.variances*self.mu2_S)
|
||||
target += np.sum(self.variances*self.mu2_S,1)
|
||||
|
||||
def dpsi0_dtheta(self,partial,Z,mu,S,target):
|
||||
self._psi_computations(Z,mu,S)
|
||||
tmp = (partial[:, None] * (np.sum(self.mu2_S,0)))
|
||||
tmp = partial[:, None] * self.mu2_S
|
||||
if self.ARD:
|
||||
target += tmp.sum(0)
|
||||
else:
|
||||
target += tmp.sum()
|
||||
|
||||
def dpsi0_dmuS(self,partial, Z,mu,S,target_mu,target_S):
|
||||
target_mu += np.sum(partial[:, None],0) * (2.0*mu*self.variances)
|
||||
target_S += np.sum(partial[:, None] * self.variances, 0)
|
||||
|
||||
def dpsi0_dZ(self,Z,mu,S,target):
|
||||
pass
|
||||
target_mu += partial[:, None] * (2.0*mu*self.variances)
|
||||
target_S += partial[:, None] * self.variances
|
||||
|
||||
def psi1(self,Z,mu,S,target):
|
||||
"""the variance, it does nothing"""
|
||||
|
|
@ -149,7 +146,7 @@ class linear(kernpart):
|
|||
def dpsi2_dZ(self,partial,Z,mu,S,target):
|
||||
self._psi_computations(Z,mu,S)
|
||||
mu2_S = np.sum(self.mu2_S,0)# Q,
|
||||
target += (partial[:,:,:,None]* (Z * mu2_S * np.square(self.variances))).sum(0).sum(1)
|
||||
target += (partial[:,:,:,None] * (self.mu2_S[:,None,None,:]*(Z*np.square(self.variances)[None,:])[None,None,:,:])).sum(0).sum(1)
|
||||
|
||||
#---------------------------------------#
|
||||
# Precomputations #
|
||||
|
|
|
|||
|
|
@ -155,21 +155,20 @@ class rbf(kernpart):
|
|||
self._psi_computations(Z,mu,S)
|
||||
d_var = 2.*self._psi2/self.variance
|
||||
d_length = self._psi2[:,:,:,None]*(0.5*self._psi2_Zdist_sq*self._psi2_denom + 2.*self._psi2_mudist_sq + 2.*S[:,None,None,:]/self.lengthscale2)/(self.lengthscale*self._psi2_denom)
|
||||
d_length = d_length.sum(0)
|
||||
|
||||
target[0] += np.sum(partial*d_var)
|
||||
dpsi2_dlength = d_length*partial[:,:,:,None]
|
||||
if not self.ARD:
|
||||
target[1] += dpsi2_dlength.sum()
|
||||
else:
|
||||
target[1:] += dpsi2_dlength.sum(0).sum(0).sum(0)
|
||||
|
||||
|
||||
def dpsi2_dZ(self,partial,Z,mu,S,target):
|
||||
self._psi_computations(Z,mu,S)
|
||||
term1 = 0.5*self._psi2_Zdist/self.lengthscale2 # M, M, Q
|
||||
term2 = self._psi2_mudist/self._psi2_denom/self.lengthscale2 # N, M, M, Q
|
||||
dZ = self._psi2[:,:,:,None] * (term1[None] + term2)
|
||||
target += (partial[:,:,:,None]*dZ).sum(0).sum(0) # <----------------- TODO not sure about the first ':' here, should be a None (WAS a none in the debug branch)
|
||||
|
||||
target += (partial[:,:,:,None]*dZ).sum(0).sum(0)
|
||||
|
||||
def dpsi2_dmuS(self,partial,Z,mu,S,target_mu,target_S):
|
||||
"""Think N,M,M,Q """
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue