This commit is contained in:
Nicolo Fusi 2013-05-17 12:29:13 +01:00
parent 5183a18a1f
commit ddd3ece3ce

View file

@ -315,31 +315,33 @@ class kern(parameterised):
# compute the "cross" terms # compute the "cross" terms
# TODO: input_slices needed # TODO: input_slices needed
crossterms = 0
for p1, p2 in itertools.combinations(self.parts, 2): for p1, p2 in itertools.combinations(self.parts, 2):
# white doesn;t combine with anything prod = np.multiply
if p1.name == 'white' or p2.name == 'white': # # white doesn;t combine with anything
pass # if p1.name == 'white' or p2.name == 'white':
# rbf X bias # pass
elif p1.name == 'bias' and p2.name == 'rbf': # # rbf X bias
target += p1.variance * (p2._psi1[:, :, None] + p2._psi1[:, None, :]) # elif p1.name == 'bias' and p2.name == 'rbf':
elif p2.name == 'bias' and p1.name == 'rbf': # target += p1.variance * (p2._psi1[:, :, None] + p2._psi1[:, None, :])
target += p2.variance * (p1._psi1[:, :, None] + p1._psi1[:, None, :]) # elif p2.name == 'bias' and p1.name == 'rbf':
# linear X bias # target += p2.variance * (p1._psi1[:, :, None] + p1._psi1[:, None, :])
elif p1.name == 'bias' and p2.name == 'linear': # # linear X bias
tmp = np.zeros((mu.shape[0], Z.shape[0])) # elif p1.name == 'bias' and p2.name == 'linear':
p2.psi1(Z, mu, S, tmp) # tmp = np.zeros((mu.shape[0], Z.shape[0]))
target += p1.variance * (tmp[:, :, None] + tmp[:, None, :]) # p2.psi1(Z, mu, S, tmp)
elif p2.name == 'bias' and p1.name == 'linear': # target += p1.variance * (tmp[:, :, None] + tmp[:, None, :])
tmp = np.zeros((mu.shape[0], Z.shape[0])) # elif p2.name == 'bias' and p1.name == 'linear':
p1.psi1(Z, mu, S, tmp) # tmp = np.zeros((mu.shape[0], Z.shape[0]))
target += p2.variance * (tmp[:, :, None] + tmp[:, None, :]) # p1.psi1(Z, mu, S, tmp)
# rbf X linear # target += p2.variance * (tmp[:, :, None] + tmp[:, None, :])
elif p1.name == 'linear' and p2.name == 'rbf': # # rbf X linear
raise NotImplementedError # TODO # elif p1.name == 'linear' and p2.name == 'rbf':
elif p2.name == 'linear' and p1.name == 'rbf': # raise NotImplementedError # TODO
raise NotImplementedError # TODO # elif p2.name == 'linear' and p1.name == 'rbf':
else: # raise NotImplementedError # TODO
raise NotImplementedError, "psi2 cannot be computed for this kernel" # else:
# raise NotImplementedError, "psi2 cannot be computed for this kernel"
return target return target
def dpsi2_dtheta(self, dL_dpsi2, Z, mu, S): def dpsi2_dtheta(self, dL_dpsi2, Z, mu, S):