Shortcuts

EarlyStoppingHook

class mmengine.hooks.EarlyStoppingHook(monitor, rule=None, min_delta=0.1, strict=False, check_finite=True, patience=5, stopping_threshold=None)[source]

Early stop the training when the monitored metric reached a plateau.

Parameters:
  • monitor (str) – The monitored metric key to decide early stopping.

  • rule (str, optional) – Comparison rule. Options are ‘greater’, ‘less’. Defaults to None.

  • min_delta (float, optional) – Minimum difference to continue the training. Defaults to 0.01.

  • strict (bool, optional) – Whether to crash the training when monitor is not found in the metrics. Defaults to False.

  • check_finite (bool) – Whether to stop training when the monitor becomes NaN or infinite. Defaults to True.

  • patience (int, optional) – The times of validation with no improvement after which training will be stopped. Defaults to 5.

  • stopping_threshold (float, optional) – Stop training immediately once the monitored quantity reaches this threshold. Defaults to None.

Note

New in version 0.7.0.

after_val_epoch(runner, metrics)[source]

Decide whether to stop the training process.

Parameters:
  • runner (Runner) – The runner of the training process.

  • metrics (dict) – Evaluation results of all metrics

before_run(runner)[source]

Check stop_training variable in runner.train_loop.

Parameters:

runner (Runner) – The runner of the training process.

Return type:

None