mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-09 20:12:38 +02:00
added domains in transformatins and priors
This commit is contained in:
parent
f403e5b0b7
commit
3fceef9d67
2 changed files with 10 additions and 13 deletions
|
|
@ -6,8 +6,10 @@ import numpy as np
|
||||||
import pylab as pb
|
import pylab as pb
|
||||||
from scipy.special import gammaln, digamma
|
from scipy.special import gammaln, digamma
|
||||||
from ..util.linalg import pdinv
|
from ..util.linalg import pdinv
|
||||||
|
from GPy.core.domains import UNDEFINED
|
||||||
|
|
||||||
class prior:
|
class prior:
|
||||||
|
domain = UNDEFINED
|
||||||
def pdf(self,x):
|
def pdf(self,x):
|
||||||
return np.exp(self.lnpdf(x))
|
return np.exp(self.lnpdf(x))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,10 @@
|
||||||
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from GPy.core.domains import UNDEFINED, POSITIVE, NEGATIVE, BOUNDED
|
||||||
|
|
||||||
class transformation(object):
|
class transformation(object):
|
||||||
def __init__(self):
|
domain = UNDEFINED
|
||||||
# set the domain. Suggest we use 'positive', 'bounded', etc
|
|
||||||
self.domain = 'undefined'
|
|
||||||
def f(self, x):
|
def f(self, x):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
@ -24,8 +23,7 @@ class transformation(object):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
class logexp(transformation):
|
class logexp(transformation):
|
||||||
def __init__(self):
|
domain = POSITIVE
|
||||||
self.domain = 'positive'
|
|
||||||
def f(self, x):
|
def f(self, x):
|
||||||
return np.log(1. + np.exp(x))
|
return np.log(1. + np.exp(x))
|
||||||
def finv(self, f):
|
def finv(self, f):
|
||||||
|
|
@ -43,8 +41,8 @@ class logexp_clipped(transformation):
|
||||||
min_bound = 1e-10
|
min_bound = 1e-10
|
||||||
log_max_bound = np.log(max_bound)
|
log_max_bound = np.log(max_bound)
|
||||||
log_min_bound = np.log(min_bound)
|
log_min_bound = np.log(min_bound)
|
||||||
|
domain = POSITIVE
|
||||||
def __init__(self, lower=1e-6):
|
def __init__(self, lower=1e-6):
|
||||||
self.domain = 'positive'
|
|
||||||
self.lower = lower
|
self.lower = lower
|
||||||
def f(self, x):
|
def f(self, x):
|
||||||
exp = np.exp(np.clip(x, self.log_min_bound, self.log_max_bound))
|
exp = np.exp(np.clip(x, self.log_min_bound, self.log_max_bound))
|
||||||
|
|
@ -66,8 +64,7 @@ class logexp_clipped(transformation):
|
||||||
return '(+ve_c)'
|
return '(+ve_c)'
|
||||||
|
|
||||||
class exponent(transformation):
|
class exponent(transformation):
|
||||||
def __init__(self):
|
domain = POSITIVE
|
||||||
self.domain = 'positive'
|
|
||||||
def f(self, x):
|
def f(self, x):
|
||||||
return np.exp(x)
|
return np.exp(x)
|
||||||
def finv(self, x):
|
def finv(self, x):
|
||||||
|
|
@ -82,8 +79,7 @@ class exponent(transformation):
|
||||||
return '(+ve)'
|
return '(+ve)'
|
||||||
|
|
||||||
class negative_exponent(transformation):
|
class negative_exponent(transformation):
|
||||||
def __init__(self):
|
domain = NEGATIVE
|
||||||
self.domain = 'negative'
|
|
||||||
def f(self, x):
|
def f(self, x):
|
||||||
return -np.exp(x)
|
return -np.exp(x)
|
||||||
def finv(self, x):
|
def finv(self, x):
|
||||||
|
|
@ -98,8 +94,7 @@ class negative_exponent(transformation):
|
||||||
return '(-ve)'
|
return '(-ve)'
|
||||||
|
|
||||||
class square(transformation):
|
class square(transformation):
|
||||||
def __init__(self):
|
domain = POSITIVE
|
||||||
self.domain = 'positive'
|
|
||||||
def f(self, x):
|
def f(self, x):
|
||||||
return x ** 2
|
return x ** 2
|
||||||
def finv(self, x):
|
def finv(self, x):
|
||||||
|
|
@ -112,8 +107,8 @@ class square(transformation):
|
||||||
return '(+sq)'
|
return '(+sq)'
|
||||||
|
|
||||||
class logistic(transformation):
|
class logistic(transformation):
|
||||||
|
domain = BOUNDED
|
||||||
def __init__(self, lower, upper):
|
def __init__(self, lower, upper):
|
||||||
self.domain = 'bounded'
|
|
||||||
assert lower < upper
|
assert lower < upper
|
||||||
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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue