diff --git a/GPy/core/transformations.py b/GPy/core/transformations.py index 8982e939..ff821851 100644 --- a/GPy/core/transformations.py +++ b/GPy/core/transformations.py @@ -50,7 +50,9 @@ class logexp_clipped(transformation): ef = np.exp(f) gf = (ef - 1.) / ef return np.where(f < 1e-6, 0, gf) - def initialize(self, f): + def initialize(self,f): + if np.any(f<0.): + print "Warning: changing parameters to satisfy constraints" return np.abs(f) def __str__(self): return '(+ve)' @@ -65,6 +67,8 @@ class exponent(transformation): def gradfactor(self, f): return f def initialize(self, f): + if np.any(f<0.): + print "Warning: changing parameters to satisfy constraints" return np.abs(f) def __str__(self): return '(+ve)' @@ -79,6 +83,8 @@ class negative_exponent(transformation): def gradfactor(self, f): return f def initialize(self, f): + if np.any(f>0.): + print "Warning: changing parameters to satisfy constraints" return -np.abs(f) def __str__(self): return '(-ve)' @@ -108,9 +114,11 @@ class logistic(transformation): def finv(self, f): return np.log(np.clip(f - self.lower, 1e-10, np.inf) / np.clip(self.upper - f, 1e-10, np.inf)) def gradfactor(self, f): - return (f - self.lower) * (self.upper - f) / self.difference - def initialize(self, f): - return self.f(f * 0.) + return (f-self.lower)*(self.upper-f)/self.difference + def initialize(self,f): + if np.any(np.logical_or(fself.upper)): + print "Warning: changing parameters to satisfy constraints" + return np.where(np.logical_or(fself.upper),self.f(f*0.),f) def __str__(self): return '({},{})'.format(self.lower, self.upper)