recon_loop#
- ptyrad.reconstruction.recon_loop(model, init, params, optimizer, loss_fn, constraint_fn, indices, batches, output_path, acc=None)[source]#
Executes the iterative optimization loop for ptychographic reconstruction.
This function performs the iterative reconstruction process by optimizing the model parameters over a specified number of iterations. During each iteration, it applies the loss and constraint functions, updates the model, and logs the loss values. Intermediate results are saved at specified intervals, and a summary is plotted.
- Parameters:
model (PtychoAD) – The ptychographic model containing the parameters and variables to be optimized.
init (Initializer) – The initializer object containing the initialized variables needed for reconstruction.
params (dict) – A dictionary containing various parameters for the reconstruction process, including experimental parameters, source parameters, loss parameters, constraint parameters, and reconstruction settings.
optimizer (torch.optim.Optimizer) – The optimizer used to update the model parameters.
loss_fn (CombinedLoss) – The loss function object used to compute the loss during each iteration.
constraint_fn (CombinedConstraint) – The constraint function object applied during each iteration to enforce specific constraints on the model.
indices (numpy.ndarray) – Array of indices for scanning positions.
batches (list of numpy.ndarray) – List of batches where each batch contains indices grouped according to the selected grouping mode.
output_path (str) – The path to the directory where reconstruction results and figures will be saved.
- Returns:
- A list of tuples, where each tuple contains the iteration number, the loss
value for that iteration, and the time taken for that iteration.
- Return type:
list