From: Francois Fleuret Date: Fri, 16 Jun 2017 12:19:06 +0000 (+0200) Subject: Prints the ETA. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=74a872447b15747c7eb576b24344ed6b48d01642;p=pysvrt.git Prints the ETA. --- diff --git a/cnn-svrt.py b/cnn-svrt.py index 5913345..06e58bd 100755 --- a/cnn-svrt.py +++ b/cnn-svrt.py @@ -146,6 +146,8 @@ def train_model(model, train_set): optimizer = optim.SGD(model.parameters(), lr = 1e-2) + start_t = time.time() + for e in range(0, args.nb_epochs): acc_loss = 0.0 for b in range(0, train_set.nb_batches): @@ -157,6 +159,8 @@ def train_model(model, train_set): loss.backward() optimizer.step() log_string('train_loss {:d} {:f}'.format(e + 1, acc_loss)) + dt = (time.time() - t) / (e + 1) + print(Fore.CYAN + 'ETA ' + time.ctime(time.time() + dt * (args.nb_epochs - e)) + Style.RESET_ALL) return model