mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-10 12:32:40 +02:00
logexp_clipped adjust & mrd error messages
This commit is contained in:
parent
8f5d577bbb
commit
4ef29e1fea
3 changed files with 6 additions and 5 deletions
|
|
@ -39,7 +39,7 @@ class logexp(transformation):
|
||||||
return '(+ve)'
|
return '(+ve)'
|
||||||
|
|
||||||
class logexp_clipped(transformation):
|
class logexp_clipped(transformation):
|
||||||
max_bound = 1e300
|
max_bound = 1e100
|
||||||
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)
|
||||||
|
|
@ -53,11 +53,11 @@ class logexp_clipped(transformation):
|
||||||
# import ipdb;ipdb.set_trace()
|
# import ipdb;ipdb.set_trace()
|
||||||
return np.clip(f, self.min_bound, self.max_bound)
|
return np.clip(f, self.min_bound, self.max_bound)
|
||||||
def finv(self, f):
|
def finv(self, f):
|
||||||
return np.log(np.exp(np.clip(f, self.min_bound, self.max_bound)) - 1.)
|
return np.log(np.exp(f - 1.))
|
||||||
def gradfactor(self, f):
|
def gradfactor(self, f):
|
||||||
ef = np.exp(f) # np.clip(f, self.min_bound, self.max_bound))
|
ef = np.exp(f) # np.clip(f, self.min_bound, self.max_bound))
|
||||||
gf = (ef - 1.) / ef
|
gf = (ef - 1.) / ef
|
||||||
return np.where(f < self.lower, 0, gf)
|
return gf # np.where(f < self.lower, 0, gf)
|
||||||
def initialize(self, f):
|
def initialize(self, f):
|
||||||
if np.any(f < 0.):
|
if np.any(f < 0.):
|
||||||
print "Warning: changing parameters to satisfy constraints"
|
print "Warning: changing parameters to satisfy constraints"
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ def bgplvm_simulation(optimize='scg',
|
||||||
return m
|
return m
|
||||||
|
|
||||||
def mrd_simulation(optimize=True, plot_sim=False, **kw):
|
def mrd_simulation(optimize=True, plot_sim=False, **kw):
|
||||||
D1, D2, D3, N, M, Q = 150, 200, 400, 700, 3, 7
|
D1, D2, D3, N, M, Q = 150, 200, 400, 300, 3, 7
|
||||||
slist, Slist, Ylist = _simulate_sincos(D1, D2, D3, N, M, Q, plot_sim)
|
slist, Slist, Ylist = _simulate_sincos(D1, D2, D3, N, M, Q, plot_sim)
|
||||||
|
|
||||||
from GPy.models import mrd
|
from GPy.models import mrd
|
||||||
|
|
@ -287,7 +287,7 @@ def mrd_simulation(optimize=True, plot_sim=False, **kw):
|
||||||
|
|
||||||
reload(mrd); reload(kern)
|
reload(mrd); reload(kern)
|
||||||
|
|
||||||
k = kern.linear(Q, [0.01] * Q, True) + kern.bias(Q, np.exp(-2)) + kern.white(Q, np.exp(-2))
|
k = kern.linear(Q, [0.05] * Q, True) + kern.bias(Q, np.exp(-2)) + kern.white(Q, np.exp(-2))
|
||||||
m = mrd.MRD(Ylist, Q=Q, M=M, kernels=k, initx="concat", initz='permute', **kw)
|
m = mrd.MRD(Ylist, Q=Q, M=M, kernels=k, initx="concat", initz='permute', **kw)
|
||||||
|
|
||||||
for i, Y in enumerate(Ylist):
|
for i, Y in enumerate(Ylist):
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ class MRD(model):
|
||||||
else:
|
else:
|
||||||
assert len(kernels) == len(likelihood_or_Y_list), "need one kernel per output"
|
assert len(kernels) == len(likelihood_or_Y_list), "need one kernel per output"
|
||||||
assert all([isinstance(k, kern) for k in kernels]), "invalid kernel object detected!"
|
assert all([isinstance(k, kern) for k in kernels]), "invalid kernel object detected!"
|
||||||
|
assert not ('kernel' in kw), "pass kernels through `kernels` argument"
|
||||||
|
|
||||||
self.Q = Q
|
self.Q = Q
|
||||||
self.M = M
|
self.M = M
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue