网络上查找到两种可视化方式:
其一:Visdom包(https://zhuanlan.zhihu.com/p/32025746)
其二:tensorboardx调用tensorboard(参考 https://www.jianshu.com/p/46eb3004beca)
本文采用第二种方式,安装文件
pip install tensorboardX
pip install tensorflow
测试代码
'''
参考 https://www.jianshu.com/p/46eb3004beca
'''
import numpy as np
from tensorboardX import SummaryWriter
writer = SummaryWriter()
for epoch in range(100):
#print(epoch,epoch*np.sin(epoch),epoch*np.cos(epoch))
writer.add_scalar('scalar/test',np.random.rand())
writer.add_scalars('scalar/scalars_test',{'xsinx':epoch*np.sin(epoch),'xcosx':epoch*np.cos(epoch)},epoch)
writer.close()
目录下生成文件位于runs文件夹下,调用
tensorboard --logdir runs
提示 TensorBoard 1.13.1 at http://DESKTOP-SM5RK2N:6006 (Press CTRL+C to quit)
但是本机输入http://DESKTOP-SM5RK2N:6006 在浏览器中无法打开,参考https://blog.csdn.net/zhangkaixu321/article/details/79166089,访问地址修改为
http://localhost:6006
成功访问