drugforge.ml.early_stopping.BestEarlyStopping

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

Bases: object

Class for handling early stopping in training based on improvement over best loss.

__init__(patience, burnin=0)[source]
Parameters:
  • patience (int) – The maximum number of epochs to continue training with no improvement in the val loss. If not given, no early stopping will be performed

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

Methods

__init__(patience[, burnin])

check(epoch, loss, wts_dict)

Check if training should be stopped.

check(epoch, loss, wts_dict)[source]

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

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

  • wts_dict (dict) – Weights dict from Pytorch for keeping track of the best model

Returns:

Whether to stop training

Return type:

bool