92

TensorBoard seems to have a feature to display multiple different runs and toggle them.

enter image description here

How can I make multiple runs show up here and how can assign a name to them to differentiate them?

4 Answers 4

158

In addition to TensorBoard scanning subdirectories (so you can pass a directory containing the directories with your runs), you can also pass multiple directories to TensorBoard explicitly and give custom names (example taken from the --help output):

tensorboard --logdir=name1:/path/to/logs/1,name2:/path/to/logs/2

More information can be found at the TensorBoard documentation.

In recent versions of TensorBoard, aliasing this way requires a different argument, however its use is discouraged (quote from current documentation on github - linked above):

Logdir & Logdir_spec (Legacy Mode)

You may also pass a comma separated list of log directories, and TensorBoard will watch each directory. You can also assign names to individual log directories by putting a colon between the name and the path, as in

tensorboard --logdir_spec name1:/path/to/logs/1,name2:/path/to/logs/2

This flag (--logdir_spec) is discouraged and can usually be avoided. TensorBoard walks log directories recursively; for finer-grained control, prefer using a symlink tree. Some features may not work when using --logdir_spec instead of --logdir.

6
  • 5
    note: home directory shortcut (~) is apparently not resolved correctly, use full name
    – Ben Usman
    Jun 25, 2018 at 23:54
  • 1
    that's more of a shell thing than a tensorflow thing - ~ has to be at the start of a "shell word" (for example, following a space outside of quotes). In here, you can use $HOME instead.
    – etarion
    Jun 27, 2018 at 0:20
  • ~ works for me so likely it has been fixed in later tensorflow versions. Mar 18, 2019 at 18:03
  • 8
    For recent TensorBoard versions (I'm using 2.3 at the moment, not sure when the change happened exactly), see @Oren's answer below, --logdir doesn't work anymore.
    – GPhilo
    Aug 24, 2020 at 8:57
  • 2
    Why is --logdir_spec discouraged, specifically? It's very powerful when comparing a new run to some base "current best" run.
    – Daniel
    Feb 12, 2021 at 10:14
91

I found the answer to my own question on github (https://github.com/tensorflow/tensorflow/issues/1548).

You need to put your logs in a subfolder e.g. /logs/run1/ and then run tensorboard on the root folder e.g. /logs/.

3
  • 13
    This should be the answer
    – BigBadMe
    May 5, 2018 at 10:13
  • put your logs in a subfolder e.g. /logs/run1/ - how to do that? manually?
    – liang
    Oct 24, 2021 at 5:17
  • @liang you probably already have this sub-folder if you created a LOG folder when creating the callback, just run the command as stated above in this folder. Sep 30, 2022 at 20:18
34

New version of tensorboard changed logdir to logdir_spec:

tensorboard --logdir_spec=name1:/path/to/logs/1,name2:/path/to/logs/2

But really my real advice it to use wandb instead of tensorboard

3
  • This appears to be wrong, and indeed --logder_spec is discouraged (follow the link to the documentation on github in the accepted answer).
    – drevicko
    Sep 18, 2020 at 2:03
  • 3
    Hi, he is asking specifcally for manually inserting different runs. logdir is for telling tensorboard to search iterativly for all runs. If you want to give a name for each run and constraine the directories, you need to use logdir_spec. I agree that it is written a bit strange.. And maybe it is discouraged, but this is what he asks for...
    – Oren
    Sep 18, 2020 at 15:54
  • 4
    This works for me! Apparently the --logdir no longer works, need logdir_spec instead!
    – yuqli
    May 20, 2021 at 21:03
3

It seems that just declaring it like this is ok:

writer = SummaryWriter(logdir='/runs/you_tag')

Then tensorboard will create a you_tag folder below runs/, in the meantime, the web application will refresh and find you_tag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.