Update the amplitude MSE and intensity MSE loss to act equivalently - currently, the intensity MSE loss was by default a mean, but amplitude was by default a sum. Both functions now have a flag, use_sum=False, which is False by default. This changes the default behavior of amplitude_mse. All models, including the tutorial version of simple_ptycho, are updated accordingly and test coverage was added.

This commit is contained in:
allevitan committed 2026-04-13 14:34:23 +02:00
1 parent 3c15b19ba7
commit d8fade9f32
11 files changed
+102 -39

No files matched your search

+2 -1
View File
@@ -1,3 +1,4 @@
from functools import partial
import torch as t
from cdtools.models import CDIModel
from cdtools import tools
@@ -42,7 +43,7 @@ class SimplePtycho(CDIModel):
self.obj = t.nn.Parameter(obj_guess)
# We register a loss function and an appropriate normalization
self.loss = tools.losses.amplitude_mse
self.loss = partial(tools.losses.amplitude_mse, use_sum=True)
self.loss_normalizer = tools.losses.AmplitudeMSENormalizer()