How does wandb.tensorboard.patch works?

Torcione: <p>Hi everyone,<br>
I’m trying to move from tensorboard to wandb that seems more flexible and has some useful additional feature to customize plots.<br>
In my code I defined two <code>Tensorboard</code> <code>SummaryWriter</code>; I’d like to import the plot associated to one of them in wandb.<br>
In other words <strong>I want to include in</strong> <code>wandb</code> <strong>only a part of the</strong> <code>tensorboard</code> <strong>logs of my code</strong>.<br>
Is it possible to do it?<br>
If, for example, I have the 2 summaries stored in 2 different folders <code>a</code> and <code>a/b</code></p>
<pre><code class="lang-auto">Sum1 = SummaryWriter('a')
Sum2 = SummaryWriter('a/b')

</code></pre>
<p>and I’m only interested in import <code>Sum2</code> in <code>wandb</code> .<br>
I thought that</p>
<pre><code class="lang-auto">wandb.tensorboard.patch(root_logdir='a/b', pytorch=True)
</code></pre>
<p>was the way but it doesn’t seem the case.<br>
In fact I get this message:</p>
<pre><code class="lang-auto">e[34me[1mwandbe[0m: e[33mWARNINGe[0m Found logdirectory outside of given root_logdir, dropping given root_logdir for eventfile in a
</code></pre>
<p>I want that paths outside <code> root_logdir</code> to be ignored.<br>
Apart from this <a href="https://docs.wandb.ai/guides/integrations/tensorboard" rel="noopener nofollow ugc">page</a> I did’t found a clear documentation about  <code>wandb.tensorboard.patch</code>.<br>
Any idea about how to proceed?</p>

scottire: <p>Hey,<br>
I work for W&amp;B, happy to try help here.</p>
<p>Judging from that error message, it seems it is trying to sync a directory outside of the root log dir. You may want to make sure the path is correct.</p>
<p>One thing to note, you must call either <code>wandb.init</code> or <code>wandb.tensorboard.patch</code> <strong>before</strong> calling <code>tf.summary.create_file_writer</code> or constructing a<code>SummaryWriter</code> via <code>torch.utils.tensorboard</code> .</p>
<p>Also, from the CLI, you can call <code>wandb sync log_dir</code> to sync your subdirectory. I’ll reach out to the engineering team internally or reproduce it myself and follow up with more information about whether it’s possible to patch a subdirectory as this could be an issue with our CLI.</p>
<p>You may want to post this as an issue on our client GitHub: <a href="https://github.com/wandb/client" class="inline-onebox" rel="noopener nofollow ugc">GitHub - wandb/client: 🔥 A tool for visualizing and tracking your machine learning experiments. This repo contains the CLI and Python API.</a><br>
or ask for help within our forum: <a href="https://community.wandb.ai/" rel="noopener nofollow ugc">https://community.wandb.ai/</a></p>

Torcione: <p>Hi,<br>
Thank you so much for your reply! I’ll report my doubut also on the client Git-Hub.<br>
I’d like to use this occasion to ask you another question:<br>
Let’s say that I have many log calls inside my code (each one register some measures)and I want to associate to each of them a different x-axis sequence for the dashboard chart.<br>
I know that it is possible to do that by adding your customized step’s sequence as an additional measure in the same logs and then manually set it as x-axis on the dashboard.<br>
Anyway I’d like to set the step (x-axis variable) automatically from the log call.<br>
I tried with <code>step</code> argument, but since I want different customized sequences for different logs call this doesn’t work (because step is supposed to be an increasing sequence shared between all the calls) .<br>
<strong>Is there a way to set a different x-axis sequence for different groups of logged measures in a automatic way (instead of doing it manually chart by chart on the dashboard)?</strong></p>

scottire: <p>This is a good question. You can use <code>define_metric</code> to define a custom x-axis.</p>
<pre><code class="lang-auto">import wandb

wandb.init()
# define our custom x axis metric
wandb.define_metric("custom_step")
# define which metrics will be plotted against it
wandb.define_metric("validation_loss", step_metric="custom_step")

for i in range(10):
  log_dict = {
      "train_loss": 1/(i+1),
      "custom_step": i**2,
      "validation_loss": 1/(i+1)   
  }
  wandb.log(log_dict)
</code></pre>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://docs.wandb.ai/guides/track/log#customize-axes-and-summaries-with-define_metric%60">
  <header class="source">
      <img src="https://firebasestorage.googleapis.com/v0/b/gitbook-28427.appspot.com/o/spaces%2F-Lqya5RvLedGEWPhtkjU%2Favatar.png?generation=1570983771045343&amp;alt=media" class="site-icon" width="256" height="256">

      <a href="https://docs.wandb.ai/guides/track/log#customize-axes-and-summaries-with-define_metric%60" target="_blank" rel="noopener nofollow ugc">docs.wandb.ai</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/362;"><img src="https://app.gitbook.com/share/space/thumbnail/-Lqya5RvLedGEWPhtkjU-1972196547.png?color=%234D86F5&amp;logo=&amp;theme=light" class="thumbnail" width="690" height="362"></div>

<h3><a href="https://docs.wandb.ai/guides/track/log#customize-axes-and-summaries-with-define_metric%60" target="_blank" rel="noopener nofollow ugc">Log Data with wandb.log</a></h3>

  <p>Keep track of metrics, videos, custom plots, and more</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>