Skip to content
Snippets Groups Projects

Fixing NaNs in PoissonEnergy

Merged Martin Reinecke requested to merge fixing_nan into NIFTy_5
1 file
+ 6
1
Compare changes
  • Side-by-side
  • Inline
@@ -191,7 +191,12 @@ class PoissonianEnergy(EnergyOperator):
@@ -191,7 +191,12 @@ class PoissonianEnergy(EnergyOperator):
def apply(self, x):
def apply(self, x):
self._check_input(x)
self._check_input(x)
res = x.sum() - x.log().vdot(self._d)
res = x.sum()
 
tmp = res.val.local_data if isinstance(res, Linearization) else res
 
# if we have no infinity here, we can continue with the calculation;
 
# otherwise we know that the result must also be infinity
 
if not np.isinf(tmp):
 
res = res - x.log().vdot(self._d)
if not isinstance(x, Linearization):
if not isinstance(x, Linearization):
return Field.scalar(res)
return Field.scalar(res)
if not x.want_metric:
if not x.want_metric:
Loading