Commit eb80cb32 authored by Philipp Arras's avatar Philipp Arras
Browse files

Add clipped_exp

parent 3e343cd4
...@@ -675,3 +675,9 @@ for f in ["sqrt", "exp", "log", "tanh"]: ...@@ -675,3 +675,9 @@ for f in ["sqrt", "exp", "log", "tanh"]:
return Field(self._domain, getattr(dobj, f)(self.val)) return Field(self._domain, getattr(dobj, f)(self.val))
return func2 return func2
setattr(Field, f, func(f)) 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): ...@@ -176,6 +176,10 @@ class Linearization(object):
tmp = self._val.exp() tmp = self._val.exp()
return, makeOp(tmp)(self._jac)) return, makeOp(tmp)(self._jac))
def clipped_exp(self):
tmp = self._val.clipped_exp()
return, makeOp(tmp)(self._jac))
def log(self): def log(self):
tmp = self._val.log() tmp = self._val.log()
return, makeOp(1./self._val)(self._jac)) return, makeOp(1./self._val)(self._jac))
...@@ -88,7 +88,7 @@ class Operator(NiftyMetaBase()): ...@@ -88,7 +88,7 @@ class Operator(NiftyMetaBase()):
return self.__class__.__name__ 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 func(f):
def func2(self): def func2(self):
fa = _FunctionApplier(, f) fa = _FunctionApplier(, 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