Logger

class neuralhydrology.training.logger.Logger(cfg: Config)

Bases: object

Class that logs runs to tensorboard and saves plots to disk.

Parameters:

cfg (Config) – The run configuration.

log_figures(figures: List[matplotlib.figure.Figure], freq: str, preamble: str = '')

Log matplotlib figures as to disk.

Parameters:
  • figures (List[mpl.figure.Figure]) – List of figures to save.

  • freq (str) – Prediction frequency of the figures.

  • preamble (str, optional) – Prefix to prepend to the figures’ file names.

log_step(**kwargs)

Log the results of a single step within an epoch.

Parameters:

**kwargs – Key-value pairs of metric names and values.

start_tb()

Start tensorboard logging.

stop_tb()

Stop tensorboard logging.

summarise() float | Dict[str, float]

“Log the results of the entire training or validation epoch.

Returns:

Average loss if training is summarized, else a dict mapping metric names to median metric values.

Return type:

Union[float, Dict[str, float]]

property tag
train() Logger

Set logging to training period.

Returns:

The Logger instance, set to training mode.

Return type:

Logger

valid() Logger

Set logging to validation period.

Returns:

The Logger instance, set to validation mode.

Return type:

Logger