Garfield.trainer.EarlyStopping
- class Garfield.trainer.EarlyStopping(early_stopping_metric: str = 'val_global_loss', metric_improvement_threshold: float = 0.0, patience: int = 8, reduce_lr_on_plateau: bool = True, lr_patience: int = 4, lr_factor: float = 0.1)[source]
EarlyStopping class for early stopping of Garfield training. Parts of the implementation are adapted from https://github.com/theislab/scarches/blob/cb54fa0df3255ad1576a977b17e9d77d4907ceb0/scarches/utils/monitor.py#L4 (01.10.2022).
- Parameters:
early_stopping_metric – The metric on which the early stopping criterion is calculated.
metric_improvement_threshold – The minimum value which counts as metric_improvement.
patience – Number of epochs which are allowed to have no metric improvement until the training is stopped.
reduce_lr_on_plateau – If ´True´, the learning rate gets adjusted by ´lr_factor´ after a given number of epochs with no metric improvement.
lr_patience – Number of epochs which are allowed to have no metric improvement until the learning rate is adjusted.
lr_factor – Scaling factor for adjusting the learning rate.
- __init__(early_stopping_metric: str = 'val_global_loss', metric_improvement_threshold: float = 0.0, patience: int = 8, reduce_lr_on_plateau: bool = True, lr_patience: int = 4, lr_factor: float = 0.1)[source]
Methods
__init__([early_stopping_metric, ...])step(current_metric)update_state(current_metric)