Stopper

Contents

Stopper#

class liesel.goose.Stopper(max_iter, patience, atol=0.001, rtol=1e-12)[source]#

Bases: object

Handles (early) stopping for optim_flat().

Parameters:
  • max_iter (int) – The maximum number of optimization steps.

  • patience (int) – Early stopping happens only, if there was no improvement for the number of patience iterations.

  • atol (float) – The absolute tolerance for early stopping. If the change in the negative log probability (compared to the best value observed within the patience period) is smaller than this value, optimization stops early. (default: 0.001)

  • rtol (float) – The relative tolerance for early stopping. If the relative absolute change in the negative log probability is smaller than this value, the optimization stops. (default: 1e-12)

Methods

continue_(i, loss_history)

Whether optimization should continue (inverse of stop_now()).

stop_early(i, loss_history)

Includes loss at iterations before i, but excluding i itself.

stop_now(i, loss_history)

Whether optimization should stop now.

which_best_in_recent_history(i, loss_history)

Identifies the index of the best observation in recent history.

Attributes

atol

rtol

max_iter

patience