Fix an issue with the test for the poisson NLL function

This commit is contained in:
Abe Levitan committed 2020-12-28 21:45:01 -05:00
1 parent 6b735a431f
commit 32a8a8179d
4 files changed
+12 -10

No files matched your search

+2
View File
@@ -27,6 +27,8 @@ dataset before attempting to do so
from __future__ import division, print_function, absolute_import
# I don't believe that __all__ really needed, but it's nice to define it
# to be explicit that import * is safe
__all__ = ['CDataset','Ptycho2DDataset']
from CDTools.datasets.base import CDataset
-5
View File
@@ -11,11 +11,6 @@ of the following functions:
* to_cxi
* inspect
Example implementations of all these functions can be found in the code
for the Ptycho2DDataset class.
In addition, it is recommended to read through the tutorial section on
defining a new ptychography dataset before attempting to do so
"""
from __future__ import division, print_function, absolute_import
+7 -2
View File
@@ -100,7 +100,7 @@ def intensity_mse(intensities, sim_intensities, mask=None):
def poisson_nll(intensities, sim_intensities, mask=None, eps=1e-4):
def poisson_nll(intensities, sim_intensities, mask=None, eps=1e-6):
""" Returns the Poisson negative log likelihood for a simulated dataset's intensities
Calculates the overall Poisson maximum likelihood metric using
@@ -117,6 +117,9 @@ def poisson_nll(intensities, sim_intensities, mask=None, eps=1e-4):
as long as their shapes match, and the provided mask array can be
broadcast correctly along them.
The default value of eps is 1e-6 - a nonzero value here helps avoid
divergence of the log function near zero.
Parameters
----------
intensities : torch.Tensor
@@ -125,7 +128,9 @@ def poisson_nll(intensities, sim_intensities, mask=None, eps=1e-4):
A tensor of simulated detector intensities
mask : torch.Tensor
A mask with ones for pixels to include and zeros for pixels to exclude
eps : float
Optional, a small number to add to the simulated intensities
Returns
-------
loss : torch.Tensor