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
9986da5c
Commit
9986da5c
authored
Sep 20, 2018
by
Martin Reinecke
Browse files
cosmetics and test speedup
parent
d33f8631
Changes
2
Hide whitespace changes
Inline
Side-by-side
test/test_models/test_model_gradients.py
View file @
9986da5c
...
...
@@ -64,29 +64,29 @@ class Model_Tests(unittest.TestCase):
dom
=
ift
.
MultiDomain
.
union
((
dom1
,
dom2
))
model
=
ift
.
FieldAdapter
(
dom
,
"s1"
)
*
ift
.
FieldAdapter
(
dom
,
"s2"
)
pos
=
ift
.
from_random
(
"normal"
,
dom
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
,
ntries
=
20
)
model
=
ift
.
FieldAdapter
(
dom
,
"s1"
)
+
ift
.
FieldAdapter
(
dom
,
"s2"
)
pos
=
ift
.
from_random
(
"normal"
,
dom
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
,
ntries
=
20
)
model
=
ift
.
FieldAdapter
(
dom
,
"s1"
).
scale
(
3.
)
pos
=
ift
.
from_random
(
"normal"
,
dom1
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
,
ntries
=
20
)
model
=
ift
.
ScalingOperator
(
2.456
,
space
)(
ift
.
FieldAdapter
(
dom
,
"s1"
)
*
ift
.
FieldAdapter
(
dom
,
"s2"
))
pos
=
ift
.
from_random
(
"normal"
,
dom
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
,
ntries
=
20
)
model
=
ift
.
positive_tanh
(
ift
.
ScalingOperator
(
2.456
,
space
)(
ift
.
FieldAdapter
(
dom
,
"s1"
)
*
ift
.
FieldAdapter
(
dom
,
"s2"
)))
pos
=
ift
.
from_random
(
"normal"
,
dom
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
,
ntries
=
20
)
pos
=
ift
.
from_random
(
"normal"
,
dom
)
model
=
ift
.
OuterProduct
(
pos
[
's1'
],
ift
.
makeDomain
(
space
))
#(ift.FieldAdapter(dom, "s2"))
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
[
's2'
])
model
=
ift
.
OuterProduct
(
pos
[
's1'
],
ift
.
makeDomain
(
space
))
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
[
's2'
]
,
ntries
=
20
)
if
isinstance
(
space
,
ift
.
RGSpace
):
model
=
ift
.
FFTOperator
(
space
)(
ift
.
FieldAdapter
(
dom
,
"s1"
)
*
ift
.
FieldAdapter
(
dom
,
"s2"
))
pos
=
ift
.
from_random
(
"normal"
,
dom
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
,
ntries
=
20
)
@
expand
(
product
(
[
ift
.
GLSpace
(
15
),
...
...
@@ -109,12 +109,12 @@ class Model_Tests(unittest.TestCase):
sv
,
im
,
iv
)
S
=
ift
.
ScalingOperator
(
1.
,
model
.
domain
)
pos
=
S
.
draw_sample
()
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
,
ntries
=
20
)
model2
=
ift
.
CorrelatedField
(
space
,
model
)
S
=
ift
.
ScalingOperator
(
1.
,
model2
.
domain
)
pos
=
S
.
draw_sample
()
ift
.
extra
.
check_value_gradient_consistency
(
model2
,
pos
)
ift
.
extra
.
check_value_gradient_consistency
(
model2
,
pos
,
ntries
=
20
)
@
expand
(
product
(
[
ift
.
GLSpace
(
15
),
...
...
@@ -128,7 +128,8 @@ class Model_Tests(unittest.TestCase):
q
=
0.73
model
=
ift
.
InverseGammaModel
(
space
,
alpha
,
q
)
# FIXME All those cdfs and ppfs are not very accurate
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
,
tol
=
1e-2
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
,
tol
=
1e-2
,
ntries
=
20
)
# @expand(product(
# ['Variable', 'Constant'],
...
...
test/test_operators/test_adjoint.py
View file @
9986da5c
...
...
@@ -259,11 +259,13 @@ class Consistency_Tests(unittest.TestCase):
ift
.
extra
.
consistency_check
(
op
)
@
expand
(
product
([
ift
.
DomainTuple
.
make
((
ift
.
RGSpace
((
3
,
5
,
4
)),
ift
.
RGSpace
((
16
,),
distances
=
(
7.
,))),),
ift
.
RGSpace
((
16
,),
distances
=
(
7.
,))),),
ift
.
DomainTuple
.
make
(
ift
.
HPSpace
(
12
),)],
[
ift
.
DomainTuple
.
make
((
ift
.
RGSpace
((
2
,)),
ift
.
GLSpace
(
10
)),),
ift
.
DomainTuple
.
make
(
ift
.
RGSpace
((
10
,
12
),
distances
=
(
0.1
,
1.
)),)]
ift
.
DomainTuple
.
make
(
ift
.
RGSpace
((
10
,
12
),
distances
=
(
0.1
,
1.
)),)]
))
def
testOuter
(
self
,
fdomain
,
domain
):
f
=
ift
.
from_random
(
'normal'
,
fdomain
)
...
...
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