pytorch 利用tensorboard显示loss,acc曲线等
运行环境:
python3.6.9
pytorch1.13.1
cuda10.0
cudnn7.5.1
tensorboard显示
运行PointRCNN算法进行training,得出events.out.tfevents.1592297776.hkd-Precision-7920-Tower
打开终端输入:tensorboard --logdir path/to/tensorboard_logs/
会有输出:TensorBoard 1.6.0 at http://iccd:6006 (Press CTRL+C to quit)
将上述链接复制到浏览器中打开便可以显示该训练参数(tensorboard)
tensorboard记录
from tensorboard_logger import Logger
logger = Logger(logdir="./tensorboard_logs", flush_secs=10)
...
def train(net, optimizer):
for epoch in range(epoch_nums):
net.train()
for batch_idx, (inputs, targets) in enumerate(trainloader):
inputs = Variable(inputs, requires_grad=True).cuda()
targets = targets.cuda()
optimizer.zero_grad()
outputs = net(inputs)
loss = criterion(outputs, targets)
loss.backward()
optimizer.step()
train_loss += loss.item()
...
# 记录所需的变量
logger.log_value('avg_loss', train_loss/(batch_idx+1), epoch*len(trainloader) + batch_idx)
logger.log_value('loss', loss.item(), epoch*len(trainloader) + batch_idx)
logger.log_value('acc', 100. * correct / total, epoch*len(trainloader) + batch_idx)
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/2151.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...