From 61ab90684f803d932d0dab95572199d920eedf9e Mon Sep 17 00:00:00 2001 From: lujun Date: Thu, 10 Jan 2019 18:44:01 +0800 Subject: [PATCH] fix bug at py3, test=develop --- .../train_and_evaluate.py | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/fluid/PaddleNLP/deep_attention_matching_net/train_and_evaluate.py b/fluid/PaddleNLP/deep_attention_matching_net/train_and_evaluate.py index 725c63b8..823d13de 100644 --- a/fluid/PaddleNLP/deep_attention_matching_net/train_and_evaluate.py +++ b/fluid/PaddleNLP/deep_attention_matching_net/train_and_evaluate.py @@ -248,8 +248,9 @@ def train(args): print("device count %d" % dev_count) print("theoretical memory usage: ") - print(fluid.contrib.memory_usage( - program=train_program, batch_size=args.batch_size)) + print( + fluid.contrib.memory_usage( + program=train_program, batch_size=args.batch_size)) exe = fluid.Executor(place) exe.run(train_startup) @@ -318,8 +319,9 @@ def train(args): if (args.save_path is not None) and (step % save_step == 0): save_path = os.path.join(args.save_path, "step_" + str(step)) print("Save model at step %d ... " % step) - print(time.strftime('%Y-%m-%d %H:%M:%S', - time.localtime(time.time()))) + print( + time.strftime('%Y-%m-%d %H:%M:%S', + time.localtime(time.time()))) fluid.io.save_persistables(exe, save_path, train_program) score_path = os.path.join(args.save_path, 'score.' + str(step)) @@ -358,8 +360,9 @@ def train(args): save_path = os.path.join(args.save_path, "step_" + str(step)) print("Save model at step %d ... " % step) - print(time.strftime('%Y-%m-%d %H:%M:%S', - time.localtime(time.time()))) + print( + time.strftime('%Y-%m-%d %H:%M:%S', + time.localtime(time.time()))) fluid.io.save_persistables(exe, save_path, train_program) score_path = os.path.join(args.save_path, @@ -389,9 +392,11 @@ def train(args): global_step, last_cost = train_with_pyreader(global_step) else: global_step, last_cost = train_with_feed(global_step) - train_time += time.time() - begin_time + + pass_time_cost = time.time() - begin_time + train_time += pass_time_cost print("Pass {0}, pass_time_cost {1}" - .format(epoch, "%2.2f sec" % (time.time() - begin_time))) + .format(epoch, "%2.2f sec" % pass_time_cost)) # For internal continuous evaluation if "CE_MODE_X" in os.environ: print("kpis train_cost %f" % last_cost) -- GitLab