mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-21 14:05:14 +02:00
observable pattern through and thorugh
This commit is contained in:
parent
26aeb5e1db
commit
65fd6dd24e
11 changed files with 64 additions and 80 deletions
|
|
@ -9,7 +9,6 @@ from ...util.linalg import tdot
|
|||
from ...util.misc import fast_array_equal, param_to_array
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from ...util.caching import cache_this
|
||||
|
||||
class Linear(Kern):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import numpy as np
|
|||
from scipy import weave
|
||||
from ...util.misc import param_to_array
|
||||
from stationary import Stationary
|
||||
from GPy.util.caching import Cache_this
|
||||
|
||||
class RBF(Stationary):
|
||||
"""
|
||||
|
|
@ -166,7 +167,7 @@ class RBF(Stationary):
|
|||
return target
|
||||
|
||||
|
||||
#@cache_this TODO
|
||||
@Cache_this(limit=1)
|
||||
def _psi1computations(self, Z, vp):
|
||||
mu, S = vp.mean, vp.variance
|
||||
l2 = self.lengthscale **2
|
||||
|
|
@ -179,7 +180,7 @@ class RBF(Stationary):
|
|||
|
||||
|
||||
|
||||
#@cache_this TODO
|
||||
@Cache_this(limit=1)
|
||||
def _psi2computations(self, Z, vp):
|
||||
mu, S = vp.mean, vp.variance
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ from kern import Kern
|
|||
import numpy as np
|
||||
from ...util.linalg import tdot
|
||||
from ...util.config import *
|
||||
from ...util.caching import cache_this
|
||||
from stationary import Stationary
|
||||
|
||||
class SSRBF(Stationary):
|
||||
|
|
@ -155,7 +154,7 @@ class SSRBF(Stationary):
|
|||
# Precomputations #
|
||||
#---------------------------------------#
|
||||
|
||||
@cache_this(1)
|
||||
#@cache_this(1)
|
||||
def _K_computations(self, X, X2):
|
||||
"""
|
||||
K(X,X2) - X is NxQ
|
||||
|
|
@ -175,7 +174,7 @@ class SSRBF(Stationary):
|
|||
self._K_dist2 = -2.*np.dot(X, X2.T) + (np.sum(np.square(X), axis=1)[:, None] + np.sum(np.square(X2), axis=1)[None, :])
|
||||
self._K_dvar = np.exp(-0.5 * self._K_dist2)
|
||||
|
||||
@cache_this(1)
|
||||
#@cache_this(1)
|
||||
def _psi_computations(self, Z, mu, S, gamma):
|
||||
"""
|
||||
Z - MxQ
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ from ...util.linalg import tdot
|
|||
from ... import util
|
||||
import numpy as np
|
||||
from scipy import integrate
|
||||
from ...util.caching import Cache_this
|
||||
|
||||
class Stationary(Kern):
|
||||
def __init__(self, input_dim, variance, lengthscale, ARD, name):
|
||||
|
|
@ -39,15 +40,18 @@ class Stationary(Kern):
|
|||
def dK_dr(self, r):
|
||||
raise NotImplementedError, "implement the covaraiance function as a fn of r to use this class"
|
||||
|
||||
@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,))
|
||||
def _dist(self, X, X2):
|
||||
if X2 is None:
|
||||
X2 = X
|
||||
return X[:, None, :] - X2[None, :, :]
|
||||
|
||||
@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
|
||||
|
|
@ -61,6 +65,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=())
|
||||
def _scaled_dist(self, X, X2=None):
|
||||
"""
|
||||
Efficiently compute the scaled distance, r.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue