减少训练过程中的输出频率

修改了训练脚本,将训练过程中的进度输出频率从每批输出改为每100批输出一次,以减少输出量,提高训练效率。
This commit is contained in:
whaifree 2024-10-06 22:16:42 +08:00
parent 87fa4dfcc6
commit d65f6ec3ce

View File

@ -222,17 +222,19 @@ for epoch in range(num_epochs):
time_left = datetime.timedelta(seconds=batches_left * (time.time() - prev_time)) time_left = datetime.timedelta(seconds=batches_left * (time.time() - prev_time))
epoch_time = time.time() - prev_time epoch_time = time.time() - prev_time
prev_time = time.time() prev_time = time.time()
sys.stdout.write( if step % 100 == 0:
"\r[Epoch %d/%d] [Batch %d/%d] [loss: %f] ETA: %.10s" sys.stdout.write(
% ( "\r[Epoch %d/%d] [Batch %d/%d] [loss: %f] ETA: %.10s"
epoch, % (
num_epochs, epoch,
i, num_epochs,
len(loader['train']), i,
loss.item(), len(loader['train']),
time_left, loss.item(),
time_left,
)
) )
)
# adjust the learning rate # adjust the learning rate