loss_logger

Contents

loss_logger#

ptyrad.reconstruction.loss_logger(batch_losses, niter, iter_t, verbose=True)[source]#

Logs and summarizes the loss values for an iteration during the ptychographic reconstruction.

This function computes the average loss for each loss component across all batches in the current iteration. It then logs the total loss, the individual loss components, and the time taken for the iteration. The function also returns the total loss for the iteration.

Parameters:
  • batch_losses (dict) – A dictionary where each key corresponds to a loss component name, and the value is a list of loss values computed for each batch in the iteration.

  • niter (int) – The current iteration number in the optimization loop.

  • iter_t (float) – The total time taken to complete the iteration, in seconds.

  • verbose (bool, optional) – If True, prints the loss summary to the console. Defaults to True.

Returns:

The total loss for the current iteration, computed as the sum of the average loss values for each component.

Return type:

float