Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/ptychi/api/options/lsqml.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ class LSQMLReconstructorOptions(base.ReconstructorOptions):
The standard deviation of the gaussian noise. Only used when `noise_model == enums.NoiseModels.GAUSSIAN`.
"""

solve_obj_prb_step_size_jointly_for_first_slice_in_multislice: bool = False
single_slice_solve_obj_prb_step_size_jointly: bool = True
"""
Whether to solve the simultaneous object/probe step length calculation;
in FoldSlice they use independent (non-joint) step length calculation, but
we're adding the option of using simultaneous AND non-simultaneous step
length calculation.
Whether to solve the object/probe step size jointly for single-slice objects.
For multislice objects, use `multislice_solve_obj_prb_step_size_jointly` instead.
"""

multislice_solve_obj_prb_step_size_jointly: bool = False
"""
Whether to solve the object/probe step size jointly for multislice objects at the first slice.
Slices other than the first are always solved independently. For single-slice objects, use
`single_slice_solve_obj_prb_step_size_jointly` instead.
"""

solve_step_sizes_only_using_first_probe_mode: bool = True
Expand Down
13 changes: 9 additions & 4 deletions src/ptychi/reconstructors/lsqml.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,15 @@ def calculate_optimal_step_sizes(
The slice index of the object.
"""
object_ = self.parameter_group.object
if (not object_.is_multislice) or (
object_.is_multislice
and slice_index == 0
and self.options.solve_obj_prb_step_size_jointly_for_first_slice_in_multislice
if (
(
not object_.is_multislice
and self.options.single_slice_solve_obj_prb_step_size_jointly
) or (
object_.is_multislice
and self.options.multislice_solve_obj_prb_step_size_jointly
and slice_index == 0
)
):
(alpha_o_i, alpha_p_i) = self.calculate_object_and_probe_update_step_sizes(
chi,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_multislice_ptycho_lsqml_joint_step_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_multislice_ptycho_lsqml_joint_step_size(self):
options.reconstructor_options.batch_size = 96
options.reconstructor_options.noise_model = api.NoiseModels.GAUSSIAN
options.reconstructor_options.num_epochs = 8
options.reconstructor_options.solve_obj_prb_step_size_jointly_for_first_slice_in_multislice = True
options.reconstructor_options.multislice_solve_obj_prb_step_size_jointly = True
options.reconstructor_options.allow_nondeterministic_algorithms = False

task = PtychographyTask(options)
Expand Down
Loading