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
On Thursday, 7th July from 1 to 3 pm there will be a maintenance with a short downtime of GitLab.
Open sidebar
ift
NIFTy
Commits
cb24121f
Commit
cb24121f
authored
Nov 18, 2019
by
Gordian Edenhofer
Browse files
Introduce expm1 by wrapping the numpy function
parent
f240b137
Changes
6
Hide whitespace changes
Inline
Side-by-side
nifty5/data_objects/distributed_do.py
View file @
cb24121f
...
...
@@ -32,7 +32,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"
,
"tanh"
,
"conjugate"
,
"sin"
,
"cos"
,
"tan"
,
"log10"
,
"log1p"
,
"tanh"
,
"conjugate"
,
"sin"
,
"cos"
,
"tan"
,
"log10"
,
"log1p"
,
"expm1"
,
"sinh"
,
"cosh"
,
"sinc"
,
"absolute"
,
"sign"
,
"clip"
]
_comm
=
MPI
.
COMM_WORLD
...
...
@@ -297,7 +297,8 @@ def _math_helper(x, function, out):
_current_module
=
sys
.
modules
[
__name__
]
for
f
in
[
"sqrt"
,
"exp"
,
"log"
,
"tanh"
,
"conjugate"
,
"sin"
,
"cos"
,
"tan"
,
"sinh"
,
"cosh"
,
"sinc"
,
"absolute"
,
"sign"
,
"log10"
,
"log1p"
]:
"sinh"
,
"cosh"
,
"sinc"
,
"absolute"
,
"sign"
,
"log10"
,
"log1p"
,
"expm1"
]:
def
func
(
f
):
def
func2
(
x
,
out
=
None
):
return
_math_helper
(
x
,
f
,
out
)
...
...
nifty5/data_objects/numpy_do.py
View file @
cb24121f
...
...
@@ -22,7 +22,7 @@ from numpy import ndarray as data_object
from
numpy
import
empty
,
empty_like
,
ones
,
zeros
,
full
from
numpy
import
absolute
,
sign
,
clip
,
vdot
from
numpy
import
sin
,
cos
,
sinh
,
cosh
,
tan
,
tanh
from
numpy
import
exp
,
log
,
log10
,
sqrt
,
sinc
,
log1p
from
numpy
import
exp
,
log
,
log10
,
sqrt
,
sinc
,
log1p
,
expm1
from
.random
import
Random
...
...
@@ -35,8 +35,8 @@ __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"
,
"clip"
,
"sin"
,
"cos"
,
"tan"
,
"sinh"
,
"cosh"
,
"absolute"
,
"sign"
,
"sinc"
,
"log10"
,
"log1p"
]
"clip"
,
"sin"
,
"cos"
,
"tan"
,
"sinh"
,
"cosh"
,
"absolute"
,
"sign"
,
"sinc"
,
"log10"
,
"log1p"
,
"expm1"
]
ntask
=
1
rank
=
0
...
...
nifty5/field.py
View file @
cb24121f
...
...
@@ -663,9 +663,8 @@ for op in ["__iadd__", "__isub__", "__imul__", "__idiv__",
return
func2
setattr
(
Field
,
op
,
func
(
op
))
for
f
in
[
"sqrt"
,
"exp"
,
"log"
,
"log10"
,
"log1p"
,
"tanh"
,
"sin"
,
"cos"
,
"tan"
,
"cosh"
,
"sinh"
,
"absolute"
,
"sinc"
,
"sign"
]:
for
f
in
[
"sqrt"
,
"exp"
,
"log"
,
"sin"
,
"cos"
,
"tan"
,
"sinh"
,
"cosh"
,
"tanh"
,
"absolute"
,
"sinc"
,
"sign"
,
"log10"
,
"log1p"
,
"expm1"
]:
def
func
(
f
):
def
func2
(
self
):
return
Field
(
self
.
_domain
,
getattr
(
dobj
,
f
)(
self
.
val
))
...
...
nifty5/linearization.py
View file @
cb24121f
...
...
@@ -341,6 +341,11 @@ class Linearization(object):
jac
=
makeOp
(
1.
/
(
1.
+
xval
))
return
self
.
new
(
res
,
jac
@
self
.
jac
)
def
expm1
(
self
):
tmp
=
self
.
_val
.
expm1
()
tmp2
=
self
.
_val
.
exp
()
return
self
.
new
(
tmp
,
makeOp
(
tmp2
)(
self
.
jac
))
def
sinh
(
self
):
tmp
=
self
.
_val
.
sinh
()
tmp2
=
self
.
_val
.
cosh
()
...
...
nifty5/multi_field.py
View file @
cb24121f
...
...
@@ -338,7 +338,7 @@ for op in ["__iadd__", "__isub__", "__imul__", "__idiv__",
setattr
(
MultiField
,
op
,
func
(
op
))
for
f
in
[
"sqrt"
,
"exp"
,
"log"
,
"log1p"
,
"tanh"
]:
for
f
in
[
"sqrt"
,
"exp"
,
"log"
,
"log1p"
,
"expm1"
,
"tanh"
]:
def
func
(
f
):
def
func2
(
self
):
fu
=
getattr
(
Field
,
f
)
...
...
test/test_linearization.py
View file @
cb24121f
...
...
@@ -54,7 +54,7 @@ def test_special_gradients():
@
pmp
(
'f'
,
[
'log'
,
'exp'
,
'sqrt'
,
'sin'
,
'cos'
,
'tan'
,
'sinc'
,
'sinh'
,
'cosh'
,
'tanh'
,
'absolute'
,
'one_over'
,
'sigmoid'
,
'log10'
,
'log1p'
'absolute'
,
'one_over'
,
'sigmoid'
,
'log10'
,
'log1p'
,
"expm1"
])
def
test_actual_gradients
(
f
):
dom
=
ift
.
UnstructuredDomain
((
1
,))
...
...
Write
Preview
Markdown
is supported
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