From 17b6b94db3d80687b07a326667664a733666bf2e Mon Sep 17 00:00:00 2001 From: Zhenwen Dai Date: Fri, 16 May 2014 10:48:18 +0100 Subject: [PATCH] Logistic transformation numerical robustness --- GPy/core/parameterization/transformations.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/GPy/core/parameterization/transformations.py b/GPy/core/parameterization/transformations.py index 506d80cd..df31f09f 100644 --- a/GPy/core/parameterization/transformations.py +++ b/GPy/core/parameterization/transformations.py @@ -195,6 +195,9 @@ class Logistic(Transformation): self.lower, self.upper = float(lower), float(upper) self.difference = self.upper - self.lower def f(self, x): + if (x<-300.).any(): + x = x.copy() + x[x<-300.] = -300. return self.lower + self.difference / (1. + np.exp(-x)) 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))