EarlyStoppingHandle

class hybrid_learning.concepts.train_eval.base_handles.early_stopping.EarlyStoppingHandle(min_delta=0.001, patience=1, verbose=False)[source]

Bases: object

Handle encapsulating early stopping checks. It measures the progress given the previous steps and determines whether one should proceed or stop early. This value is then stored in require_stop.

Usage: Initialize the handle, then apply after each epoch step() to the loss tensor. step() will update the current best values and returns the new value of require_stop.

Public Data Attributes:

settings

A dict with the settings.

Public Methods:

reset()

Reset the history of the handle to start at step 0.

step(loss)

Update stopping flag according to latest epoch results.

Special Methods:

__init__([min_delta, patience, verbose])

Init.

__repr__()

String representation with all properties.

__str__()

Return str(self).


Parameters
  • min_delta (float) –

  • patience (int) –

  • verbose (bool) –

__init__(min_delta=0.001, patience=1, verbose=False)[source]

Init.

Parameters
  • min_delta (float) – minimum decrease of the loss value such that it is considered progress. If the loss should be increasing, assign corresponding negative min_delta

  • patience (int) – number of steps (epochs) with no progress after which to suggest to stop; values <=0 are mapped to 1 (i.e. no patience, stop if no progress since last step)

  • verbose (bool) – logging verbosity level.

__repr__()[source]

String representation with all properties.

__str__()[source]

Return str(self).

reset()[source]

Reset the history of the handle to start at step 0.

step(loss)[source]

Update stopping flag according to latest epoch results. If stopping is required, set require_stop to True.

Parameters

loss (float) – the loss of the last epoch unseen to the handle

Returns

the new value of require_stop

Return type

bool

min_delta

Minimum decrease (increase if <0) of loss value per step to be considered a progress.

patience

Number of steps with no progress after which to suggest to stop.

require_stop

Whether the early stopping handle would suggest to stop or to proceed. Updated using the step() method.

property settings: Dict[str, Any]

A dict with the settings.

verbose

Verbosity level (simple logging switch).