drugforge.ml.early_stopping.ThresholdEarlyStopping

class drugforge.ml.early_stopping.ThresholdEarlyStopping(threshold, patience, burnin=0)[source]

Bases: object

Class for handling early stopping in training based on whether loss has been below a certain threshold for some number of epochs.

__init__(threshold, patience, burnin=0)[source]
Parameters:
  • threshold (float) – Loss below which to stop model training

  • patience (ing) – Number of epochs to wait once loss has dipped below threshold to make sure it stays there

  • burnin (int, optional) – If given, ensure that at least this many epochs of training have been done before we stop

Methods

__init__(threshold, patience[, burnin])

check(epoch, loss)

Check if training should be stopped.

check(epoch, loss)[source]

Check if training should be stopped. Return True to stop, False to keep going.

Parameters:
  • epoch (int) – Current training epoch

  • loss (float) – Model loss from the current epoch of training

Returns:

Whether to stop training

Return type:

bool