mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-10 20:42:39 +02:00
pickling unified with __getstate__ and __setstate__
This commit is contained in:
parent
1e06ca2d40
commit
05e8e75c58
5 changed files with 35 additions and 13 deletions
|
|
@ -57,7 +57,6 @@ class GPBase(Model):
|
||||||
self.num_data = state.pop()
|
self.num_data = state.pop()
|
||||||
self.X = state.pop()
|
self.X = state.pop()
|
||||||
Model.__setstate__(self, state)
|
Model.__setstate__(self, state)
|
||||||
self._set_params(self._get_params())
|
|
||||||
|
|
||||||
def plot_f(self, samples=0, plot_limits=None, which_data='all', which_parts='all', resolution=None, full_cov=False, fignum=None, ax=None):
|
def plot_f(self, samples=0, plot_limits=None, which_data='all', which_parts='all', resolution=None, full_cov=False, fignum=None, ax=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,28 @@ class kern(Parameterised):
|
||||||
|
|
||||||
Parameterised.__init__(self)
|
Parameterised.__init__(self)
|
||||||
|
|
||||||
|
def __getstate__(self):
|
||||||
|
"""
|
||||||
|
Get the current state of the class,
|
||||||
|
here just all the indices, rest can get recomputed
|
||||||
|
"""
|
||||||
|
return Parameterised.__getstate__(self) + [self.parts,
|
||||||
|
self.Nparts,
|
||||||
|
self.num_params,
|
||||||
|
self.input_dim,
|
||||||
|
self.input_slices,
|
||||||
|
self.param_slices
|
||||||
|
]
|
||||||
|
|
||||||
|
def __setstate__(self, state):
|
||||||
|
self.param_slices = state.pop()
|
||||||
|
self.input_slices = state.pop()
|
||||||
|
self.input_dim = state.pop()
|
||||||
|
self.num_params = state.pop()
|
||||||
|
self.Nparts = state.pop()
|
||||||
|
self.parts = state.pop()
|
||||||
|
Parameterised.__setstate__(self, state)
|
||||||
|
|
||||||
|
|
||||||
def plot_ARD(self, fignum=None, ax=None, title=None):
|
def plot_ARD(self, fignum=None, ax=None, title=None):
|
||||||
"""If an ARD kernel is present, it bar-plots the ARD parameters"""
|
"""If an ARD kernel is present, it bar-plots the ARD parameters"""
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class BayesianGPLVM(SparseGP, GPLVM):
|
||||||
Get the current state of the class,
|
Get the current state of the class,
|
||||||
here just all the indices, rest can get recomputed
|
here just all the indices, rest can get recomputed
|
||||||
"""
|
"""
|
||||||
return [self.init] + SparseGP.__getstate__(self)
|
return SparseGP.__getstate__(self) + [self.init]
|
||||||
|
|
||||||
def __setstate__(self, state):
|
def __setstate__(self, state):
|
||||||
self.init = state.pop()
|
self.init = state.pop()
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ class MRD(Model):
|
||||||
self.ensure_default_constraints()
|
self.ensure_default_constraints()
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
return [self.names,
|
return Model.__getstate__(self) + [self.names,
|
||||||
self.bgplvms,
|
self.bgplvms,
|
||||||
self.gref,
|
self.gref,
|
||||||
self.nparams,
|
self.nparams,
|
||||||
|
|
@ -105,6 +105,7 @@ class MRD(Model):
|
||||||
self.gref = state.pop()
|
self.gref = state.pop()
|
||||||
self.bgplvms = state.pop()
|
self.bgplvms = state.pop()
|
||||||
self.names = state.pop()
|
self.names = state.pop()
|
||||||
|
Model.__setstate__(self, state)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def X(self):
|
def X(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue