Logger

class sorrel.utils.logging.Logger(max_epochs: int, *args: str)

Abstract class for logging.

max_epochs

The number of epochs.

Type:

int

losses

A list of the loss values for each epoch.

Type:

list[float | numpy.ndarray]

rewards

A list of the reward values for each epoch.

Type:

list[float | numpy.ndarray]

epsilons

A list of the epsilon values for each epoch.

Type:

list[float | numpy.ndarray]

additional_values

A dictionary of optional values to be stored.

Type:

Mapping[str, list[int | float | numpy.ndarray]]

Methods

Logger.__init__(max_epochs: int, *args: str)

Initialize a log.

Parameters:
  • max_epochs (int) – The length of the lists.

  • *args – Additional optional values to be stored in a dictionary.

Logger.record_turn(epoch: int, loss: float | ndarray, reward: float | ndarray, epsilon: float = 0, **kwargs) None

Record a turn.

Parameters:
  • epoch (int) – The number of the epoch.

  • loss (float | torch.Tensor) – The loss value.

  • reward (float | torch.Tensor) – The reward value.

  • epsilon (float) – The epsilon value.

  • kwargs – Additional values to store.

Logger.to_csv(file_path: str | PathLike) None

Write the logged data to a CSV file.

Parameters:

file_path – The path to the file to write the data to.

ConsoleLogger

class sorrel.utils.logging.ConsoleLogger(max_epochs: int, *args: str)

Logs elements to the console.

max_epochs

The number of epochs.

Type:

int

losses

A list of the loss values for each epoch.

Type:

list[float | numpy.ndarray]

rewards

A list of the reward values for each epoch.

Type:

list[float | numpy.ndarray]

epsilons

A list of the epsilon values for each epoch.

Type:

list[float | numpy.ndarray]

additional_values

A dictionary of optional values to be stored.

Type:

Mapping[str, list[int | float | numpy.ndarray]]

Methods

ConsoleLogger.record_turn(epoch, loss, reward, epsilon=0, **kwargs)

Record a turn.

Parameters:
  • epoch (int) – The number of the epoch.

  • loss (float | torch.Tensor) – The loss value.

  • reward (float | torch.Tensor) – The reward value.

  • epsilon (float) – The epsilon value.

  • kwargs – Additional values to store.

JupyterLogger

class sorrel.utils.logging.JupyterLogger(max_epochs: int, *args: str)

Logs elements to a Jupyter notebook.

max_epochs

The number of epochs.

Type:

int

losses

A list of the loss values for each epoch.

Type:

list[float | numpy.ndarray]

rewards

A list of the reward values for each epoch.

Type:

list[float | numpy.ndarray]

epsilons

A list of the epsilon values for each epoch.

Type:

list[float | numpy.ndarray]

additional_values

A dictionary of optional values to be stored.

Type:

Mapping[str, list[int | float | numpy.ndarray]]

Methods

JupyterLogger.record_turn(epoch, loss, reward, epsilon=0, **kwargs)

Record a turn.

Parameters:
  • epoch (int) – The number of the epoch.

  • loss (float | torch.Tensor) – The loss value.

  • reward (float | torch.Tensor) – The reward value.

  • epsilon (float) – The epsilon value.

  • kwargs – Additional values to store.

Tensorboard Logger

class sorrel.utils.logging.TensorboardLogger(max_epochs: int, log_dir: str | PathLike, *args)

Logs elements to a Tensorboard file.

max_epochs

The number of epochs.

Type:

int

losses

A list of the loss values for each epoch.

Type:

list[float | numpy.ndarray]

rewards

A list of the reward values for each epoch.

Type:

list[float | numpy.ndarray]

epsilons

A list of the epsilon values for each epoch.

Type:

list[float | numpy.ndarray]

additional_values

A dictionary of optional values to be stored.

Type:

Mapping[str, list[int | float | numpy.ndarray]]

Methods

TensorboardLogger.__init__(max_epochs: int, log_dir: str | PathLike, *args)

Initialize a Tensorboard log.

Parameters:
  • max_epochs (int) – The length of the lists.

  • log_dir (str | PathLike) – Where the

  • *args – Additional optional values to be stored in a dictionary.

TensorboardLogger.record_turn(epoch, loss, reward, epsilon=0, **kwargs)

Record a turn.

Parameters:
  • epoch (int) – The number of the epoch.

  • loss (float | torch.Tensor) – The loss value.

  • reward (float | torch.Tensor) – The reward value.

  • epsilon (float) – The epsilon value.

  • kwargs – Additional values to store.