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
24addafb
Commit
24addafb
authored
May 20, 2020
by
Philipp Arras
Browse files
Gradient tests also for complex positions, directions and holomorphic
parent
90f0662d
Pipeline
#75322
failed with stages
in 3 minutes and 20 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
test/test_linearization.py
View file @
24addafb
...
...
@@ -57,14 +57,28 @@ def test_special_gradients():
'log'
,
'exp'
,
'sqrt'
,
'sin'
,
'cos'
,
'tan'
,
'sinc'
,
'sinh'
,
'cosh'
,
'tanh'
,
'absolute'
,
'reciprocal'
,
'sigmoid'
,
'log10'
,
'log1p'
,
"expm1"
])
def
test_actual_gradients
(
f
):
@
pmp
(
'cplxpos'
,
[
True
,
False
])
@
pmp
(
'cplxdir'
,
[
True
,
False
])
@
pmp
(
'holomorphic'
,
[
True
,
False
])
def
test_actual_gradients
(
f
,
cplxpos
,
cplxdir
,
holomorphic
):
if
(
cplxpos
or
cplxdir
)
and
f
in
[
'absolute'
]:
return
if
holomorphic
and
f
in
[
'absolute'
]:
# These function are not holomorphic
return
dom
=
ift
.
UnstructuredDomain
((
1
,))
fld
=
ift
.
full
(
dom
,
2.4
)
eps
=
1e-8
if
cplxpos
:
fld
=
fld
+
0.21j
eps
=
1e-7
if
cplxdir
:
eps
*=
1j
if
holomorphic
:
eps
*=
(
1
+
0.78j
)
var0
=
ift
.
Linearization
.
make_var
(
fld
)
var1
=
ift
.
Linearization
.
make_var
(
fld
+
eps
)
f0
=
var0
.
ptw
(
f
).
val
.
val
f1
=
var1
.
ptw
(
f
).
val
.
val
df0
=
(
f1
-
f0
)
/
eps
df1
=
_lin2grad
(
var0
.
ptw
(
f
))
assert_allclose
(
df0
,
df1
,
rtol
=
100
*
eps
)
assert_allclose
(
df0
,
df1
,
rtol
=
100
*
np
.
abs
(
eps
)
)
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