Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Neel Shah
NIFTy
Commits
d6b86d97
Commit
d6b86d97
authored
Jun 09, 2021
by
Philipp Arras
Browse files
Cleanup interface
parent
12df7bd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/library/variational_models.py
View file @
d6b86d97
...
...
@@ -70,8 +70,8 @@ class MeanFieldVI:
else
:
pos
[
'std'
]
=
full
(
Flat
.
target
,
initial_sig
)
pos
=
MultiField
.
from_dict
(
pos
)
self
.
_
op
=
hamiltonian
(
self
.
_generator
)
+
self
.
_entropy
self
.
_KL
=
StochasticEnergyAdapter
.
make
(
pos
,
self
.
_
op
,
[
'latent'
,],
n_samples
,
op
=
hamiltonian
(
self
.
_generator
)
+
self
.
_entropy
self
.
_KL
=
StochasticEnergyAdapter
.
make
(
pos
,
op
,
[
'latent'
,],
n_samples
,
mirror_samples
,
nanisinf
=
nanisinf
,
comm
=
comm
)
self
.
_samdom
=
latent
.
domain
...
...
test/test_kl.py
View file @
d6b86d97
...
...
@@ -127,15 +127,10 @@ def test_ParametricVI(mirror_samples, fc):
true_val
=
[]
for
i
in
range
(
expected_nsamps
):
lat_rnd
=
ift
.
from_random
(
model
.
_op
.
domain
[
'latent'
])
lat_rnd
=
ift
.
from_random
(
model
.
_
KL
.
_
op
.
domain
[
'latent'
])
samp
=
kl
.
position
.
to_dict
()
samp
[
'latent'
]
=
lat_rnd
samp
=
ift
.
MultiField
.
from_dict
(
samp
)
true_val
.
append
(
model
.
_op
(
samp
))
true_val
.
append
(
model
.
_
KL
.
_
op
(
samp
))
true_val
=
sum
(
true_val
)
/
expected_nsamps
assert_allclose
(
true_val
.
val
,
kl
.
value
,
rtol
=
0.1
)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment