mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-15 06:52:39 +02:00
Merge branch 'master' of github.com:SheffieldML/GPy
This commit is contained in:
commit
6d1b93faf3
2 changed files with 7 additions and 9 deletions
|
|
@ -8,13 +8,13 @@ import hashlib
|
||||||
|
|
||||||
class rbf(kernpart):
|
class rbf(kernpart):
|
||||||
"""
|
"""
|
||||||
Radial Basis Function kernel, aka squared-exponential, exponentiated quadratic or Gaussian kernel.
|
Radial Basis Function kernel, aka squared-exponential, exponentiated quadratic or Gaussian kernel:
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 \exp(- \frac{r^2}{2\ell}) \qquad \qquad \\text{ where } r = \sqrt{\frac{\sum_{i=1}^d (x_i-x^\prime_i)^2}{\ell^2}}
|
k(r) = \sigma^2 \exp(- \frac{1}{2}r^2) \qquad \qquad \\text{ where } r^2 = \sum_{i=1}^d \frac{ (x_i-x^\prime_i)^2}{\ell_i^2}}
|
||||||
|
|
||||||
where \ell is the lengthscale, \alpha the smoothness, \sigma^2 the variance and d the dimensionality of the input.
|
where \ell_i is the lengthscale, \sigma^2 the variance and d the dimensionality of the input.
|
||||||
|
|
||||||
:param D: the number of input dimensions
|
:param D: the number of input dimensions
|
||||||
:type D: int
|
:type D: int
|
||||||
|
|
@ -38,7 +38,6 @@ class rbf(kernpart):
|
||||||
assert lengthscale.shape == (1,)
|
assert lengthscale.shape == (1,)
|
||||||
else:
|
else:
|
||||||
lengthscale = np.ones(1)
|
lengthscale = np.ones(1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.Nparam = self.D + 1
|
self.Nparam = self.D + 1
|
||||||
self.name = 'rbf_ARD'
|
self.name = 'rbf_ARD'
|
||||||
|
|
@ -109,11 +108,10 @@ class rbf(kernpart):
|
||||||
self._X2 = X2
|
self._X2 = X2
|
||||||
if X2 is None: X2 = X
|
if X2 is None: X2 = X
|
||||||
self._K_dist = X[:,None,:]-X2[None,:,:] # this can be computationally heavy
|
self._K_dist = X[:,None,:]-X2[None,:,:] # this can be computationally heavy
|
||||||
self._params = np.empty(shape=(1,0))#ensure the next section gets called
|
self._params = np.empty(shape=(1,0)) #ensure the next section gets called
|
||||||
if not np.all(self._params == self._get_params()):
|
if not np.all(self._params == self._get_params()):
|
||||||
self._params == self._get_params()
|
self._params == self._get_params()
|
||||||
self._K_dist2 = np.square(self._K_dist/self.lengthscale)
|
self._K_dist2 = np.square(self._K_dist/self.lengthscale)
|
||||||
#self._K_exponent = -0.5*self._K_dist2.sum(-1) #ND: commented out because seems not to be used
|
|
||||||
self._K_dvar = np.exp(-0.5*self._K_dist2.sum(-1))
|
self._K_dvar = np.exp(-0.5*self._K_dist2.sum(-1))
|
||||||
|
|
||||||
def psi0(self,Z,mu,S,target):
|
def psi0(self,Z,mu,S,target):
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ def toy_rbf_1d(seed=default_seed):
|
||||||
N = 500
|
N = 500
|
||||||
X = np.random.uniform(low=-1.0, high=1.0, size=(N, numIn))
|
X = np.random.uniform(low=-1.0, high=1.0, size=(N, numIn))
|
||||||
X.sort(axis=0)
|
X.sort(axis=0)
|
||||||
rbf = GPy.kern.rbf(numIn, variance=1., lengthscale=0.25)
|
rbf = GPy.kern.rbf(numIn, variance=1., lengthscale=np.array((0.25,)))
|
||||||
white = GPy.kern.white(numIn, variance=1e-2)
|
white = GPy.kern.white(numIn, variance=1e-2)
|
||||||
kernel = rbf + white
|
kernel = rbf + white
|
||||||
K = kernel.K(X)
|
K = kernel.K(X)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue