1、使用方法
from tensorboardX import SummaryWriter
writer = SummaryWriter(log_dir="summary/{}".format(args.model))
def train():
writer.add_scalar("Train/loss", epoch_loss, epoch)
writer.add_scalar("Train/ppl", math.pow(2, epoch_loss) , epoch)
writer.add_scalar("Train/bleu", epoch_bleu, epoch)
def evaluate():
pass
for epoch in range(1 , NUM_EPOCHS):
epoch_start_time = time.time()
train()
epoch_loss, epoch_bleu = evaluate()
print('+' * 100)
print('| end of epoch {:3d} | time: {:5.2f}s | valid loss {:5.2f} | '
'valid ppl {:6.2f} | bleu {:3.2f} |'.format(epoch, (time.time() - epoch_start_time), epoch_loss,
math.pow(2, epoch_loss), epoch_bleu))
print('+' * 100)
if not best_epoch_loss or epoch_loss < best_epoch_loss:
with open(args.save, 'wb')