下载相应库
pip3 install tensorboardX
pip3 install tensorboard
conda install tensorflow
使用tensorboard
调包
from torch.utils.tensorboard import SummaryWriter
初始化
writer = SummaryWriter
(The file path)
Writer = SummaryWriter()
或者
writer = SummaryWriter(os.path.join(basedir, expname))
# 在默认或者定义的文件夹中生成记录的loss文件
记录变量值
writer.add_scalar
(“The text explains”,Loss,The number of iterations)
writer.add_scalar('Loss', loss, i)
writer.add_scalar('psnr', psnr, i)
生成下面的文件
查看Loss
在终端输入:
tensorboard --logdir <your/running/dir> --port <your_bind_port>
tensorboard --logdir='/home/ubuntu/workspace/xxx/logs/xxx' --port='6006'
点击(http://localhost:6006/)进入web端查看数据