Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIFTy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
13
Merge Requests
13
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ift
NIFTy
Commits
54c659a9
Commit
54c659a9
authored
May 29, 2018
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
nifty4/extra/energy_tests.py
nifty4/extra/energy_tests.py
+7
-2
test/test_energies/test_map.py
test/test_energies/test_map.py
+4
-2
No files found.
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
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