mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-09 20:12:38 +02:00
minor modifications to the constraint behaviour
This commit is contained in:
parent
e60eb4e236
commit
a91501af56
1 changed files with 9 additions and 1 deletions
|
|
@ -34,6 +34,8 @@ class logexp(transformation):
|
|||
ef = np.exp(f)
|
||||
return (ef - 1.)/ef
|
||||
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)'
|
||||
|
|
@ -48,6 +50,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)'
|
||||
|
|
@ -62,6 +66,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)'
|
||||
|
|
@ -79,7 +85,9 @@ class logistic(transformation):
|
|||
def gradfactor(self,f):
|
||||
return (f-self.lower)*(self.upper-f)/self.difference
|
||||
def initialize(self,f):
|
||||
return self.f(f*0.)
|
||||
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)
|
||||
def __str__(self):
|
||||
return '({},{})'.format(self.lower,self.upper)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue