Logger

class deeplogs.logger.Log(name: str, description: str = '', hyperparams: dict = <factory>, timestep: list[int | float] = <factory>, logs: dict[slice(<class 'str'>, <class 'list'>, None)] = <factory>)

Data class to store and manage logs for a model.

Parameters:
  • name (str) – Name of the model or log entry.

  • description (str, optional) – Description of the log. Default is an empty string.

  • hyperparams (dict, optional) – Dictionary containing hyperparameters for the model. Default is an empty dictionary.

  • timestep (list of int or float, optional) – List to store the timesteps of logged data. Default is an empty list.

  • logs (dict of str to list, optional) – Dictionary to store the logged data with keys as log names and values as lists of corresponding log values. Default is an empty dictionary.

classmethod load(path: PathLike | str)

Load a Log object from a file using pickle.

Parameters:

path (PathLike or str) – The file path from which the Log object will be loaded.

Returns:

The loaded Log object.

Return type:

Log

save(path: PathLike | str) None

Save the Log object to a file using pickle.

Parameters:

path (PathLike or str) – The file path where the Log object will be saved.

scalar_to_dataframe() DataFrame

Convert the scalar log data to a pandas DataFrame for easy analysis and visualization.

Returns:

A pandas DataFrame with log data and timesteps organized in columns and rows, respectively.

Return type:

pd.DataFrame

class deeplogs.logger.Logger(name: str, description: str = '', hyperparams: dict = {}, folder_path: PathLike[str] | str = './dplogs/', save_interval: float = 5.0)

A logging utility to store and manage logs generated during the training or execution of a model.

Parameters:
  • name (str) – Name of the session.

  • description (str, optional) – Description of the session. Default is an empty string.

  • hyperparams (dict, optional) – Dictionary containing hyperparameters of the session. Default is an empty dictionary.

  • folder_path (PathLike or str, optional) – Path to the folder where logs will be saved. Default is ‘./dplogs/’.

  • save_interval (float, optional) – Time interval (in seconds) between automatic saves. Default is 5.0 seconds.

flush() None

Save the logs immediately.

image(timestep: int | float, img: ndarray, tag: str, image_format: str = 'NCHW') None

Log image data at a specific timestep with the provided tag.

Parameters:
  • timestep (int or float) – The timestep associated with the logged image.

  • img (np.ndarray) – The image data to be logged as a NumPy array.

  • tag (str) – A descriptive tag for the logged image.

  • image_format (str, optional) – Format of the image data. Default is “NCHW”.

scalar(timestep: int | float, **logs: dict[slice(<class 'str'>, typing.Any, None)]) None

Log scalar data at a specific timestep.

Parameters:
  • timestep (int or float) – The timestep associated with the logged data.

  • (dict[str (**logs) – Any]): Keyword arguments representing the logged data with log names as keys and corresponding scalar values as values.

Bar

class deeplogs.bar.Bar(logger: Logger | None = None, description: str = '', running_mean_size: int = 1, bar_size: int = 10, empty_char: str = ' ', fill_char: str = '█', print_interval: float = 0.2)[source]

A progress bar that optionally displays the logs of a model.

Parameters:
  • logger (Logger, optional) – An instance of the Logger class to log in the Bar. Default is None.

  • description (str, optional) – Description to be displayed before the progress bar. Default is an empty string.

  • running_mean_size (int, optional) – The number of most recent iterations on which the moving average is based. The default value is 1.

  • bar_size (int, optional) – Total size of the progress bar. Default is 10.

  • empty_char (str, optional) – Character to represent empty space in the progress bar. Default is a single space ‘ ‘.

  • fill_char (str, optional) – Character to represent filled space in the progress bar. Default is the Unicode block character u”█”.

  • print_interval (float, optional) – Time interval (in seconds) between progress bar updates. Default is 0.2 seconds.

__call__(iterator: Iterable | Generator, iterator_length: int | None = None) Generator[int, float, str][source]

Create a generator for iterating over an iterable while displaying a progress bar while logging the progress of a model.

Parameters:
  • iterator (Iterable) – The iterable to be iterated over.

  • iterator_length (int) – The number of elements in the iterable. Required if iterator does not have a defined length.

Yields:

Generator[int, float, str] – A generator that yields elements from the original iterator.

Reader

class deeplogs.reader.Reader(log_names: list[str] = [], log_folder_path: PathLike | str = './dplogs/')

A utility to read and analyze logs generated during the training or execution of multiple models.

Parameters:
  • log_names (list of str, optional) – List of session names to load. Default is all sessions.

  • log_folder_path (PathLike or str, optional) – Path to the folder where logs are saved. Default is ‘./dplogs/’.

describe(name: list[str] = [], percentiles: list[float] = [0.25, 0.5, 0.75, 0.9]) DataFrame

Generate descriptive statistics of the scalar logs.

Parameters:
  • name (list of str, optional) – List of session names for which statistics will be generated. Default is all.

  • percentiles (list of float, optional) – List of percentiles to include in the statistics. Default is [0.25, 0.5, 0.75, 0.9].

Returns:

A DataFrame containing descriptive statistics.

Return type:

pd.DataFrame

infos(name: list[str] = []) DataFrame

Generate a summary of sessions information.

Parameters:

name (list of str, optional) – List of session names for which information will be generated. Default is all.

Returns:

A DataFrame containing the informations.

Return type:

pd.DataFrame

scalar(logs: list[str] = [], using: Literal['plotly', 'matplotlib'] = 'plotly', ncols: int = 2, figsize: tuple[int, int] = (20, 10), xlabel: str = 'timestep', smooth_perc: float = 0.99) None

Plot scalar logs over timesteps using different visualization libraries.

Parameters:
  • logs (list of str, optional) – List of scalar log names to plot. Default is all.

  • using (Literal["plotly", "matplotlib"], optional) – Visualization library to use for plotting. Default is “plotly”.

  • ncols (int, optional) – Number of columns in the plot grid. Default is 2.

  • figsize (tuple of int, optional) – Figure size (width, height) for the plot. Default is (20, 10).

  • xlabel (str, optional) – Label for the x-axis in the plot. Default is “timestep”.

  • smooth_perc (float, optional) – Percentage of smoothing for the plot. Default is 0.99.