Revert "[pickling] _src -> src"

This reverts commit 4cd16a86b4.
This commit is contained in:
Max Zwiessele 2015-10-16 15:06:10 +01:00
parent 4cd16a86b4
commit 29921e1c69
9 changed files with 34 additions and 69 deletions

View file

@ -1,8 +1,10 @@
"""
Kernel module the kernels to sit in.
.. automodule:: .src
:members:
:private-members:
"""
from . import src
from .src.kern import Kern
from .src.add import Add
from .src.prod import Prod

View file

@ -54,22 +54,13 @@ class Kern(Parameterized):
self.active_dims = active_dims
self._all_dims_active = np.atleast_1d(active_dims).astype(int)
assert self._all_dims_active.size == self.input_dim, "input_dim={} does not match len(active_dim)={}, active_dim={}".format(self.input_dim, self._all_dims_active.size, self._all_dims_active)
assert self._all_dims_active.size == self.input_dim, "input_dim={} does not match len(active_dim)={}, _all_dims_active={}".format(self.input_dim, self._all_dims_active.size, self._all_dims_active)
self._sliced_X = 0
self.useGPU = self._support_GPU and useGPU
from .psi_comp import PSICOMP_GH
self.psicomp = PSICOMP_GH()
@property
def _all_dims_active(self):
if not hasattr(self, '__all_dims_active'):
self.__all_dims_active = np.asanyarray(self.active_dims)
return self.__all_dims_active
@_all_dims_active.setter
def _all_dims_active(self, active_dims):
self.__all_dims_active = np.asanyarray(active_dims)
self.psicomp = PSICOMP_GH()
@property
def _effective_input_dim(self):
@ -220,15 +211,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]
@ -244,7 +235,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

View file

@ -47,13 +47,12 @@ 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()
@ -86,7 +85,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.)