0

The page below gives informations about Tensorboard: https://pytorch.org/docs/stable/tensorboard.html I am using Google Colab and when i write the following instructions(which are in the link above):

!pip install tensorboard
tensorboard --logdir=runs

it sends me the following error message:

 File "<ipython-input-111-949c7e8e565e>", line 2
tensorboard --logdir=runs
                         ^
SyntaxError: can't assign to operator

so when i copy paste their own example:

from torch.utils.tensorboard import SummaryWriter
writer = SummaryWriter()
x = range(100)
for i in x:
    writer.add_scalar('y=2x', i * 2, i)
writer.close()

it does not return the expected graph. Could someone help me fix this problem?Thank you in advance!

sosamm
  • 39
  • 1
  • 6
  • Which problem? Could you paste the error message? – Berriel Oct 15 '20 at 13:10
  • It looks like you're missing the `!` at the beginning of that line... it is being interpreted as python code as it is – Berriel Oct 15 '20 at 13:16
  • When i add the '!' it takes forever to load.That's the problem. – sosamm Oct 15 '20 at 13:18
  • Does this answer your question? [Can I use TensorBoard with Google Colab?](https://stackoverflow.com/questions/47818822/can-i-use-tensorboard-with-google-colab) – kHarshit Oct 17 '20 at 05:32

1 Answers1

2

As explained in How to use Tensorboard with PyTorch in Google Colab.

In Google Colab you should start Tensorboard magic at the start of your code with:

%load_ext tensorboard

and after you define a summary file you need to insatiate Tensorboard with

%tensorboard --logdir $tensorboard_dir

where Tensorboard dir is a script variable of type str indicating where the summary file is.

Ido Loebl
  • 61
  • 7