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