Skip to content

Commit

Permalink
added minor losses to total loss array
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-a-cox committed Feb 6, 2024
1 parent 8135aac commit 93bc8c9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions hera_cal/nucal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,7 @@ def _nucal_post_redcal(

# Initialize variables used in calibration loop
losses = []
previous_loss = np.inf

# Start gradient descent
for step in range(major_cycle_maxiter):
Expand Down Expand Up @@ -1239,13 +1240,17 @@ def _nucal_post_redcal(
if minor_step >= 1 and np.abs(minor_cycle_losses[-1] - minor_cycle_losses[-2]) < convergence_criteria:
break

losses += minor_cycle_loss

# Store loss values
losses.append(loss)

# Stop if subsequent losses are within tolerance
if step >= 1 and np.abs(losses[-1] - losses[-2]) < convergence_criteria:
if step >= 1 and np.abs(losses[-1] - previous_loss) < convergence_criteria:
break

previous_loss = loss

# Save the metadata in dictionary
metadata = {"niter": step + 1, "loss_history": np.array(losses)}

Expand Down

0 comments on commit 93bc8c9

Please sign in to comment.