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
e7f235e5
Commit
e7f235e5
authored
Jul 20, 2019
by
Philipp Arras
Browse files
Add possibility to add approximation to Sampling Enabler
parent
3028acad
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty5/operators/sampling_enabler.py
View file @
e7f235e5
...
...
@@ -63,16 +63,20 @@ class SamplingEnabler(EndomorphicOperator):
s
=
self
.
_prior
.
draw_sample
(
from_inverse
=
True
)
sp
=
self
.
_prior
(
s
)
nj
=
self
.
_likelihood
.
draw_sample
()
energy
=
QuadraticEnergy
(
s
,
self
.
_op
,
sp
+
nj
,
_grad
=
self
.
_likelihood
(
s
)
-
nj
)
inverter
=
ConjugateGradient
(
self
.
_ic
)
if
self
.
_approximation
is
not
None
:
energy
=
QuadraticEnergy
(
s
,
self
.
_op
,
sp
+
nj
)
energy
,
convergence
=
inverter
(
energy
,
preconditioner
=
self
.
_approximation
.
inverse
)
else
:
energy
=
QuadraticEnergy
(
s
,
self
.
_op
,
sp
+
nj
,
_grad
=
self
.
_likelihood
(
s
)
-
nj
)
energy
,
convergence
=
inverter
(
energy
)
return
energy
.
position
def
add_approximation
(
self
,
approx
):
self
.
_approximation
=
approx
def
apply
(
self
,
x
,
mode
):
return
self
.
_op
.
apply
(
x
,
mode
)
...
...
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