Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
3214c980
Commit
3214c980
authored
Feb 16, 2021
by
Martin Reinecke
Browse files
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
Changes
1
Pipelines
10
Hide whitespace changes
Inline
Side-by-side
src/pointwise.py
View file @
3214c980
...
...
@@ -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
))
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment