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
9b2959f7
Commit
9b2959f7
authored
Jun 18, 2018
by
Philipp Arras
Browse files
Add poisson likelihood
parent
178ca953
Pipeline
#31247
passed with stages
in 1 minute and 27 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty4/library/__init__.py
View file @
9b2959f7
...
...
@@ -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
nifty4/library/poisson_log_likelihood.py
0 → 100644
View file @
9b2959f7
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
covariance
"""
super
(
PoissonLogLikelihood
,
self
).
__init__
(
position
)
self
.
_lamb
=
lamb
.
at
(
position
)
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
)
@
property
def
value
(
self
):
return
self
.
_value
@
property
def
gradient
(
self
):
return
self
.
_gradient
@
property
def
curvature
(
self
):
return
self
.
_curvature
Write
Preview
Markdown
is supported
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