ncalab.training.earlystopping

Classes

EarlyStopping

Early stopping helper class.

Module Contents

class ncalab.training.earlystopping.EarlyStopping(patience: int, min_delta: float = 1e-06)

Early stopping helper class. Helps to stop the training if no change in validation metrics is observed.

Parameters:
  • patience (int) – Steps to wait until stopping the training.

  • min_delta (float) – Minimum deviation until counter is reset, defaults to 1e-6.

patience
min_delta = 1e-06
best_accuracy = 0.0
counter = 0
done() bool

Checks whether the training can be stopped.

Needs to be queried in training loop, once per epoch.

Returns:

Whether to stop the training or not.

Return type:

bool

step(accuracy: float)

Increases internal counter if accuracy doesn’t improve, otherwise resets the counter.

Needs to be called in training loop, once per epoch.

Parameters:

accuracy (float) – Validation accuracy.