pip install tensorboardX
还得安装TensorFlow
pip install tensorflow
导包后往里面放数据就行,第一个参数是名称,第二个是y坐标,第三个是x坐标,通过add_scalar进行参数的添加。
import numpy as np
from tensorboardX import SummaryWriter
writer = SummaryWriter(log_dir='scalar')
for epoch in range(100):
writer.add_scalar('scalar/test', np.random.rand(), epoch)
writer.add_scalars('scalar/scalars_test', {'xsinx': epoch * np.sin(epoch), 'xcosx': epoch * np.cos(epoch)}, epoch)
writer.close()
结束后会生成scalar目录(log_dir所指),里面放了.event文件。
tensorboard --logdir=scalar