Use tensorboard to draw two curves in one picture in Pytorch (error report: NotImplementedError: Got <class 'dict'>, but numpy array, torch)

Up code

from torch.utils.tensorboard import SummaryWriter

writer=SummaryWriter("log2")

for i in range(100):
     writer.add_scalars('haha', {
    
    'Train':i*i*3+0.5}, i)
     writer.add_scalars('haha', {
    
    'Test': i*i}, i)
writer.close()
#############################################
!!!是add_scalars而不是add_scalar
有一个s!
#############################################

否则报错:
Please add image description
NotImplementedError: Got <class ‘dict’>, but numpy array, torch tensor, or caffe2 blob name are expected.

Run screenshot
Please add image description

おすすめ

転載: blog.csdn.net/X131644/article/details/124860810