From 08982c691d0880b6dc68532cf95b132dfde9e3e6 Mon Sep 17 00:00:00 2001 From: Jane-Ding <69578198+Jane-Ding@users.noreply.github.com> Date: Thu, 29 Apr 2021 12:37:05 +0800 Subject: [PATCH] Update program.py (#2665) Fix training on Windows when one epoch finishes, it quits unexpectedly. Same as fixing the problem when evaluating on Windows. --- tools/program.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/program.py b/tools/program.py index 33bd35c2..ad6fcbd9 100755 --- a/tools/program.py +++ b/tools/program.py @@ -197,9 +197,11 @@ def train(config, train_reader_cost = 0.0 batch_sum = 0 batch_start = time.time() + max_iter = len(train_dataloader) - 1 if platform.system( + ) == "Windows" else len(train_dataloader) for idx, batch in enumerate(train_dataloader): train_reader_cost += time.time() - batch_start - if idx >= len(train_dataloader): + if idx >= max_iter: break lr = optimizer.get_lr() images = batch[0] -- GitLab