There is a maintenance of MPCDF Gitlab on Thursday, April 22st 2020, 9:00 am CEST - Expect some service interruptions during this time

Commit 3214c980 authored by Martin Reinecke's avatar Martin Reinecke

Merge branch 'inverse_trig_nonlins' into 'NIFTy_7'

Inverse trigonometric and unitstep nonlinearities

See merge request !598
parents 57cbbc96 415e1f61
Pipeline #94209 passed with stages
in 24 minutes and 22 seconds
......@@ -82,6 +82,14 @@ def _clip_helper(v, a_min, a_max):
tmp2 = np.where(tmp == a_max, 0., tmp2)
return (tmp, tmp2)
def _step_helper(v, grad):
if np.issubdtype(v.dtype, np.complexfloating):
raise TypeError("Argument must not be complex")
r = np.zeros(v.shape)
r[v>=0.] = 1.
if grad:
return (r, np.zeros(v.shape))
return r
def softplus(v):
fv = np.empty(v.shape, dtype=np.float64 if np.isrealobj(v) else np.complex128)
......@@ -141,5 +149,7 @@ ptw_dict = {
"power": (np.power, _power_helper),
"clip": (np.clip, _clip_helper),
"softplus": (softplus, _softplus_helper),
"exponentiate": (exponentiate, _exponentiate_helper)
"exponentiate": (exponentiate, _exponentiate_helper),
"arctan": (np.arctan, lambda v: (np.arctan(v), 1./(1.+v**2))),
"unitstep": (lambda v: _step_helper(v, False), lambda v: _step_helper(v, True))
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