mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-08 03:22:38 +02:00
caching in place again and working : )
This commit is contained in:
parent
1d1123fcae
commit
83f5b9377a
4 changed files with 10 additions and 10 deletions
|
|
@ -69,18 +69,18 @@ class Stationary(Kern):
|
|||
def dK_dr(self, r):
|
||||
raise NotImplementedError, "implement derivative of the covariance function wrt r to use this class"
|
||||
|
||||
#@Cache_this(limit=5, ignore_args=())
|
||||
@Cache_this(limit=5, ignore_args=())
|
||||
def K(self, X, X2=None):
|
||||
r = self._scaled_dist(X, X2)
|
||||
return self.K_of_r(r)
|
||||
|
||||
#@Cache_this(limit=5, ignore_args=(0,))
|
||||
@Cache_this(limit=5, ignore_args=(0,))
|
||||
def _dist(self, X, X2):
|
||||
if X2 is None:
|
||||
X2 = X
|
||||
return X[:, None, :] - X2[None, :, :]
|
||||
|
||||
#@Cache_this(limit=5, ignore_args=(0,))
|
||||
@Cache_this(limit=5, ignore_args=(0,))
|
||||
def _unscaled_dist(self, X, X2=None):
|
||||
"""
|
||||
Compute the square distance between each row of X and X2, or between
|
||||
|
|
@ -94,7 +94,7 @@ class Stationary(Kern):
|
|||
X2sq = np.sum(np.square(X2),1)
|
||||
return np.sqrt(-2.*np.dot(X, X2.T) + (X1sq[:,None] + X2sq[None,:]))
|
||||
|
||||
#@Cache_this(limit=5, ignore_args=())
|
||||
@Cache_this(limit=5, ignore_args=())
|
||||
def _scaled_dist(self, X, X2=None):
|
||||
"""
|
||||
Efficiently compute the scaled distance, r.
|
||||
|
|
@ -147,7 +147,7 @@ class Stationary(Kern):
|
|||
diagonal, where we return zero (the distance on the diagonal is zero).
|
||||
This term appears in derviatives.
|
||||
"""
|
||||
dist = self._scaled_dist(X, X2)
|
||||
dist = self._scaled_dist(X, X2).copy()
|
||||
if X2 is None:
|
||||
nondiag = util.diag.offdiag_view(dist)
|
||||
nondiag[:] = 1./nondiag
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue