Stopper

class Stopper(*args, **kwargs)[source]

Bases: ABC

A harness for stopping training.

Initialize the stopper.

Parameters:
  • args – ignored positional parameters

  • kwargs – ignored keyword-based parameters

Methods Summary

get_summary_dict()

Get a summary dict.

load_summary_dict_from_training_loop_checkpoint(path)

Load the summary dict from a training loop checkpoint.

should_evaluate(epoch)

Check if the stopper should be evaluated on the given epoch.

should_stop(epoch)

Validate on validation set and check for termination condition.

Methods Documentation

abstract get_summary_dict() Mapping[str, Any][source]

Get a summary dict.

Return type:

Mapping[str, Any]

static load_summary_dict_from_training_loop_checkpoint(path: str | Path) Mapping[str, Any][source]

Load the summary dict from a training loop checkpoint.

Parameters:

path (str | Path) – Path of the file where to store the state in.

Returns:

The summary dict of the stopper at the time of saving the checkpoint.

Return type:

Mapping[str, Any]

should_evaluate(epoch: int) bool[source]

Check if the stopper should be evaluated on the given epoch.

Parameters:

epoch (int)

Return type:

bool

abstract should_stop(epoch: int) bool[source]

Validate on validation set and check for termination condition.

Parameters:

epoch (int)

Return type:

bool