base#


class BaseLogger(train_interval: int = 1000, test_interval: int = 1, update_interval: int = 1000)[source]#

The base class for any logger which is compatible with trainer.

Try to overwrite write() method to use your own writer.

Parameters:
  • train_interval – the log interval in log_train_data(). Default to 1000.

  • test_interval – the log interval in log_test_data(). Default to 1.

  • update_interval – the log interval in log_update_data(). Default to 1000.

log_test_data(collect_result: dict, step: int) None[source]#

Use writer to log statistics generated during evaluating.

Parameters:
  • collect_result – a dict containing information of data collected in evaluating stage, i.e., returns of collector.collect().

  • step – stands for the timestep the collect_result being logged.

log_train_data(collect_result: dict, step: int) None[source]#

Use writer to log statistics generated during training.

Parameters:
  • collect_result – a dict containing information of data collected in training stage, i.e., returns of collector.collect().

  • step – stands for the timestep the collect_result being logged.

log_update_data(update_result: dict, step: int) None[source]#

Use writer to log statistics generated during updating.

Parameters:
  • update_result – a dict containing information of data collected in updating stage, i.e., returns of policy.update().

  • step – stands for the timestep the collect_result being logged.

abstract restore_data() tuple[int, int, int][source]#

Return the metadata from existing log.

If it finds nothing or an error occurs during the recover process, it will return the default parameters.

Returns:

epoch, env_step, gradient_step.

abstract save_data(epoch: int, env_step: int, gradient_step: int, save_checkpoint_fn: collections.abc.Callable[[int, int, int], str] | None = None) None[source]#

Use writer to log metadata when calling save_checkpoint_fn in trainer.

Parameters:
  • epoch – the epoch in trainer.

  • env_step – the env_step in trainer.

  • gradient_step – the gradient_step in trainer.

  • save_checkpoint_fn (function) – a hook defined by user, see trainer documentation for detail.

abstract write(step_type: str, step: int, data: dict[str, int | numbers.Number | numpy.number | numpy.ndarray]) None[source]#

Specify how the writer is used to log data.

Parameters:
  • step_type (str) – namespace which the data dict belongs to.

  • step – stands for the ordinate of the data dict.

  • data – the data to write with format {key: value}.

class LazyLogger[source]#

A logger that does nothing. Used as the placeholder in trainer.

restore_data() tuple[int, int, int][source]#

Return the metadata from existing log.

If it finds nothing or an error occurs during the recover process, it will return the default parameters.

Returns:

epoch, env_step, gradient_step.

save_data(epoch: int, env_step: int, gradient_step: int, save_checkpoint_fn: collections.abc.Callable[[int, int, int], str] | None = None) None[source]#

Use writer to log metadata when calling save_checkpoint_fn in trainer.

Parameters:
  • epoch – the epoch in trainer.

  • env_step – the env_step in trainer.

  • gradient_step – the gradient_step in trainer.

  • save_checkpoint_fn (function) – a hook defined by user, see trainer documentation for detail.

write(step_type: str, step: int, data: dict[str, int | numbers.Number | numpy.number | numpy.ndarray]) None[source]#

The LazyLogger writes nothing.