mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-10 04:22:38 +02:00
Logistic transformation numerical robustness
This commit is contained in:
parent
c568bad4fb
commit
17b6b94db3
1 changed files with 3 additions and 0 deletions
|
|
@ -195,6 +195,9 @@ class Logistic(Transformation):
|
||||||
self.lower, self.upper = float(lower), float(upper)
|
self.lower, self.upper = float(lower), float(upper)
|
||||||
self.difference = self.upper - self.lower
|
self.difference = self.upper - self.lower
|
||||||
def f(self, x):
|
def f(self, x):
|
||||||
|
if (x<-300.).any():
|
||||||
|
x = x.copy()
|
||||||
|
x[x<-300.] = -300.
|
||||||
return self.lower + self.difference / (1. + np.exp(-x))
|
return self.lower + self.difference / (1. + np.exp(-x))
|
||||||
def finv(self, f):
|
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))
|
return np.log(np.clip(f - self.lower, 1e-10, np.inf) / np.clip(self.upper - f, 1e-10, np.inf))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue