Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging PyTorch scalars #61

Open
dkumor opened this issue Apr 6, 2020 · 0 comments
Open

Logging PyTorch scalars #61

dkumor opened this issue Apr 6, 2020 · 0 comments

Comments

@dkumor
Copy link

dkumor commented Apr 6, 2020

With latest tensorwatch and pytorch 1.4, I would expect the following code, based on the example in readme to create a plot of loss:

import tensorwatch as tw
import time
import torch

w = tw.Watcher(filename='test.log')
s = w.create_stream(name='metric1')
w.make_notebook()

# loss is a pytorch scalar with value 2
loss = torch.tensor(2)
for i in range(1000):
    # Without the next line, plotting does not work
    # loss = loss.reshape((1,1))
    print("loss",loss)
    s.write(loss)
    loss +=1
    time.sleep(1)

However, the plot remains empty when logging the pytorch scalar. Only when I reshape it to a 1x1 matrix with loss.reshape((1,1)) does the plot update in jupyter notebook.

I personally found this confusing - I think it would be very useful to have direct support for scalars here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant