moved plot functionality from add to kern

This commit is contained in:
James Hensman 2014-02-26 14:30:28 +00:00
parent 26aeb5e1db
commit 9867330861
4 changed files with 17 additions and 24 deletions

View file

@ -184,14 +184,6 @@ class Add(Kern):
target_S += b target_S += b
return target_mu, target_S return target_mu, target_S
def plot(self, *args, **kwargs):
"""
See GPy.plotting.matplot_dep.plot
"""
assert "matplotlib" in sys.modules, "matplotlib package has not been imported."
from ..plotting.matplot_dep import kernel_plots
kernel_plots.plot(self,*args)
def input_sensitivity(self): def input_sensitivity(self):
in_sen = np.zeros((self.num_params, self.input_dim)) in_sen = np.zeros((self.num_params, self.input_dim))
for i, [p, i_s] in enumerate(zip(self._parameters_, self.input_slices)): for i, [p, i_s] in enumerate(zip(self._parameters_, self.input_slices)):

View file

@ -60,17 +60,6 @@ class Coregionalize(Kern):
def K(self, X, X2=None): def K(self, X, X2=None):
index = np.asarray(X, dtype=np.int) index = np.asarray(X, dtype=np.int)
#here's the old code (numpy)
#if index2 is None:
#index2 = index
#else:
#index2 = np.asarray(index2, dtype=np.int)
#false_target = target.copy()
#ii, jj = np.meshgrid(index, index2)
#ii, jj = ii.T, jj.T
#false_target += self.B[ii, jj]
if X2 is None: if X2 is None:
target = np.empty((X.shape[0], X.shape[0]), dtype=np.float64) target = np.empty((X.shape[0], X.shape[0]), dtype=np.float64)
code=""" code="""

View file

@ -68,6 +68,14 @@ class Kern(Parameterized):
""" """
raise NotImplementedError raise NotImplementedError
def plot(self, *args, **kwargs):
"""
See GPy.plotting.matplot_dep.plot
"""
assert "matplotlib" in sys.modules, "matplotlib package has not been imported."
from ..plotting.matplot_dep import kernel_plots
kernel_plots.plot(self,*args)
def plot_ARD(self, *args, **kw): def plot_ARD(self, *args, **kw):
""" """
See :class:`~GPy.plotting.matplot_dep.kernel_plots` See :class:`~GPy.plotting.matplot_dep.kernel_plots`

View file

@ -178,6 +178,11 @@ class RBF(Stationary):
return denom, dist, dist_sq, psi1 return denom, dist, dist_sq, psi1
#@cache_this(ignore_args=(1,))
def _Z_distances(self, Z):
Zhat = 0.5 * (Z[:, None, :] + Z[None, :, :]) # M,M,Q
Zdist = 0.5 * (Z[:, None, :] - Z[None, :, :]) # M,M,Q
return Zhat, Zdist
#@cache_this TODO #@cache_this TODO
def _psi2computations(self, Z, vp): def _psi2computations(self, Z, vp):
@ -187,8 +192,7 @@ class RBF(Stationary):
M = Z.shape[0] M = Z.shape[0]
#compute required distances #compute required distances
Zhat = 0.5 * (Z[:, None, :] + Z[None, :, :]) # M,M,Q Zhat, Zdist = self._Z_distances(Z)
Zdist = 0.5 * (Z[:, None, :] - Z[None, :, :]) # M,M,Q
Zdist_sq = np.square(Zdist / self.lengthscale) # M,M,Q Zdist_sq = np.square(Zdist / self.lengthscale) # M,M,Q
#allocate memory for the things we want to compute #allocate memory for the things we want to compute