Commit d16f65da authored by Martin Reinecke's avatar Martin Reinecke

re-organize

parent cafc8423
......@@ -47,6 +47,11 @@ from .operators.smoothness_operator import SmoothnessOperator
from .operators.symmetrizing_operator import SymmetrizingOperator
from .operators.vdot_operator import VdotOperator
from .operators.block_diagonal_operator import BlockDiagonalOperator
from .operators.kl import SampledKullbachLeiblerDivergence
from .operators.hamiltonian import Hamiltonian
from .operators.gaussian_energy import GaussianEnergy
from .operators.poissonian_energy import PoissonianEnergy
from .operators.bernoulli_energy import BernoulliEnergy
from .probing.utils import probe_with_posterior_samples, probe_diagonal, \
StatCalculator
......@@ -68,19 +73,17 @@ from .minimization.scipy_minimizer import (ScipyMinimizer, NewtonCG, L_BFGS_B,
from .minimization.energy import Energy
from .minimization.quadratic_energy import QuadraticEnergy
from .minimization.line_energy import LineEnergy
from .minimization.energy_adapter import EnergyAdapter
from .sugar import *
from .plotting.plot import plot, plot_finish
from .library.amplitude_model import AmplitudeModel
from .library.gaussian_energy import GaussianEnergy
from .library.los_response import LOSResponse
# from .library.point_sources import PointSources
from .library.poissonian_energy import PoissonianEnergy
from .library.wiener_filter_curvature import WienerFilterCurvature
from .library.correlated_fields import CorrelatedField
# make_mf_correlated_field)
from .library.bernoulli_energy import BernoulliEnergy
from . import extra
......@@ -88,10 +91,6 @@ from .utilities import memo, frozendict
from .logger import logger
from .energies.kl import SampledKullbachLeiblerDivergence
from .energies.hamiltonian import Hamiltonian
from .energies.energy_adapter import EnergyAdapter
from .linearization import Linearization
# We deliberately don't set __all__ here, because we don't want people to do a
......
......@@ -19,13 +19,13 @@
from __future__ import absolute_import, division, print_function
from ..compat import *
from ..operators.operator import Operator
from ..library.gaussian_energy import GaussianEnergy
from ..operators.sampling_enabler import SamplingEnabler
from .operator import EnergyOperator
from .gaussian_energy import GaussianEnergy
from .sampling_enabler import SamplingEnabler
from ..linearization import Linearization
class Hamiltonian(Operator):
class Hamiltonian(EnergyOperator):
def __init__(self, lh, ic_samp=None):
super(Hamiltonian, self).__init__()
self._lh = lh
......@@ -36,10 +36,6 @@ class Hamiltonian(Operator):
def domain(self):
return self._lh.domain
@property
def target(self):
return DomainTuple.scalar_domain()
def apply(self, x):
if self._ic_samp is None or not isinstance(x, Linearization):
return self._lh(x) + self._prior(x)
......
......@@ -19,11 +19,11 @@
from __future__ import absolute_import, division, print_function
from ..compat import *
from ..operators.operator import Operator
from .operator import EnergyOperator
from ..utilities import my_sum
class SampledKullbachLeiblerDivergence(Operator):
class SampledKullbachLeiblerDivergence(EnergyOperator):
def __init__(self, h, res_samples):
"""
# MR FIXME: does h have to be a Hamiltonian? Couldn't it be any energy?
......@@ -38,10 +38,6 @@ class SampledKullbachLeiblerDivergence(Operator):
def domain(self):
return self._h.domain
@property
def target(self):
return DomainTuple.scalar_domain()
def apply(self, x):
return (my_sum(map(lambda v: self._h(x+v), self._res_samples)) *
(1./len(self._res_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