last stability changes

This commit is contained in:
Max Zwiessele 2013-05-20 10:11:27 +01:00
parent 3c12f85a28
commit 99017e5e50
4 changed files with 14 additions and 10 deletions

View file

@ -39,8 +39,8 @@ class logexp(transformation):
return '(+ve)'
class logexp_clipped(transformation):
max_bound = 1e300
min_bound = 1e-10
max_bound = 1e250
min_bound = 1e-9
log_max_bound = np.log(max_bound)
log_min_bound = np.log(min_bound)
def __init__(self, lower=1e-6):
@ -49,11 +49,13 @@ class logexp_clipped(transformation):
def f(self, x):
exp = np.exp(np.clip(x, self.log_min_bound, self.log_max_bound))
f = np.log(1. + exp)
if np.isnan(f).any():
import ipdb;ipdb.set_trace()
return f
def finv(self, f):
return np.log(np.exp(np.clip(f, self.min_bound, self.max_bound)) - 1.)
def gradfactor(self, f):
ef = np.exp(f)
ef = np.exp(f) # np.clip(f, self.min_bound, self.max_bound))
gf = (ef - 1.) / ef
return np.where(f < self.lower, 0, gf)
def initialize(self, f):