Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ift
NIFTy
Commits
a6e1e5e2
Commit
a6e1e5e2
authored
6 years ago
by
Martin Reinecke
Browse files
Options
Downloads
Patches
Plain Diff
tweaks
parent
012f4643
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
demos/bernoulli_demo.py
+5
-10
5 additions, 10 deletions
demos/bernoulli_demo.py
test/test_models/test_model_gradients.py
+1
-1
1 addition, 1 deletion
test/test_models/test_model_gradients.py
with
6 additions
and
11 deletions
demos/bernoulli_demo.py
+
5
−
10
View file @
a6e1e5e2
...
@@ -47,25 +47,20 @@ if __name__ == '__main__':
...
@@ -47,25 +47,20 @@ if __name__ == '__main__':
def
sqrtpspec
(
k
):
def
sqrtpspec
(
k
):
return
1.
/
(
20.
+
k
**
2
)
return
1.
/
(
20.
+
k
**
2
)
p_space
=
ift
.
PowerSpace
(
harmonic_space
)
A
=
ift
.
create_power_operator
(
harmonic_space
,
sqrtpspec
)
pd
=
ift
.
PowerDistributor
(
harmonic_space
,
p_space
)
a
=
ift
.
PS_field
(
p_space
,
sqrtpspec
)
A
=
pd
(
a
)
# Set up a sky model
# Set up a sky model
sky
=
HT
(
ift
.
makeOp
(
A
)).
positive_tanh
()
sky
=
ift
.
positive_tanh
(
HT
(
A
)
)
GR
=
ift
.
GeometryRemover
(
position_space
)
GR
=
ift
.
GeometryRemover
(
position_space
)
# Set up instrumental response
# Set up instrumental response
R
=
GR
R
=
GR
# Generate mock data
# Generate mock data
d_space
=
R
.
target
[
0
]
p
=
R
(
sky
)
p
=
R
(
sky
)
mock_position
=
ift
.
from_random
(
'
normal
'
,
harmonic_space
)
mock_position
=
ift
.
from_random
(
'
normal
'
,
harmonic_space
)
pp
=
p
(
mock_position
)
data
=
np
.
random
.
binomial
(
1
,
p
(
mock_position
).
local_data
.
astype
(
np
.
float64
))
data
=
np
.
random
.
binomial
(
1
,
pp
.
to_global_data
().
astype
(
np
.
float64
))
data
=
ift
.
Field
.
from_local_data
(
R
.
target
,
data
)
data
=
ift
.
Field
.
from_global_data
(
d_space
,
data
)
# Compute likelihood and Hamiltonian
# Compute likelihood and Hamiltonian
position
=
ift
.
from_random
(
'
normal
'
,
harmonic_space
)
position
=
ift
.
from_random
(
'
normal
'
,
harmonic_space
)
...
@@ -79,7 +74,7 @@ if __name__ == '__main__':
...
@@ -79,7 +74,7 @@ if __name__ == '__main__':
# Minimize the Hamiltonian
# Minimize the Hamiltonian
H
=
ift
.
Hamiltonian
(
likelihood
,
ic_sampling
)
H
=
ift
.
Hamiltonian
(
likelihood
,
ic_sampling
)
H
=
ift
.
EnergyAdapter
(
position
,
H
,
ic_cg
)
H
=
ift
.
EnergyAdapter
(
position
,
H
,
ic_cg
)
# minimizer = ift.
SteepestDescent
(ic_newton)
# minimizer = ift.
L_BFGS
(ic_newton)
H
,
convergence
=
minimizer
(
H
)
H
,
convergence
=
minimizer
(
H
)
reconstruction
=
sky
(
H
.
position
)
reconstruction
=
sky
(
H
.
position
)
...
...
This diff is collapsed.
Click to expand it.
test/test_models/test_model_gradients.py
+
1
−
1
View file @
a6e1e5e2
...
@@ -69,7 +69,7 @@ class Model_Tests(unittest.TestCase):
...
@@ -69,7 +69,7 @@ class Model_Tests(unittest.TestCase):
pos
=
ift
.
from_random
(
"
normal
"
,
dom
)
pos
=
ift
.
from_random
(
"
normal
"
,
dom
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
)
model
=
ift
.
FieldAdapter
(
dom
,
"
s1
"
).
scale
(
3.
)
model
=
ift
.
FieldAdapter
(
dom
,
"
s1
"
).
scale
(
3.
)
pos
=
ift
.
from_random
(
"
normal
"
,
dom
)
pos
=
ift
.
from_random
(
"
normal
"
,
dom
1
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
)
ift
.
extra
.
check_value_gradient_consistency
(
model
,
pos
)
model
=
ift
.
ScalingOperator
(
2.456
,
space
)(
model
=
ift
.
ScalingOperator
(
2.456
,
space
)(
ift
.
FieldAdapter
(
dom
,
"
s1
"
)
*
ift
.
FieldAdapter
(
dom
,
"
s2
"
))
ift
.
FieldAdapter
(
dom
,
"
s1
"
)
*
ift
.
FieldAdapter
(
dom
,
"
s2
"
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment