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
3b24e3c7
Commit
3b24e3c7
authored
Jan 21, 2020
by
Philipp Frank
Browse files
workaround for complex lh sampling
parent
6fa98577
Pipeline
#67471
passed with stages
in 25 minutes and 18 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty6/minimization/metric_gaussian_kl.py
View file @
3b24e3c7
...
...
@@ -14,6 +14,7 @@
# Copyright(C) 2013-2019 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import
numpy
as
np
from
..
import
utilities
from
..linearization
import
Linearization
...
...
@@ -78,7 +79,7 @@ class MetricGaussianKL(Energy):
def
__init__
(
self
,
mean
,
hamiltonian
,
n_samples
,
constants
=
[],
point_estimates
=
[],
mirror_samples
=
False
,
napprox
=
0
,
_samples
=
None
):
napprox
=
0
,
_samples
=
None
,
lh_sampling_dtype
=
np
.
float
):
super
(
MetricGaussianKL
,
self
).
__init__
(
mean
)
if
not
isinstance
(
hamiltonian
,
StandardHamiltonian
):
...
...
@@ -99,7 +100,8 @@ class MetricGaussianKL(Energy):
mean
,
point_estimates
,
True
)).
metric
if
napprox
>
1
:
met
.
_approximation
=
makeOp
(
approximation2endo
(
met
,
napprox
))
_samples
=
tuple
(
met
.
draw_sample
(
from_inverse
=
True
)
_samples
=
tuple
(
met
.
draw_sample
(
from_inverse
=
True
,
dtype
=
lh_sampling_dtype
)
for
_
in
range
(
n_samples
))
if
mirror_samples
:
_samples
+=
tuple
(
-
s
for
s
in
_samples
)
...
...
nifty6/operators/sampling_enabler.py
View file @
3b24e3c7
...
...
@@ -71,7 +71,7 @@ class SamplingEnabler(EndomorphicOperator):
else
:
s
=
self
.
_prior
.
draw_sample
(
from_inverse
=
True
)
sp
=
self
.
_prior
(
s
)
nj
=
self
.
_likelihood
.
draw_sample
()
nj
=
self
.
_likelihood
.
draw_sample
(
dtype
=
dtype
)
energy
=
QuadraticEnergy
(
s
,
self
.
_op
,
sp
+
nj
,
_grad
=
self
.
_likelihood
(
s
)
-
nj
)
inverter
=
ConjugateGradient
(
self
.
_ic
)
...
...
Write
Preview
Markdown
is supported
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