Commit 02f153a5 authored by Philipp Arras's avatar Philipp Arras
Browse files

Merge branch 'new_energies' into 'NIFTy_5'

Add poisson likelihood

See merge request ift/NIFTy!270
parents 178ca953 9b2959f7
Pipeline #31252 passed with stages
in 1 minute and 25 seconds
......@@ -5,5 +5,6 @@ from .nonlinear_wiener_filter_energy import NonlinearWienerFilterEnergy
from .nonlinearities import Exponential, Linear, PositiveTanh, Tanh
from .poisson_energy import PoissonEnergy
from .unit_log_gauss import UnitLogGauss
from .poisson_log_likelihood import PoissonLogLikelihood
from .wiener_filter_curvature import WienerFilterCurvature
from .wiener_filter_energy import WienerFilterEnergy
from numpy import inf, isnan
from ..minimization import Energy
from ..operators import SandwichOperator
from ..sugar import log, makeOp
class PoissonLogLikelihood(Energy):
def __init__(self, position, lamb, d):
s: Sky model object
value = 0.5 * s.vdot(s), i.e. a log-Gauss distribution with unit
super(PoissonLogLikelihood, self).__init__(position)
self._lamb =
self._d = d
lamb_val = self._lamb.value
self._value = lamb_val.sum() - d.vdot(log(lamb_val))
if isnan(self._value):
self._value = inf
self._gradient = self._lamb.gradient.adjoint_times(1 - d/lamb_val)
# metric = makeOp(d/lamb_val/lamb_val)
metric = makeOp(1./lamb_val)
self._curvature = SandwichOperator.make(self._lamb.gradient, metric)
def at(self, position):
return self.__class__(position, self._lamb, self._d)
def value(self):
return self._value
def gradient(self):
return self._gradient
def curvature(self):
return self._curvature
Supports Markdown
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