Commit eb80cb32 authored by Philipp Arras's avatar Philipp Arras

Add clipped_exp

parent 3e343cd4
......@@ -675,3 +675,9 @@ for f in ["sqrt", "exp", "log", "tanh"]:
return Field(self._domain, getattr(dobj, f)(self.val))
return func2
setattr(Field, f, func(f))
def func2(self):
np.clip(self.val, -300, 300, out=self.val)
return Field(self._domain, getattr(dobj, 'exp')(self.val))
setattr(Field, 'clipped_exp', func2)
......@@ -176,6 +176,10 @@ class Linearization(object):
tmp = self._val.exp()
return self.new(tmp, makeOp(tmp)(self._jac))
def clipped_exp(self):
tmp = self._val.clipped_exp()
return self.new(tmp, makeOp(tmp)(self._jac))
def log(self):
tmp = self._val.log()
return self.new(tmp, makeOp(1./self._val)(self._jac))
......
......@@ -88,7 +88,7 @@ class Operator(NiftyMetaBase()):
return self.__class__.__name__
for f in ["sqrt", "exp", "log", "tanh", "positive_tanh"]:
for f in ["sqrt", "exp", "log", "tanh", "positive_tanh", 'clipped_exp']:
def func(f):
def func2(self):
fa = _FunctionApplier(self.target, f)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment