mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-08 19:42:39 +02:00
fixing the logexp (with MZ) and some stability issue in the stationary class
This commit is contained in:
parent
22dafabca2
commit
01271e3868
2 changed files with 7 additions and 12 deletions
|
|
@ -7,10 +7,10 @@ from domains import _POSITIVE,_NEGATIVE, _BOUNDED
|
|||
import weakref
|
||||
|
||||
import sys
|
||||
#_lim_val = -np.log(sys.float_info.epsilon)
|
||||
|
||||
_exp_lim_val = np.finfo(np.float64).max
|
||||
_lim_val = np.log(_exp_lim_val)
|
||||
_lim_val = 36.0
|
||||
epsilon = np.finfo(np.float64).resolution
|
||||
|
||||
#===============================================================================
|
||||
# Fixing constants
|
||||
|
|
@ -54,12 +54,12 @@ class Transformation(object):
|
|||
class Logexp(Transformation):
|
||||
domain = _POSITIVE
|
||||
def f(self, x):
|
||||
return np.where(x>_lim_val, x, np.log(1. + np.exp(np.clip(x, -_lim_val, _lim_val))))
|
||||
return np.where(x>_lim_val, x, np.log(1. + np.exp(np.clip(x, -_lim_val, _lim_val)))) + epsilon
|
||||
#raises overflow warning: return np.where(x>_lim_val, x, np.log(1. + np.exp(x)))
|
||||
def finv(self, f):
|
||||
return np.where(f>_lim_val, f, np.log(np.exp(f+1e-20) - 1.))
|
||||
def gradfactor(self, f):
|
||||
return np.where(f>_lim_val, 1., 1 - np.exp(-f))
|
||||
return np.where(f>_lim_val, 1., 1. - np.exp(-f))
|
||||
def initialize(self, f):
|
||||
if np.any(f < 0.):
|
||||
print "Warning: changing parameters to satisfy constraints"
|
||||
|
|
|
|||
|
|
@ -152,11 +152,6 @@ class Stationary(Kern):
|
|||
This term appears in derviatives.
|
||||
"""
|
||||
dist = self._scaled_dist(X, X2).copy()
|
||||
if X2 is None:
|
||||
nondiag = util.diag.offdiag_view(dist)
|
||||
nondiag[:] = 1./nondiag
|
||||
return dist
|
||||
else:
|
||||
return 1./np.where(dist != 0., dist, np.inf)
|
||||
|
||||
def gradients_X(self, dL_dK, X, X2=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue