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
38c6bd82
There was a problem fetching the pipeline summary.
Commit
38c6bd82
authored
7 years ago
by
Martin Reinecke
Browse files
Options
Downloads
Patches
Plain Diff
improve demo; variance sampling still disabled
parent
911a5f88
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
demos/wiener_filter_via_hamiltonian.py
+19
-14
19 additions, 14 deletions
demos/wiener_filter_via_hamiltonian.py
with
19 additions
and
14 deletions
demos/wiener_filter_via_hamiltonian.py
+
19
−
14
View file @
38c6bd82
...
...
@@ -55,9 +55,10 @@ if __name__ == "__main__":
ss
=
fft
.
adjoint_times
(
sh
)
# Choosing the measurement instrument
# Instrument = SmoothingOperator(s_space, sigma=0.05)
Instrument
=
ift
.
DiagonalOperator
(
ift
.
Field
.
ones
(
s_space
))
# Instrument._diagonal.val[200:400, 200:400] = 0
#Instrument = ift.FFTSmoothingOperator(s_space, sigma=0.05)
diag
=
ift
.
Field
.
ones
(
s_space
)
#diag.val[20:80, 20:80] = 0
Instrument
=
ift
.
DiagonalOperator
(
diag
.
weight
(
-
1
))
# Adding a harmonic transformation to the instrument
R
=
AdjointFFTResponse
(
fft
,
Instrument
)
...
...
@@ -77,6 +78,8 @@ if __name__ == "__main__":
ctrl
=
ift
.
GradientNormController
(
verbose
=
True
,
tol_abs_gradnorm
=
0.1
)
inverter
=
ift
.
ConjugateGradient
(
controller
=
ctrl
)
controller
=
ift
.
GradientNormController
(
verbose
=
True
,
tol_abs_gradnorm
=
0.1
)
minimizer
=
ift
.
RelaxedNewton
(
controller
=
controller
)
# Setting starting position
m0
=
ift
.
Field
.
zeros
(
h_space
)
...
...
@@ -85,16 +88,18 @@ if __name__ == "__main__":
inverter
=
inverter
)
D0
=
energy
.
curvature
# Solving the problem analytically
m0
=
D0
.
inverse_times
(
j
)
sample_variance
=
ift
.
Field
.
zeros
(
sh
.
domain
)
sample_mean
=
ift
.
Field
.
zeros
(
sh
.
domain
)
m
=
minimizer
(
energy
)[
0
].
position
ift
.
plotting
.
plot
(
ss
,
name
=
"
signal.pdf
"
,
colormap
=
"
Planck-like
"
)
ift
.
plotting
.
plot
(
fft
.
inverse_times
(
m
),
name
=
"
m.pdf
"
,
colormap
=
"
Planck-like
"
)
# sampling the uncertainty map
n_samples
=
50
for
i
in
range
(
n_samples
):
sample
=
fft
(
ift
.
sugar
.
generate_posterior_sample
(
0.
,
D0
))
sample_variance
+=
sample
**
2
sample_mean
+=
sample
variance
=
(
sample_variance
-
sample_mean
**
2
)
/
n_samples
#sample_variance = ift.Field.zeros(sh.domain)
#sample_mean = ift.Field.zeros(sh.domain)
#n_samples = 50
#for i in range(n_samples):
# sample = ift.sugar.generate_posterior_sample(0., D0)
# sample_variance += sample**2
# sample_mean += sample
#variance = sample_variance/n_samples - (sample_mean/n_samples)**2
#ift.plotting.plot(fft.inverse_times(variance), name="variance.pdf", colormap="Planck-like")
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