from torch.utils.tensorboard import SummaryWriter for line in range(10): tb = SummaryWriter('./runs/lines/' + str(line)) for step in range(10): value = step + line tb.add_scalar('value of lines', value, step) tb.close()
SummaryWriter类可以打开新的文件,也可以用来修改已经存在的文件