Logging and Plotting¶
garage supports convenient and useful logging. garage uses dowel
for logging. The
logger supports many outputs, including
In garage’s experiment, the
logger will output to all of these.
Here is an example of logging in garage.
from garage import wrap_experiment from dowel import logger, tabular @wrap_experiment def log_experiment(ctxt=None): for i in range(100): # Log str directly logger.log('Logging messages:') # Log scalar values with the key 'AverageReturn' tabular.record('AverageReturn', i) # The Trainer will do these steps for you, if you log things in # the algorithms. logger.log(tabular) logger.dump_all() log_experiment()
Running the example will generate outputs like:
2020-10-21 14:06:04 | [log_experiment] Logging to [CUR_DIR]/data/local/experiment/log_experiment 2020-10-21 14:06:04 | [log_experiment] Logging messages: ------------- - AverageReturn 0 ------------- - 2020-10-21 14:06:04 | [log_experiment] Logging messages: ------------- - AverageReturn 1 ------------- - 2020-10-21 14:06:04 | [log_experiment] Logging messages: ------------- - AverageReturn 2 ------------- -
To look at outputs with TensorBoard, you can refer to this page.
To set a customized log directory, just pass a
log_dir argument to the
In garage, as long as the environment implement the
visualize() method, is
it easy to plot a policy running in the environment when training.
trainer.train(n_epochs=100, batch_size=4000, plot=True)
If you want to pause in every epoch, just set
This page was authored by Ruofu Wang (@yeukfu).