From 97acb36b5596745cfd762eefde2172c70384e09b Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 26 Jun 2013 17:29:37 +0100 Subject: [PATCH 1/2] new constrain_negative negative_logexp (selected by default) --- GPy/core/parameterised.py | 2 +- GPy/core/transformations.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/GPy/core/parameterised.py b/GPy/core/parameterised.py index 13467fdf..af96e0a7 100644 --- a/GPy/core/parameterised.py +++ b/GPy/core/parameterised.py @@ -199,7 +199,7 @@ class Parameterised(object): def constrain_negative(self, regexp): """ Set negative constraints. """ - self.constrain(regexp, transformations.negative_exponent()) + self.constrain(regexp, transformations.negative_logexp()) def constrain_positive(self, regexp): """ Set positive constraints. """ diff --git a/GPy/core/transformations.py b/GPy/core/transformations.py index 2520a33b..5db835a9 100644 --- a/GPy/core/transformations.py +++ b/GPy/core/transformations.py @@ -36,6 +36,20 @@ class logexp(transformation): def __str__(self): return '(+ve)' +class negative_logexp(transformation): + domain = NEGATIVE + def f(self, x): + return -np.log(1. + np.exp(x)) + def finv(self, f): + return np.log(np.exp(-f) - 1.) + def gradfactor(self, f): + ef = np.exp(-f) + return -(ef - 1.) / ef + def initialize(self, f): + return -np.abs(f) + def __str__(self): + return '(-ve)' + class logexp_clipped(transformation): max_bound = 1e100 min_bound = 1e-10 From b9ca93e8abb716065680809e6cedf0d36fdeb93d Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 26 Jun 2013 18:41:05 +0100 Subject: [PATCH 2/2] Fixed bug in constructors --- GPy/kern/constructors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPy/kern/constructors.py b/GPy/kern/constructors.py index 697f3554..487a324b 100644 --- a/GPy/kern/constructors.py +++ b/GPy/kern/constructors.py @@ -227,7 +227,7 @@ def periodic_Matern52(input_dim, variance=1., lengthscale=None, period=2 * np.pi :param n_freq: the number of frequencies considered for the periodic subspace :type n_freq: int """ - part = parts.periodic_Matern52part(input_dim, variance, lengthscale, period, n_freq, lower, upper) + part = parts.periodic_Matern52.PeriodicMatern52(input_dim, variance, lengthscale, period, n_freq, lower, upper) return kern(input_dim, [part]) def prod(k1,k2,tensor=False):