Commit 8537dd73 authored by Martin Reinecke's avatar Martin Reinecke

formatting

parent ad3efa7a
...@@ -21,16 +21,19 @@ from .. import utilities ...@@ -21,16 +21,19 @@ from .. import utilities
class MetricGaussianKL(Energy): class MetricGaussianKL(Energy):
"""Provides the sampled Kullback-Leibler divergence between a distribution and a Metric Gaussian. """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 A Metric Gaussian is used to approximate some other distribution.
of the other distribution at the location of its mean to approximate the variance. It is a Gaussian distribution that uses the Fisher Information Metric
In order to infer the mean, the a stochastic estimate of the Kullback-Leibler divergence of the other distribution at the location of its mean to approximate the
is minimized. This estimate is obtained by drawing samples from the Metric Gaussian at the current mean. variance. In order to infer the mean, the a stochastic estimate of the
During minimization these samples are kept constant, updating only the mean. Due to the typically nonlinear Kullback-Leibler divergence is minimized. This estimate is obtained by
structure of the true distribution these samples have to be updated by re-initializing this class at some point. drawing samples from the Metric Gaussian at the current mean.
Here standard parametrization of the true distribution is assumed. 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 Parameters
---------- ----------
...@@ -53,7 +56,8 @@ class MetricGaussianKL(Energy): ...@@ -53,7 +56,8 @@ class MetricGaussianKL(Energy):
Notes 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=[], def __init__(self, mean, hamiltonian, n_sampels, constants=[],
...@@ -106,7 +110,8 @@ class MetricGaussianKL(Energy): ...@@ -106,7 +110,8 @@ class MetricGaussianKL(Energy):
def _get_metric(self): def _get_metric(self):
if self._metric is None: if self._metric is None:
lin = self._lin.with_want_metric() 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 = utilities.my_sum(mymap)
self._metric = self._metric.scale(1./len(self._samples)) self._metric = self._metric.scale(1./len(self._samples))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment