Merge branch 'devel' of github.com:SheffieldML/GPy into devel

This commit is contained in:
James Hensman 2013-05-17 10:28:21 +01:00
commit dbfcebe2a0
19 changed files with 410 additions and 330 deletions

View file

@ -39,23 +39,29 @@ class logexp(transformation):
return '(+ve)'
class logexp_clipped(transformation):
def __init__(self):
max_bound = 1e300
min_bound = 1e-10
log_max_bound = np.log(max_bound)
log_min_bound = np.log(min_bound)
def __init__(self, lower=1e-6):
self.domain = 'positive'
self.lower = lower
def f(self, x):
f = np.log(1. + np.exp(x))
exp = np.exp(np.clip(x, self.log_min_bound, self.log_max_bound))
f = np.log(1. + exp)
return f
def finv(self, f):
return np.log(np.exp(f) - 1.)
return np.log(np.exp(np.clip(f, self.min_bound, self.max_bound)) - 1.)
def gradfactor(self, f):
ef = np.exp(f)
gf = (ef - 1.) / ef
return np.where(f < 1e-6, 0, gf)
def initialize(self,f):
if np.any(f<0.):
return np.where(f < self.lower, 0, gf)
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)'
return '(+ve_c)'
class exponent(transformation):
def __init__(self):
@ -67,7 +73,7 @@ class exponent(transformation):
def gradfactor(self, f):
return f
def initialize(self, f):
if np.any(f<0.):
if np.any(f < 0.):
print "Warning: changing parameters to satisfy constraints"
return np.abs(f)
def __str__(self):
@ -83,7 +89,7 @@ class negative_exponent(transformation):
def gradfactor(self, f):
return f
def initialize(self, f):
if np.any(f>0.):
if np.any(f > 0.):
print "Warning: changing parameters to satisfy constraints"
return -np.abs(f)
def __str__(self):
@ -114,11 +120,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):
if np.any(np.logical_or(f<self.lower,f>self.upper)):
return (f - self.lower) * (self.upper - f) / self.difference
def initialize(self, f):
if np.any(np.logical_or(f < self.lower, f > self.upper)):
print "Warning: changing parameters to satisfy constraints"
return np.where(np.logical_or(f<self.lower,f>self.upper),self.f(f*0.),f)
return np.where(np.logical_or(f < self.lower, f > self.upper), self.f(f * 0.), f)
def __str__(self):
return '({},{})'.format(self.lower, self.upper)