Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nifty_tutorial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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_tutorial
Commits
432752bd
Commit
432752bd
authored
5 years ago
by
Philipp Arras
Browse files
Options
Downloads
Patches
Plain Diff
Add noise inference
parent
28d4befd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#60399
passed
5 years ago
Stage: build_docker
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
2_critical_filter_solution.py
+21
-6
21 additions, 6 deletions
2_critical_filter_solution.py
helpers/plot.py
+1
-1
1 addition, 1 deletion
helpers/plot.py
with
22 additions
and
7 deletions
2_critical_filter_solution.py
+
21
−
6
View file @
432752bd
...
...
@@ -52,15 +52,30 @@ signal_response = R @ signal
N
=
ift
.
ScalingOperator
(
0.1
,
data_space
)
data
,
ground_truth
=
generate_gaussian_data
(
signal_response
,
N
)
# Corrupt data
if
True
:
arr
=
data
.
to_global_data_rw
()
arr
[
1001
]
*=
1000
arr
[
48
]
*=
1000
data
=
ift
.
from_global_data
(
data
.
domain
,
arr
)
plot_prior_samples_2d
(
5
,
signal
,
R
,
signal
,
A
,
'
gauss
'
,
N
=
N
)
likelihood
=
ift
.
GaussianEnergy
(
mean
=
data
,
inverse_covariance
=
N
.
inverse
)(
signal_response
)
residual
=
ift
.
Adder
(
data
,
neg
=
True
)
@
signal_response
# Enable noise inference
if
True
:
scale_q
=
0.5
*
N
.
inverse
N_amp
=
scale_q
@
ift
.
InverseGammaOperator
(
data_space
,
0.5
,
1
)
@
scale_q
sqrtnop
=
N_amp
.
ducktape
(
'
eta
'
)
**-
0.5
residual
=
sqrtnop
*
residual
likelihood
=
ift
.
GaussianEnergy
(
domain
=
data_space
)
@
residual
# Solve inference problem
ic_sampling
=
ift
.
GradientNormController
(
iteration_limit
=
100
)
ic_newton
=
ift
.
GradInfNormController
(
name
=
'
Newton
'
,
tol
=
1e-6
,
iteration_limit
=
30
)
ic_newton
=
ift
.
GradInfNormController
(
name
=
'
Newton
'
,
tol
=
1e-6
,
iteration_limit
=
30
)
minimizer
=
ift
.
NewtonCG
(
ic_newton
)
H
=
ift
.
StandardHamiltonian
(
likelihood
,
ic_sampling
)
...
...
@@ -68,12 +83,12 @@ initial_mean = ift.MultiField.full(H.domain, 0.)
mean
=
initial_mean
# Draw five samples and minimize KL, iterate 10 times
for
_
in
range
(
10
):
for
_
in
range
(
3
):
KL
=
ift
.
MetricGaussianKL
(
mean
,
H
,
5
)
KL
,
convergence
=
minimizer
(
KL
)
mean
=
KL
.
position
# Draw posterior samples and plot
N_posterior_samples
=
3
0
N_posterior_samples
=
1
0
KL
=
ift
.
MetricGaussianKL
(
mean
,
H
,
N_posterior_samples
)
plot_reconstruction_2d
(
data
,
ground_truth
,
KL
,
signal
,
R
,
A
,
'
criticalfilter
'
)
This diff is collapsed.
Click to expand it.
helpers/plot.py
+
1
−
1
View file @
432752bd
...
...
@@ -162,7 +162,7 @@ def plot_reconstruction_2d(data, ground_truth, KL, signal, R, A, name):
sc
=
ift
.
StatCalculator
()
sky_samples
,
pspec_samples
=
[],
[]
for
sample
in
KL
.
samples
:
tmp
=
signal
(
sample
+
KL
.
position
)
tmp
=
signal
.
force
(
sample
+
KL
.
position
)
sc
.
add
(
tmp
)
sky_samples
.
append
(
tmp
)
pspec_samples
.
append
(
A
.
force
(
sample
)
**
2
)
...
...
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