mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-07 11:02:38 +02:00
[pickle] load errors bc of kernel changes, backwards compatibility issues fixed
This commit is contained in:
parent
6f9c5042f9
commit
850c10beaa
4 changed files with 42 additions and 53 deletions
|
|
@ -58,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):
|
||||
|
|
@ -209,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]
|
||||
|
|
@ -233,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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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.)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue