commonpower.control.logging_utils.callbacks.MARLWandBCallback

class MARLWandBCallback(verbose: int = 0, model_save_path: str | None = None, model_save_freq: int = 0, log: Literal['gradients', 'parameters', 'all'] | None = 'all')[source]

Bases: MARLBaseCallback

Callback for logging experiments to Weights and Biases.

Log MAPPO experiments to Weights and Biases
  • Added model tracking and uploading

  • Added complete hyperparameters recording

  • Note that wandb.init(…) must be called before the WandbCallback can be used.

Parameters:
  • verbose (int) – The verbosity of output

  • model_save_path (Optional[str]) – Path to the folder where the model will be saved, The default value is None so the model is not logged

  • model_save_freq (int) – Frequency to save the model

  • log (Optional[Literal["gradients", "parameters", "all"]]) – What to log. One of “gradients”, “parameters”, or “all”.

Methods

init_callback

Initialize the callback by saving references to the RL runner and the training environment for convenience.

on_rollout_end

Any operations the callback has to perform at the end of one training episode

on_rollout_start

on_step

This method will be called by the runner after each call to env.step().

on_training_end

Any operations the callback has to perform after the training is finished

on_training_start

Any operations the callback has to perform before the training starts

save_model

Call the runner to save the actor and critic parameters of each agent

update_child_locals

Update the references to the local variables on sub callbacks.

update_locals

Update the references to the local variables.

update_num_timesteps

Attributes

runner

logger

_on_step() bool[source]

Internal operation that should be performed in each step. Here we want to save the model from time to time.

Returns:

(bool) – If the callback returns False, training is aborted early.

_on_training_end() None[source]

We want to save the model at the end of the training.

Returns:

None

save_model() None[source]

Call the runner to save the actor and critic parameters of each agent

Returns:

None