From 400a4880c6c88fff76632171835c32930a2e50a8 Mon Sep 17 00:00:00 2001 From: Joan Gonzalvez <44616000+jopago@users.noreply.github.com> Date: Sun, 13 Jan 2019 20:11:11 +0100 Subject: [PATCH 1/2] Update brownian.py added to_dict method --- GPy/kern/src/brownian.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/GPy/kern/src/brownian.py b/GPy/kern/src/brownian.py index 68da4435..88f3af8a 100644 --- a/GPy/kern/src/brownian.py +++ b/GPy/kern/src/brownian.py @@ -23,6 +23,17 @@ class Brownian(Kern): self.variance = Param('variance', variance, Logexp()) self.link_parameters(self.variance) + + def to_dict(self): + """ + Convert the object into a json serializable dictionary. + Note: It uses the private method _save_to_input_dict of the parent. + :return dict: json serializable dictionary containing the needed information to instantiate the object + """ + + input_dict = super(RBF, self)._save_to_input_dict() + input_dict["class"] = "GPy.kern.Brownian" + return input_dict def K(self,X,X2=None): if X2 is None: From b41b0df9a04e4d9328eaae86be666ae7a491231a Mon Sep 17 00:00:00 2001 From: Joan Gonzalvez <44616000+jopago@users.noreply.github.com> Date: Sun, 13 Jan 2019 20:16:32 +0100 Subject: [PATCH 2/2] Update static.py --- GPy/kern/src/static.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/GPy/kern/src/static.py b/GPy/kern/src/static.py index a4831107..e0251337 100644 --- a/GPy/kern/src/static.py +++ b/GPy/kern/src/static.py @@ -64,6 +64,11 @@ class White(Static): def __init__(self, input_dim, variance=1., active_dims=None, name='white'): super(White, self).__init__(input_dim, variance, active_dims, name) + def to_dict(self): + input_dict = super(White, self)._save_to_input_dict() + input_dict["class"] = "GPy.kern.White" + return input_dict + def K(self, X, X2=None): if X2 is None: return np.eye(X.shape[0])*self.variance @@ -102,6 +107,10 @@ class WhiteHeteroscedastic(Static): super(Static, self).__init__(input_dim, active_dims, name) self.variance = Param('variance', np.ones(num_data) * variance, Logexp()) self.link_parameters(self.variance) + def to_dict(self): + input_dict = super(WhiteHeteroscedastic, self)._save_to_input_dict() + input_dict["class"] = "GPy.kern.WhiteHeteroscedastic" + return input_dict def Kdiag(self, X): if X.shape[0] == self.variance.shape[0]: