question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SummaryWriter.add_scalar() number format and Transforms.TensorboardX

See original GitHub issue

1st Question : How can I control the number format of scalars in TensorboardX board in a graph?

Let’s

# proper imports writer = SummaryWriter() x = 5.123456789 epoch = 3

If I write, writer.add_scalar( 'Raw integer scalar', x, epoch) everything works fine, but the output format in TensorboardX it varies.

If I write, writer.add_scalar( 'Formatted raw integer scalar', '{:0.2%}'.format(x), epoch) I get this kind of error

there is no workspace variable

from line 404, file tensorboardX/writer.py

if self._check_caffe2_blob(scalar_value): scalar_value = workspace.FetchBlob(scalar_value)

and there is a check for a Caffe variable although I am using PyTorch.

2nd Question : How can I use TensorboardX from Transforms module, what are the dependencies and their minimum versions?

Thanks, Vassilis

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
mgoldeycommented, Jun 9, 2020

This error is indeed triggered whenever a string is passed in as the second value of add_scalar. That’s because add_scalar expects scalars. That’s a perfectly natural assumption for tensorboardX to make. It would be better to throw a different error in this situation, but both my fundamental problem and the OP’s problem are not tensorboardX’s problem. I would politely suggest throwing a TypeError rather than leaving users thinking that they have a package installation problem when they see the NameError.

example code to trigger a NameError that probably ought to throw a TypeError

from tensorboardX import SummaryWriter
writer = SummaryWriter()
writer.add_scalar("some_variable", "a_string", 0)
0reactions
mgoldeycommented, Jun 9, 2020

The specific invocation in transformers could be passing something that’s a string type, so this looks like the logic for whether it’s in caffe2 is falsely triggering. I think I can suggest a one line fix for this, but there might be a more elegant way. Specific logic in transformers triggering this issue for me is just a for loop over a dictionary’s items. https://github.com/huggingface/transformers/blob/02e5f79662d72cccdca81a47e3001a5f6d36e5b1/src/transformers/trainer.py#L556-L557

Read more comments on GitHub >

github_iconTop Results From Across the Web

tensorboardX documentation - Read the Docs
Writes entries directly to event files in the logdir to be consumed by TensorBoard. The SummaryWriter class provides a high-level API to create...
Read more >
torch.utils.tensorboard — PyTorch 1.13 documentation
The SummaryWriter class provides a high-level API to create an event file in a given directory and add summaries and events to it....
Read more >
A Complete Guide to Using TensorBoard with PyTorch
import torchvision.transforms as transforms from torch.utils.tensorboard import SummaryWriter. The last command is the one which enables us ...
Read more >
TensorBoard support within PyTorch (#16196) (98e312cf)
25, + from torch.utils.tensorboard import SummaryWriter ... ToTensor(), transforms. ... assertFalse(plt.fignum_exists(figure.number)).
Read more >
Can I use TensorBoard with Google Colab? - Stack Overflow
LOG_DIR = '/tmp/log' get_ipython().system_raw( 'tensorboard --logdir {} --host ... You can add scalar info or graph or histogram data.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found