diff --git a/GPy/core/parameterized.py b/GPy/core/parameterized.py index b94689ad..a2f2bf25 100644 --- a/GPy/core/parameterized.py +++ b/GPy/core/parameterized.py @@ -187,7 +187,7 @@ class Parameterized(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 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):