mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-09 03:52:39 +02:00
start of cythoning coregionalize
This commit is contained in:
parent
2e8ce34ee0
commit
c00f76d250
3 changed files with 56 additions and 1 deletions
|
|
@ -111,6 +111,11 @@ class Coregionalize(Kern):
|
|||
weave.inline(code, ['target', 'index', 'index2', 'N', 'num_inducing', 'B', 'output_dim'])
|
||||
return target
|
||||
|
||||
def _K_cython(self, X, X2=None):
|
||||
if X2 is None:
|
||||
return coregionalize_cython.K_symmetric(self.B, X[:,0])
|
||||
return coregionalize_cython.K_asymmetric(self.B, X[:,0], X2[:,0])
|
||||
|
||||
|
||||
def Kdiag(self, X):
|
||||
return np.diag(self.B)[np.asarray(X, dtype=np.int).flatten()]
|
||||
|
|
@ -164,6 +169,11 @@ class Coregionalize(Kern):
|
|||
dL_dK_small[j,i] = tmp1[:,index2==j].sum()
|
||||
return dL_dK_small
|
||||
|
||||
def gradient_reduce_cython(self, dL_dK, index, index2):
|
||||
index, index2 = index[:,0], index2[:,0]
|
||||
return coregionalize_cython.gradient_reduce(self.output_dim, dL_dK, index, index2
|
||||
|
||||
|
||||
def update_gradients_diag(self, dL_dKdiag, X):
|
||||
index = np.asarray(X, dtype=np.int).flatten()
|
||||
dL_dKdiag_small = np.array([dL_dKdiag[index==i].sum() for i in range(self.output_dim)])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue