参考https://blog.csdn.net/hxxjxw/article/details/106155870
from torch.utils.tensorboard import SummaryWriter
writer = SummaryWriter("results/logs")
for i in range(100):
writer.add_scalar('y=2x',2*i,i)
writer.close()
writer.add_scalar
中添加需要跟踪的变量的值,这里的i
相当于epoch
上面的代码,会将log保存到``中,查看曲线,通过:
tensorboard --logdir "logs"
#想换端口的话
tensorboard --logdir "logs" --port=6007
#这种写法比--logdir=logs这种写法更好
还有通过add_graph
查看网络结构图,以及通过add_histogram
查看网络权值的分布