noether.core.callbacks.early_stoppers¶
Submodules¶
Exceptions¶
Custom StopIteration exception for Early Stoppers. |
Classes¶
Base class for early stoppers that is used to define the interface for early stoppers used by the trainers. |
|
Early stopper (training) based on a fixed number of epochs, updates, or samples. |
|
Early stopper (training) based on a metric value to be monitored. |
Package Contents¶
- exception noether.core.callbacks.early_stoppers.EarlyStopIteration¶
Bases:
StopIterationCustom 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.PeriodicCallbackBase class for early stoppers that is used to define the interface for early stoppers used by the trainers.
- Parameters:
callback_config (noether.core.schemas.callbacks.CallBackBaseConfig) – Configuration for the callback. See
CallBackBaseConfigfor available options.trainer (noether.training.trainers.BaseTrainer) – Trainer of the current run.
model (noether.core.models.ModelBase) – Model of the current run.
data_container (noether.data.container.DataContainer) –
DataContainerinstance that provides access to all datasets.tracker (noether.core.trackers.BaseTracker) –
BaseTrackerinstance to log metrics to stdout/disk/online platform.log_writer (noether.core.writers.LogWriter) –
LogWriterinstance to log metrics.checkpoint_writer (noether.core.writers.CheckpointWriter) –
CheckpointWriterinstance to save checkpoints.metric_property_provider (noether.core.providers.MetricPropertyProvider) –
MetricPropertyProviderinstance to access properties of metrics.name (str | None) – Name of the callback.
- to_short_interval_string()¶
Convert the interval to a short string representation used for logging.
- Return type:
- 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) –
UpdateCounterinstance 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.EarlyStopperBaseEarly 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:
callback_config (noether.core.schemas.callbacks.FixedEarlyStopperConfig) – The configuration for the callback. See
FixedEarlyStopperConfigfor available options.**kwargs – Additional arguments to pass to the parent class.
- 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.EarlyStopperBaseEarly 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:
callback_config (noether.core.schemas.callbacks.MetricEarlyStopperConfig) – Configuration for the callback. See
MetricEarlyStopperConfigfor available options including metric key and tolerance.**kwargs – Additional arguments to pass to the parent class.
- metric_key¶
- higher_is_better¶
- tolerance¶
- tolerance_counter = 0¶
- best_metric¶