This commit is contained in:
James Hensman 2014-04-28 16:09:11 +01:00
commit 7d223d8df0
5 changed files with 14 additions and 10 deletions

View file

@ -167,4 +167,10 @@ class Add(CombinationKernel):
else:
self.add_parameter(other)
self.input_dim, self.active_dims = self.get_input_dim_active_dims(self.parts)
return self
return self
def input_sensitivity(self):
in_sen = np.zeros(self.input_dim)
for i, p in enumerate(self.parts):
in_sen[p.active_dims] += p.input_sensitivity()
return in_sen

View file

@ -238,7 +238,4 @@ class CombinationKernel(Kern):
return input_dim, active_dims
def input_sensitivity(self):
in_sen = np.zeros((self.num_params, self.input_dim))
for i, p in enumerate(self.parts):
in_sen[i, p.active_dims] = p.input_sensitivity()
return in_sen
raise NotImplementedError("Choose the kernel you want to get the sensitivity for. You need to override the default behaviour for getting the input sensitivity to be able to get the input sensitivity. For sum kernel it is the sum of all sensitivities, TODO: product kernel? Other kernels?, also TODO: shall we return all the sensitivities here in the combination kernel? So we can combine them however we want? This could lead to just plot all the sensitivities here...")

View file

@ -42,6 +42,7 @@ class _Slice_wrap(object):
self.X2 = self.k._slice_X(X2) if X2 is not None else X2
self.ret = True
else:
assert X.shape[1] == self.k.input_dim, "You did not specify active_dims and X has wrong shape: X_dim={} -- input_dim={}".format(X.shape[1], self.input_dim)
self.X = X
self.X2 = X2
self.ret = False