Early Termination

Callbacks and event handlers used to terminate training as soon as the running loss becomes lower than the theoretical-smallest.

Tensorflow v2

Tensorflow v2 code to terminate training of a deep learning regressor or classifier when the running loss is much lower than a threshold, typically the theoretical-best.

class kxy.learning.tensorflow_early_termination.TerminateIfOverfittedTF(theoretical_best, loss_key)

Tensorflow callback that terminates training at the end of a batch when the running loss is smaller than the theoretical best, which is strong indication that the model will end up overfitting.

Parameters
  • loss_key (str) – Which loss to base early-termination on. Example values are: 'loss', 'classification_error', and any other registered loss metrics.

  • theoretical_best (float) – The theoretical-smallest loss achievable without overfiting, obtained using df.kxy.data_valuation

on_batch_end(batch, logs=None)

PyTorch

PyTorch code to terminate training of a deep learning regressor or classifier when the running loss is much lower than a threshold, typically the theoretical-best.

class kxy.learning.pytorch_early_termination.TerminateIfOverfittedPT(theoretical_best, loss_key)

PyTorch event handler that terminates training when the running loss is smaller than the theoretical best, which is strong indication that the model will end up overfitting.

Parameters
  • loss_key (str) – Which loss to base early-termination on. Example values are: 'loss', 'classification_error', and any other registered loss metrics.

  • theoretical_best (float) – The theoretical-smallest loss achievable without overfiting, obtained using df.kxy.data_valuation.