Monitor Your Experiments with TensorBoard¶
TensorBoard is a powerful tool that allows you to monitor and visualize an experiment. This section introduces how to set up TensorBoard logging in garage, and how to view/share your TensorBoard logs.
The TensorBoard package should be installed upon garage’s installation. It can be also manually installed via:
pip install tensorboard
Log to TensorBoard¶
This section introduces how to log TensorBoard output with
logger, and how to
log different types of TensorBoard output.
Find more about how to use
Log Scalar Values to TensorBoard¶
You would need
To prepare your TensorBoard output, import dowel’s
from dowel import tabular
Add scalar values:
tabular.record('Epoch', epoch) tabular.record('# Sample', i_sample) tabular.record('AverageDiscountedReturn', return)
Finally, log your scalar values with
Log Histograms to TensorBoard¶
To log histograms to TensorBoard, you would need to pass
dowel.Histogram is implemented as a typed view of a numpy array.
It will accept input that
from dowel import Histogram, logger, tabular samples = norm.rvs(100) # ndarray of 100 samples of a normal distribution hist = Histogram(samples) tabular.record('Sample', hist) logger.log(tabular)
You can use
Histogram() to log distribution types from
View Your TensorBoard Logs¶
You can view your TensorBoard results via the TensorBoard command line tool:
$ tensorboard --logdir logs
Once you run the command, you will see
$ tensorboard --logdir logs Serving TensorBoard on localhost; to expose to the network, use a proxy or pass --bind_all TensorBoard 2.2.2 at http://localhost:6006/ (Press CTRL+C to quit)
Open your browser and navigate to the link to see a dashboard of your TensorBoard results.
Note that if your
--logdir directory contains multiple TensorBoard logs,
the dashboard will show all of them. This is useful when comparing results from
You can find more TensorBoard dashboard details here.
Change the output directory or x-axis¶
@wrap_experiment sets up TensorBoard output via:
$(pwd)/data/local, and the
To manually output to a different directory, you can
logger in your experiment by:
Add additional x-axes¶
If you’d like to view your logs on more than one x-axis, you can configure dowel
to log to additional x-axes by passing a list of tabular keys to the
additional_x_axes parameter of
logger.add_output(dowel.TensorBoardOutput( log_dir, x_axis='TotalEnvSteps', additional_x_axes=['Itr'], # Logs keys by optimization iteration as well ))
Using this configuration, the key
Loss will appear in TensorBoard under both
TotalEnvSteps as its x-axis, and under the tag
Itr as its x-axis.
This page was authored by Eric Yihan Chen (@AiRuiChen).