Logger

The logger is nearly a direct copy from rllab, which implemented it as a module. It provides convenient recording of diagnostics to the terminal, which is also saved to debug.log, tabular diagnostics to comma-separated file, progress.csv, and training snapshot files (e.g. agent parameters), params.pkl. The logger is not extensively documented here; its usage is mostly exposed in the examples.

rlpyt.utils.logging.context.logger_context(log_dir, run_ID, name, log_params=None, snapshot_mode='none', override_prefix=False, use_summary_writer=False)

Use as context manager around calls to the runner’s train() method. Sets up the logger directory and filenames. Unless override_prefix is True, this function automatically prepends log_dir with the rlpyt logging directory and the date: path-to-rlpyt/data/yyyymmdd/hhmmss (data/ is in the gitignore), and appends with /run_{run_ID} to separate multiple runs of the same settings. Saves hyperparameters provided in log_params to params.json, along with experiment name and run_ID.

Input snapshot_mode refers to how often the logger actually saves the snapshot (e.g. may include agent parameters). The runner calls on the logger to save the snapshot at every iteration, but the input snapshot_mode sets how often the logger actually saves (e.g. snapshot may include agent parameters). Possible modes include (but check inside the logger itself):

  • “none”: don’t save at all
  • “last”: always save and overwrite the previous
  • “all”: always save and keep each iteration
  • “gap”: save periodically and keep each (will also need to set the gap, not done here)

The cleanup operations after the yield close files but might not be strictly necessary if not launching another training session in the same python process.

rlpyt.utils.logging.context.add_exp_param(param_name, param_val, exp_dir=None, overwrite=False)

Puts a param in all experiments in immediate subdirectories. So you can write a new distinguising param after the fact, perhaps reflecting a combination of settings.

rlpyt.utils.logging.context.check_progress(exp_dir=None)

Print to stdout the number of lines in all progress.csv files in the directory. Call like:

python -c 'from rlpyt.util.logging.context import check_progress; check_progress('path_to_dir')