mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-07 11:02:38 +02:00
merge with current GPy devel
This commit is contained in:
commit
c0e6978054
164 changed files with 733 additions and 5931 deletions
|
|
@ -4,7 +4,7 @@
|
|||
from .kern import Kern
|
||||
from .independent_outputs import index_to_slices
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from paramz.transformations import Logexp
|
||||
import numpy as np
|
||||
|
||||
class ODE_UY(Kern):
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
from .kern import Kern
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from paramz.transformations import Logexp
|
||||
import numpy as np
|
||||
from .independent_outputs import index_to_slices
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
||||
from .kern import Kern
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from paramz.transformations import Logexp
|
||||
import numpy as np
|
||||
from .independent_outputs import index_to_slices
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from .kern import Kern
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from paramz.transformations import Logexp
|
||||
import numpy as np
|
||||
from .independent_outputs import index_to_slices
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import numpy as np
|
||||
import itertools
|
||||
from ...util.caching import Cache_this
|
||||
from paramz.caching import Cache_this
|
||||
from .kern import CombinationKernel, Kern
|
||||
from functools import reduce
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
import numpy as np
|
||||
from .kern import Kern
|
||||
from ...core.parameterization.param import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from ...util.caching import Cache_this
|
||||
from paramz.transformations import Logexp
|
||||
from paramz.caching import Cache_this
|
||||
from ...util.linalg import tdot, mdot
|
||||
|
||||
class BasisFuncKernel(Kern):
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
from .kern import Kern
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from paramz.transformations import Logexp
|
||||
import numpy as np
|
||||
|
||||
class Brownian(Kern):
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
from .kern import Kern
|
||||
import numpy as np
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from paramz.transformations import Logexp
|
||||
from ...util.config import config # for assesing whether to use cython
|
||||
try:
|
||||
from . import coregionalize_cython
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import numpy as np
|
|||
from scipy.special import wofz
|
||||
from .kern import Kern
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from ...util.caching import Cache_this
|
||||
from paramz.transformations import Logexp
|
||||
from paramz.caching import Cache_this
|
||||
|
||||
class EQ_ODE2(Kern):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
import sys
|
||||
import numpy as np
|
||||
from ...core.parameterization.parameterized import Parameterized
|
||||
from ...core.parameterization.observable_array import ObsAr
|
||||
from ...util.caching import Cache_this
|
||||
from paramz.core.observable_array import ObsAr
|
||||
from paramz.caching import Cache_this
|
||||
from .kernel_slice_operations import KernCallsViaSlicerMeta
|
||||
from functools import reduce
|
||||
import six
|
||||
|
|
@ -30,18 +30,16 @@ class Kern(Parameterized):
|
|||
tight dimensionality of inputs.
|
||||
You most likely want this to be the integer telling the number of
|
||||
input dimensions of the kernel.
|
||||
If this is not an integer (!) we will work on the whole input matrix X,
|
||||
and not check whether dimensions match or not (!).
|
||||
|
||||
_all_dims_active:
|
||||
active_dims:
|
||||
|
||||
is the active_dimensions of inputs X we will work on.
|
||||
All kernels will get sliced Xes as inputs, if _all_dims_active is not None
|
||||
Only positive integers are allowed in _all_dims_active!
|
||||
if _all_dims_active is None, slicing is switched off and all X will be passed through as given.
|
||||
Only positive integers are allowed in active_dims!
|
||||
if active_dims is None, slicing is switched off and all X will be passed through as given.
|
||||
|
||||
:param int input_dim: the number of input dimensions to the function
|
||||
:param array-like|None _all_dims_active: list of indices on which dimensions this kernel works on, or none if no slicing
|
||||
:param array-like|None active_dims: list of indices on which dimensions this kernel works on, or none if no slicing
|
||||
|
||||
Do not instantiate.
|
||||
"""
|
||||
|
|
@ -60,7 +58,11 @@ class Kern(Parameterized):
|
|||
self.useGPU = self._support_GPU and useGPU
|
||||
|
||||
from .psi_comp import PSICOMP_GH
|
||||
self.psicomp = PSICOMP_GH()
|
||||
self.psicomp = PSICOMP_GH()
|
||||
|
||||
def __setstate__(self, state):
|
||||
self._all_dims_active = range(0, max(state['active_dims'])+1)
|
||||
super(Kern, self).__setstate__(state)
|
||||
|
||||
@property
|
||||
def _effective_input_dim(self):
|
||||
|
|
@ -211,15 +213,15 @@ class Kern(Parameterized):
|
|||
def get_most_significant_input_dimensions(self, which_indices=None):
|
||||
"""
|
||||
Determine which dimensions should be plotted
|
||||
|
||||
|
||||
Returns the top three most signification input dimensions
|
||||
|
||||
|
||||
if less then three dimensions, the non existing dimensions are
|
||||
labeled as None, so for a 1 dimensional input this returns
|
||||
(0, None, None).
|
||||
|
||||
:param which_indices: force the indices to be the given indices.
|
||||
:type which_indices: int or tuple(int,int) or tuple(int,int,int)
|
||||
|
||||
:param which_indices: force the indices to be the given indices.
|
||||
:type which_indices: int or tuple(int,int) or tuple(int,int,int)
|
||||
"""
|
||||
if which_indices is None:
|
||||
which_indices = np.argsort(self.input_sensitivity())[::-1][:3]
|
||||
|
|
@ -235,7 +237,7 @@ class Kern(Parameterized):
|
|||
input_1, input_2 = which_indices, None
|
||||
except ValueError:
|
||||
# which_indices was a list or array like with only one int
|
||||
input_1, input_2 = which_indices[0], None
|
||||
input_1, input_2 = which_indices[0], None
|
||||
return input_1, input_2, input_3
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ This module provides a meta class for the kernels. The meta class is for
|
|||
slicing the inputs (X, X2) for the kernels, before K (or any other method involving X)
|
||||
gets calls. The `_all_dims_active` of a kernel decide which dimensions the kernel works on.
|
||||
'''
|
||||
from ...core.parameterization.parameterized import ParametersChangedMeta
|
||||
import numpy as np
|
||||
from functools import wraps
|
||||
from paramz.parameterized import ParametersChangedMeta
|
||||
|
||||
def put_clean(dct, name, func):
|
||||
if name in dct:
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import numpy as np
|
|||
from .kern import Kern
|
||||
from ...util.linalg import tdot
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from ...util.caching import Cache_this
|
||||
from paramz.transformations import Logexp
|
||||
from paramz.caching import Cache_this
|
||||
from .psi_comp import PSICOMP_Linear
|
||||
|
||||
class Linear(Kern):
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
from .kern import Kern
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from paramz.transformations import Logexp
|
||||
import numpy as np
|
||||
from ...util.caching import Cache_this
|
||||
from paramz.caching import Cache_this
|
||||
four_over_tau = 2./np.pi
|
||||
|
||||
class MLP(Kern):
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from .kern import Kern
|
|||
from ...util.linalg import mdot
|
||||
from ...util.decorators import silence_errors
|
||||
from ...core.parameterization.param import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from paramz.transformations import Logexp
|
||||
|
||||
class Periodic(Kern):
|
||||
def __init__(self, input_dim, variance, lengthscale, period, n_freq, lower, upper, active_dims, name):
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
import numpy as np
|
||||
from .kern import Kern
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from paramz.transformations import Logexp
|
||||
|
||||
class Poly(Kern):
|
||||
"""
|
||||
Polynomial kernel
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import numpy as np
|
||||
from .kern import CombinationKernel
|
||||
from ...util.caching import Cache_this
|
||||
from paramz.caching import Cache_this
|
||||
import itertools
|
||||
from functools import reduce
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
# Copyright (c) 2012, GPy authors (see AUTHORS.txt).
|
||||
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
||||
|
||||
from ....core.parameterization.parameter_core import Pickleable
|
||||
from ....util.caching import Cache_this
|
||||
from ....core.parameterization import variational
|
||||
from paramz.core.pickleable import Pickleable
|
||||
from paramz.caching import Cache_this
|
||||
from GPy.core.parameterization import variational
|
||||
#from linear_psi_comp import LINEAr
|
||||
|
||||
class PSICOMP(Pickleable):
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ An approximated psi-statistics implementation based on Gauss-Hermite Quadrature
|
|||
import numpy as np
|
||||
|
||||
from ....core.parameterization import Param
|
||||
from ....util.caching import Cache_this
|
||||
from paramz.caching import Cache_this
|
||||
from ....util.linalg import tdot
|
||||
from . import PSICOMP
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ class PSICOMP_GH(PSICOMP):
|
|||
@Cache_this(limit=10, ignore_args=(0,))
|
||||
def comp_K(self, Z, qX):
|
||||
if self.Xs is None or self.Xs.shape != qX.mean.shape:
|
||||
from ....core.parameterization import ObsAr
|
||||
from paramz import ObsAr
|
||||
self.Xs = ObsAr(np.empty((self.degree,)+qX.mean.shape))
|
||||
mu, S = qX.mean.values, qX.variance.values
|
||||
S_sq = np.sqrt(S)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ The module for psi-statistics for RBF kernel
|
|||
"""
|
||||
|
||||
import numpy as np
|
||||
from GPy.util.caching import Cacher
|
||||
from paramz.caching import Cacher
|
||||
|
||||
def psicomputations(variance, lengthscale, Z, variational_posterior, return_psi2_n=False):
|
||||
# here are the "statistics" for psi0, psi1 and psi2
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ The module for psi-statistics for RBF kernel
|
|||
"""
|
||||
|
||||
import numpy as np
|
||||
from ....util.caching import Cache_this
|
||||
from paramz.caching import Cache_this
|
||||
from . import PSICOMP_RBF
|
||||
from ....util import gpu_init
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ The module for psi-statistics for RBF kernel for Spike-and-Slab GPLVM
|
|||
"""
|
||||
|
||||
import numpy as np
|
||||
from ....util.caching import Cache_this
|
||||
from paramz.caching import Cache_this
|
||||
from . import PSICOMP_RBF
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import numpy as np
|
|||
from .stationary import Stationary
|
||||
from .psi_comp import PSICOMP_RBF, PSICOMP_RBF_GPU
|
||||
from ...core import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from paramz.transformations import Logexp
|
||||
|
||||
class RBF(Stationary):
|
||||
"""
|
||||
|
|
@ -47,12 +47,13 @@ class RBF(Stationary):
|
|||
return dc
|
||||
|
||||
def __setstate__(self, state):
|
||||
self.use_invLengthscale = False
|
||||
return super(RBF, self).__setstate__(state)
|
||||
|
||||
def spectrum(self, omega):
|
||||
assert self.input_dim == 1 #TODO: higher dim spectra?
|
||||
return self.variance*np.sqrt(2*np.pi)*self.lengthscale*np.exp(-self.lengthscale*2*omega**2/2)
|
||||
|
||||
|
||||
def parameters_changed(self):
|
||||
if self.use_invLengthscale: self.lengthscale[:] = 1./np.sqrt(self.inv_l+1e-200)
|
||||
super(RBF,self).parameters_changed()
|
||||
|
|
@ -85,7 +86,7 @@ class RBF(Stationary):
|
|||
|
||||
def gradients_qX_expectations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior):
|
||||
return self.psicomp.psiDerivativecomputations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior)[3:]
|
||||
|
||||
|
||||
def update_gradients_diag(self, dL_dKdiag, X):
|
||||
super(RBF,self).update_gradients_diag(dL_dKdiag, X)
|
||||
if self.use_invLengthscale: self.inv_l.gradient =self.lengthscale.gradient*(self.lengthscale**3/-2.)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import numpy as np
|
||||
from .kern import Kern
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from paramz.transformations import Logexp
|
||||
|
||||
class Spline(Kern):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ Neural Networks and Machine Learning, pages 133-165. Springer, 1998.
|
|||
|
||||
from .kern import Kern
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from paramz.transformations import Logexp
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
from .kern import Kern
|
||||
import numpy as np
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from paramz.transformations import Logexp
|
||||
|
||||
class Static(Kern):
|
||||
def __init__(self, input_dim, variance, active_dims, name):
|
||||
|
|
|
|||
|
|
@ -2,15 +2,15 @@
|
|||
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
||||
|
||||
|
||||
from .kern import Kern
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from ...util.linalg import tdot
|
||||
from ... import util
|
||||
import numpy as np
|
||||
from scipy import integrate
|
||||
from .kern import Kern
|
||||
from ...core.parameterization import Param
|
||||
from ...util.linalg import tdot
|
||||
from ... import util
|
||||
from ...util.config import config # for assesing whether to use cython
|
||||
from ...util.caching import Cache_this
|
||||
from paramz.caching import Cache_this
|
||||
from paramz.transformations import Logexp
|
||||
|
||||
try:
|
||||
from . import stationary_cython
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
import numpy as np
|
||||
from .kern import Kern
|
||||
from ...core.parameterization import Param
|
||||
from ...core.parameterization.transformations import Logexp
|
||||
from ...util.caching import Cache_this
|
||||
from paramz.transformations import Logexp
|
||||
from paramz.caching import Cache_this
|
||||
|
||||
class TruncLinear(Kern):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue