Timer#

class braintools.trainer.Timer(duration=None, verbose=True)#

Track training time.

Parameters:
  • duration (Dict[str, float] | None) – Maximum training duration. Keys can be ‘seconds’, ‘minutes’, ‘hours’, ‘days’.

  • verbose (bool) – Whether to print timing information.

Examples

>>> timer = Timer(duration={'hours': 2})  # Stop after 2 hours
>>> trainer = Trainer(callbacks=[timer])
on_fit_end(trainer, module)[source]#

Record end time and print summary.

on_fit_start(trainer, module)[source]#

Record start time.

on_train_epoch_end(trainer, module)[source]#

Record epoch time and check duration limit.

on_train_epoch_start(trainer, module)[source]#

Record epoch start time.

property should_stop: bool#

Whether training should stop due to time limit.

property time_elapsed: float | None#

Time elapsed since training started (seconds).

property time_remaining: float | None#

Estimated time remaining (seconds).