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
8537dd73
Commit
8537dd73
authored
Jan 18, 2019
by
Martin Reinecke
Browse files
formatting
parent
ad3efa7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty5/minimization/metric_gaussian_kl.py
View file @
8537dd73
...
...
@@ -21,16 +21,19 @@ from .. import utilities
class
MetricGaussianKL
(
Energy
):
"""Provides the sampled Kullback-Leibler divergence between a distribution and a Metric Gaussian.
A Metric Gaussian is used to approximate some other distribution.
It is a Gaussian distribution that uses the Fisher Information Metric
of the other distribution at the location of its mean to approximate the variance.
In order to infer the mean, the a stochastic estimate of the Kullback-Leibler divergence
is minimized. This estimate is obtained by drawing samples from the Metric Gaussian at the current mean.
During minimization these samples are kept constant, updating only the mean. Due to the typically nonlinear
structure of the true distribution these samples have to be updated by re-initializing this class at some point.
Here standard parametrization of the true distribution is assumed.
"""Provides the sampled Kullback-Leibler divergence between a distribution
and a Metric Gaussian.
A Metric Gaussian is used to approximate some other distribution.
It is a Gaussian distribution that uses the Fisher Information Metric
of the other distribution at the location of its mean to approximate the
variance. In order to infer the mean, the a stochastic estimate of the
Kullback-Leibler divergence is minimized. This estimate is obtained by
drawing samples from the Metric Gaussian at the current mean.
During minimization these samples are kept constant, updating only the
mean. Due to the typically nonlinear structure of the true distribution
these samples have to be updated by re-initializing this class at some
point. Here standard parametrization of the true distribution is assumed.
Parameters
----------
...
...
@@ -53,7 +56,8 @@ class MetricGaussianKL(Energy):
Notes
-----
For further details see: Metric Gaussian Variational Inference (in preparation)
For further details see: Metric Gaussian Variational Inference
(in preparation)
"""
def
__init__
(
self
,
mean
,
hamiltonian
,
n_sampels
,
constants
=
[],
...
...
@@ -106,7 +110,8 @@ class MetricGaussianKL(Energy):
def
_get_metric
(
self
):
if
self
.
_metric
is
None
:
lin
=
self
.
_lin
.
with_want_metric
()
mymap
=
map
(
lambda
v
:
self
.
_hamiltonian
(
lin
+
v
).
metric
,
self
.
_samples
)
mymap
=
map
(
lambda
v
:
self
.
_hamiltonian
(
lin
+
v
).
metric
,
self
.
_samples
)
self
.
_metric
=
utilities
.
my_sum
(
mymap
)
self
.
_metric
=
self
.
_metric
.
scale
(
1.
/
len
(
self
.
_samples
))
...
...
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