noether.core.callbacks.early_stoppers

Submodules

Exceptions

EarlyStopIteration

Custom StopIteration exception for Early Stoppers.

Classes

EarlyStopperBase

Base class for early stoppers that is used to define the interface for early stoppers used by the trainers.

FixedEarlyStopper

Early stopper (training) based on a fixed number of epochs, updates, or samples.

MetricEarlyStopper

Early stopper (training) based on a metric value to be monitored.

Package Contents

exception noether.core.callbacks.early_stoppers.EarlyStopIteration

Bases: StopIteration

Custom StopIteration exception for Early Stoppers.

Initialize self. See help(type(self)) for accurate signature.

class noether.core.callbacks.early_stoppers.EarlyStopperBase(callback_config, trainer, model, data_container, tracker, log_writer, checkpoint_writer, metric_property_provider, name=None)

Bases: noether.core.callbacks.periodic.PeriodicCallback

Base class for early stoppers that is used to define the interface for early stoppers used by the trainers.

Parameters:
to_short_interval_string()

Convert the interval to a short string representation used for logging.

Return type:

str

periodic_callback(*, interval_type, update_counter, **kwargs)

Check if training should stop and raise exception if needed.

Parameters:
  • interval_type (noether.core.callbacks.periodic.IntervalType) – Type of interval that triggered this callback.

  • update_counter (noether.core.utils.training.UpdateCounter) – UpdateCounter instance with current training state.

  • **kwargs – Additional keyword arguments.

Raises:

EarlyStopIteration – If training should be stopped based on the stopping criterion.

Return type:

None

class noether.core.callbacks.early_stoppers.FixedEarlyStopper(callback_config, **kwargs)

Bases: noether.core.callbacks.early_stoppers.base.EarlyStopperBase

Early stopper (training) based on a fixed number of epochs, updates, or samples.

Example config:

- kind: noether.core.callbacks.FixedEarlyStopper
  stop_at_epoch: 10
  name: FixedEarlyStopper
Parameters:
stop_at_sample
stop_at_update
stop_at_epoch
class noether.core.callbacks.early_stoppers.MetricEarlyStopper(callback_config, **kwargs)

Bases: noether.core.callbacks.early_stoppers.base.EarlyStopperBase

Early stopper (training) based on a metric value to be monitored.

Example config:

- kind: noether.core.callbacks.MetricEarlyStopper
  every_n_epochs: 1
  metric_key: loss/val/total
  tolerance: 0.10
  name: MetricEarlyStopper
Parameters:
metric_key
higher_is_better
tolerance
tolerance_counter = 0
best_metric