Skip to content
GitLab
Menu
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
eb3d1fd2
Commit
eb3d1fd2
authored
Dec 21, 2018
by
Martin Reinecke
Browse files
byebye clipped_exp()
parent
9483e218
Changes
6
Hide whitespace changes
Inline
Side-by-side
nifty5/data_objects/distributed_do.py
View file @
eb3d1fd2
...
...
@@ -35,7 +35,7 @@ __all__ = ["ntask", "rank", "master", "local_shape", "data_object", "full",
"redistribute"
,
"default_distaxis"
,
"is_numpy"
,
"absmax"
,
"norm"
,
"lock"
,
"locked"
,
"uniform_full"
,
"transpose"
,
"to_global_data_rw"
,
"ensure_not_distributed"
,
"ensure_default_distributed"
,
"clipped_exp"
,
"tanh"
,
"conjugate"
,
"sin"
,
"cos"
,
"tan"
,
"tanh"
,
"conjugate"
,
"sin"
,
"cos"
,
"tan"
,
"sinh"
,
"cosh"
,
"sinc"
,
"absolute"
,
"sign"
,
"clip"
]
_comm
=
MPI
.
COMM_WORLD
...
...
@@ -309,10 +309,6 @@ for f in ["sqrt", "exp", "log", "tanh", "conjugate", "sin", "cos", "tan",
setattr
(
_current_module
,
f
,
func
(
f
))
def
clipped_exp
(
x
):
return
data_object
(
x
.
shape
,
np
.
exp
(
np
.
clip
(
x
.
data
,
-
300
,
300
),
x
.
distaxis
))
def
clip
(
x
,
a_min
=
None
,
a_max
=
None
):
return
data_object
(
x
.
shape
,
np
.
clip
(
x
.
data
,
a_min
,
a_max
),
x
.
distaxis
)
...
...
nifty5/data_objects/numpy_do.py
View file @
eb3d1fd2
...
...
@@ -35,7 +35,7 @@ __all__ = ["ntask", "rank", "master", "local_shape", "data_object", "full",
"redistribute"
,
"default_distaxis"
,
"is_numpy"
,
"absmax"
,
"norm"
,
"lock"
,
"locked"
,
"uniform_full"
,
"to_global_data_rw"
,
"ensure_not_distributed"
,
"ensure_default_distributed"
,
"clipped_exp"
,
"clip"
,
"sin"
,
"cos"
,
"tan"
,
"sinh"
,
"clip"
,
"sin"
,
"cos"
,
"tan"
,
"sinh"
,
"cosh"
,
"absolute"
,
"sign"
,
"sinc"
]
ntask
=
1
...
...
@@ -152,7 +152,3 @@ def absmax(arr):
def
norm
(
arr
,
ord
=
2
):
return
np
.
linalg
.
norm
(
arr
.
reshape
(
-
1
),
ord
=
ord
)
def
clipped_exp
(
arr
):
return
np
.
exp
(
np
.
clip
(
arr
,
-
300
,
300
))
nifty5/field.py
View file @
eb3d1fd2
...
...
@@ -634,9 +634,6 @@ class Field(object):
def
sigmoid
(
self
):
return
0.5
*
(
1.
+
self
.
tanh
())
def
clipped_exp
(
self
):
return
Field
(
self
.
_domain
,
dobj
.
clipped_exp
(
self
.
_val
))
def
clip
(
self
,
min
=
None
,
max
=
None
):
return
Field
(
self
.
_domain
,
dobj
.
clip
(
self
.
_val
,
min
,
max
))
...
...
nifty5/linearization.py
View file @
eb3d1fd2
...
...
@@ -184,14 +184,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
clip
(
self
,
min
=
None
,
max
=
None
):
tmp
=
self
.
_val
.
clip
(
min
,
max
)
if
(
min
is
None
)
and
(
max
is
None
):
tmp2
=
ScalingOperator
(
1
,
self
.
_val
.
domain
)
return
self
elif
max
is
None
:
tmp2
=
makeOp
(
1.
-
(
tmp
==
min
))
elif
min
is
None
:
...
...
nifty5/multi_field.py
View file @
eb3d1fd2
...
...
@@ -194,6 +194,10 @@ class MultiField(object):
def
conjugate
(
self
):
return
self
.
_transform
(
lambda
x
:
x
.
conjugate
())
def
clip
(
self
,
min
=
None
,
max
=
None
):
return
MultiField
(
self
.
_domain
,
tuple
(
clip
(
v
,
min
,
max
)
for
v
in
self
.
_val
))
def
all
(
self
):
for
v
in
self
.
_val
:
if
not
v
.
all
():
...
...
@@ -296,7 +300,7 @@ for op in ["__iadd__", "__isub__", "__imul__", "__idiv__",
setattr
(
MultiField
,
op
,
func
(
op
))
for
f
in
[
"sqrt"
,
"exp"
,
"log"
,
"tanh"
,
"clipped_exp"
]:
for
f
in
[
"sqrt"
,
"exp"
,
"log"
,
"tanh"
]:
def
func
(
f
):
def
func2
(
self
):
fu
=
getattr
(
Field
,
f
)
...
...
nifty5/operators/operator.py
View file @
eb3d1fd2
...
...
@@ -112,8 +112,7 @@ class Operator(NiftyMetaBase()):
return
self
.
__class__
.
__name__
for
f
in
[
"sqrt"
,
"exp"
,
"log"
,
"tanh"
,
"sigmoid"
,
'clipped_exp'
,
'sin'
,
'cos'
,
'tan'
,
for
f
in
[
"sqrt"
,
"exp"
,
"log"
,
"tanh"
,
"sigmoid"
,
'sin'
,
'cos'
,
'tan'
,
'sinh'
,
'cosh'
,
'absolute'
,
'sinc'
,
'one_over'
]:
def
func
(
f
):
def
func2
(
self
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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