mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-09 20:12:38 +02:00
new constrain_negative negative_logexp (selected by default)
This commit is contained in:
parent
05e8e75c58
commit
97acb36b55
2 changed files with 15 additions and 1 deletions
|
|
@ -199,7 +199,7 @@ class Parameterised(object):
|
||||||
|
|
||||||
def constrain_negative(self, regexp):
|
def constrain_negative(self, regexp):
|
||||||
""" Set negative constraints. """
|
""" Set negative constraints. """
|
||||||
self.constrain(regexp, transformations.negative_exponent())
|
self.constrain(regexp, transformations.negative_logexp())
|
||||||
|
|
||||||
def constrain_positive(self, regexp):
|
def constrain_positive(self, regexp):
|
||||||
""" Set positive constraints. """
|
""" Set positive constraints. """
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,20 @@ class logexp(transformation):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '(+ve)'
|
return '(+ve)'
|
||||||
|
|
||||||
|
class negative_logexp(transformation):
|
||||||
|
domain = NEGATIVE
|
||||||
|
def f(self, x):
|
||||||
|
return -np.log(1. + np.exp(x))
|
||||||
|
def finv(self, f):
|
||||||
|
return np.log(np.exp(-f) - 1.)
|
||||||
|
def gradfactor(self, f):
|
||||||
|
ef = np.exp(-f)
|
||||||
|
return -(ef - 1.) / ef
|
||||||
|
def initialize(self, f):
|
||||||
|
return -np.abs(f)
|
||||||
|
def __str__(self):
|
||||||
|
return '(-ve)'
|
||||||
|
|
||||||
class logexp_clipped(transformation):
|
class logexp_clipped(transformation):
|
||||||
max_bound = 1e100
|
max_bound = 1e100
|
||||||
min_bound = 1e-10
|
min_bound = 1e-10
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue