diff --git a/fluid/DeepASR/tools/profile.py b/fluid/DeepASR/tools/profile.py index cb0227c33a25b1c38977f8485237f13d0351c36f..9d0b47694273345357726ad51062d01ff01b120d 100644 --- a/fluid/DeepASR/tools/profile.py +++ b/fluid/DeepASR/tools/profile.py @@ -169,7 +169,8 @@ def profile(args): outs = exe.run(fluid.default_main_program(), feed={"feature": feature_t, "label": label_t}, - fetch_list=[avg_cost, accuracy], + fetch_list=[avg_cost, accuracy] + if args.print_train_acc else [], return_numpy=False) if args.print_train_acc: diff --git a/fluid/DeepASR/train.py b/fluid/DeepASR/train.py index 9856dad7d56b47bf14c32a7d0ca0ec10b8ecf88f..b5d2239e94dd5ddcd79d0245e4b980d6cf5bfbf4 100644 --- a/fluid/DeepASR/train.py +++ b/fluid/DeepASR/train.py @@ -216,16 +216,17 @@ def train(args): label_t.set(labels, place) label_t.set_lod([lod]) - cost, acc = exe.run(fluid.default_main_program(), - feed={"feature": feature_t, - "label": label_t}, - fetch_list=[avg_cost, accuracy], - return_numpy=False) + to_print = batch_id > 0 and (batch_id % args.print_per_batches == 0) + outs = exe.run(fluid.default_main_program(), + feed={"feature": feature_t, + "label": label_t}, + fetch_list=[avg_cost, accuracy] if to_print else [], + return_numpy=False) - if batch_id > 0 and (batch_id % args.print_per_batches == 0): + if to_print: print("\nBatch %d, train cost: %f, train acc: %f" % - (batch_id, lodtensor_to_ndarray(cost)[0], - lodtensor_to_ndarray(acc)[0])) + (batch_id, lodtensor_to_ndarray(outs[0])[0], + lodtensor_to_ndarray(outs[1])[0])) # save the latest checkpoint if args.checkpoints != '': model_path = os.path.join(args.checkpoints,