# TensorBoard: Visualizing Models and Actions

## :chart\_with\_upwards\_trend: Built-in TensorBoard

TensorBoard is built-in to SLM Lab. It will record all of the metric variables already logged to the terminal output, as well as the PyTorch model graph, model parameter histogram, and action histograms. All of these are done automatically during checkpointing using a writer in `agent.body`. This allows for richer diagnosis of the network and policy, e.g. by seeing if the distributions shift over the course of learning.

Tensorboard event files are saved to the `log/` folder in the output data. During/after a run, you can launch TensorBoard for diagnosis:

```bash
tensorboard --log_dir=data
```

{% hint style="info" %}
Note that it may take some time for TensorBoard to parse the event files, which can be quite large. You can also speed it up by providing a more specific folder for the command, e.g. `--log_dir=data/a2c_gae_bipedalwalker_2019_10_14_223906/log` so that it does not read from other folders.
{% endhint %}

Then, go to `localhost:6006` on your browser, and you should see the TensorBoard page:

![](https://user-images.githubusercontent.com/8209263/66803221-d9bc0980-eed3-11e9-92b8-0e5cd42a6eab.png)

The histogram tab is useful for revealing the distributions of the actions. In the example above, BipedalWalker has 4 continuous actions, hence there are 4 groups for plots for visualizing the value distributions of these 4 actions across different trials and sessions. Likewise, all the model parameters of an agent is also recorded as value distributions of the parameters of their layers.

In the histograms, the vertical axis (coming out from the page) is the number of frames during checkpoints. As an agent learns over time, we should see the distributions changing in shape and shifting locations.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://slm-lab.gitbook.io/slm-lab/v4.2.0/using-slm-lab/tensorboard-visualizing-models-and-actions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
