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
54c659a9
Commit
54c659a9
authored
May 29, 2018
by
Martin Reinecke
Browse files
speed up energy tests; test more spaces
parent
ddbbf9b2
Pipeline
#29972
failed with stages
in 2 minutes and 26 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty4/extra/energy_tests.py
View file @
54c659a9
...
...
@@ -25,9 +25,12 @@ __all__ = ["check_value_gradient_consistency",
def
_get_acceptable_energy
(
E
):
if
not
np
.
isfinite
(
E
.
value
):
val
=
E
.
value
if
not
np
.
isfinite
(
val
):
raise
ValueError
dir
=
from_random
(
"normal"
,
E
.
position
.
domain
)
dirder
=
E
.
gradient
.
vdot
(
dir
)
dir
*=
np
.
abs
(
val
)
/
np
.
abs
(
dirder
)
*
1e-5
# find a step length that leads to a "reasonable" energy
for
i
in
range
(
50
):
try
:
...
...
@@ -45,12 +48,14 @@ def _get_acceptable_energy(E):
def
check_value_gradient_consistency
(
E
,
tol
=
1e-6
,
ntries
=
100
):
for
_
in
range
(
ntries
):
E2
=
_get_acceptable_energy
(
E
)
val
=
E
.
value
dir
=
E2
.
position
-
E
.
position
Enext
=
E2
dirnorm
=
dir
.
norm
()
dirder
=
E
.
gradient
.
vdot
(
dir
)
/
dirnorm
for
i
in
range
(
50
):
if
abs
((
E2
.
value
-
E
.
value
)
/
dirnorm
-
dirder
)
<
tol
:
if
abs
((
E2
.
value
-
val
)
/
dirnorm
-
dirder
)
<
tol
:
print
i
,
dirnorm
,
dirder
,
E2
.
value
-
val
break
dir
*=
0.5
dirnorm
*=
0.5
...
...
test/test_energies/test_map.py
View file @
54c659a9
...
...
@@ -29,7 +29,8 @@ def _flat_PS(k):
class
Energy_Tests
(
unittest
.
TestCase
):
@
expand
(
product
([
ift
.
RGSpace
(
64
,
distances
=
.
789
),
@
expand
(
product
([
ift
.
GLSpace
(
15
),
ift
.
RGSpace
(
64
,
distances
=
.
789
),
ift
.
RGSpace
([
32
,
32
],
distances
=
.
789
)],
[
4
,
78
,
23
]))
def
testLinearMap
(
self
,
space
,
seed
):
...
...
@@ -63,7 +64,8 @@ class Energy_Tests(unittest.TestCase):
ift
.
extra
.
check_value_gradient_curvature_consistency
(
energy
,
tol
=
1e-4
,
ntries
=
10
)
@
expand
(
product
([
ift
.
RGSpace
(
64
,
distances
=
.
789
),
@
expand
(
product
([
ift
.
GLSpace
(
15
),
ift
.
RGSpace
(
64
,
distances
=
.
789
),
ift
.
RGSpace
([
32
,
32
],
distances
=
.
789
)],
[
ift
.
library
.
Tanh
,
ift
.
library
.
Exponential
,
ift
.
library
.
Linear
],
...
...
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