Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion fluid/DeepASR/tools/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 9 additions & 8 deletions fluid/DeepASR/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,17 @@ def test(exe):
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,
Expand Down