nip.trainers.trainer_base.IterationContext#

class nip.trainers.trainer_base.IterationContext(trainer: Trainer, num_iterations: int)[source]#

Context manager for methods that run for a certain number of iterations.

This context manager should be used in conjunction with the attach_progress_bar decorator. It manages the progress bar and ensures that the correct number of iterations are run.

Parameters:
  • trainer (Trainer) – The trainer instance that the method is called on.

  • num_iterations (int) – The number of iterations that the method should run for.

Methods Summary

__enter__()

__exit__(exc_type, exc_value, traceback)

__init__(trainer, num_iterations)

set_description(description)

Set the description of the progress bar.

step()

Step the progress bar by one iteration.

Methods

__enter__()[source]#
__exit__(exc_type, exc_value, traceback)[source]#
__init__(trainer: Trainer, num_iterations: int)[source]#
set_description(description: str)[source]#

Set the description of the progress bar.

Parameters:

description (str) – The description to set.

step()[source]#

Step the progress bar by one iteration.