【发布时间】:2019-12-29 05:56:26
【问题描述】:
我正在尝试使用 tensorboard(通过调用 .addscalar())可视化损失与纪元图,以便我可以适当地调整我的神经网络模型。然而,在训练模型之后,我在网络浏览器中检查了我的张量板,它显示:“未找到标量数据。”
我试过检查我的事件统计信息,似乎有标量:
Event statistics for runs/tf_druggability/classification_ffnn_1:
audio -
graph -
histograms -
images -
scalars
first_step 0
last_step 90
max_step 90
min_step 0
num_steps 10
outoforder_steps [(90L, 0L), (90L, 0L)]
sessionlog:checkpoint -
sessionlog:start -
sessionlog:stop -
tensor -
这是我的代码:
from torch.utils.tensorboard import SummaryWriter
sess = tensorflow.Session()
writer = SummaryWriter('runs/tf_druggability/classification_ffnn_1', sess.graph)
for epoch in range(100):
# Wrap input data and labels in Variable to can gradient descent (in place of DataLoader)
inputs = Variable(traindf_to_tensor)
labels = Variable(trainlabels_to_tensor)
optimizer.zero_grad()
outputs = net(inputs)
loss = criterion(outputs, labels)
loss.backward()
optimizer.step()
if(epoch%10 == 0):
# HERE I WRITE to the LOG FILE for TENSORBOARD:
writer.add_scalar('training loss', loss.item(), epoch)
print('epoch {}, loss {}'.format(epoch, loss.item()))
writer.close()
print('Finished training! :)')
当我尝试在 Jupyter Notebooks 中打开事件文件时,它里面有这个(...意味着我省略了中间部分):
1800 0000 0000 0000 a37f 4b22 09f2 3d6b
a51e 58d7 411a 0d62 7261 696e 2e45 7665
6e74 3a32 ac51 0a16 2100 0000 0000 0000
...
f723 0000 0000 0000 00b0 9f77 4309 d00a
0ea7 1e58 d741 105a 2a16 0a14 0a0d 7472
6169 6e69 6e67 5f6c 6f73 7315 c193 403f
【问题讨论】:
标签: python pytorch tensorboard