Skip to content
Open
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
2 changes: 1 addition & 1 deletion dygraph/seq2seq/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def eval(data, epoch_id=0):
batch_times.append(train_batch_cost)
if batch_id > 0 and batch_id % 100 == 0:
print(
"-- Epoch:[%d]; Batch:[%d]; ppl: %.5f, batch_cost: %.5f s, reader_cost: %.5f s, ips: %.5f words/s"
"-- Epoch:[%d]; Batch:[%d]; ppl: %.5f, batch_cost: %.5f s, reader_cost: %.5f s, ips: %.5f words/sec"
% (epoch_id, batch_id, np.exp(total_loss.numpy() /
word_count),
train_batch_cost, total_reader_cost / 100,
Comment on lines +183 to 186
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

train_batch_cost需求平均

Expand Down
13 changes: 10 additions & 3 deletions dygraph/transformer/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,13 @@ def do_train(args):
batch_id = 0
batch_start = time.time()
interval_word_num = 0.0
total_reader_costs = 0.0
batch_reader_start = time.time()
for input_data in train_loader():
if args.max_iter and step_idx == args.max_iter: #NOTE: used for benchmark
return
batch_reader_end = time.time()
total_reader_costs += batch_reader_end - batch_reader_start

(src_word, src_pos, src_slf_attn_bias, trg_word, trg_pos,
trg_slf_attn_bias, trg_src_attn_bias, lbl_word,
Expand Down Expand Up @@ -201,13 +204,16 @@ def do_train(args):
logger.info(
"step_idx: %d, epoch: %d, batch: %d, avg loss: %f, "
"normalized loss: %f, ppl: %f, avg_speed: %.2f step/s, "
"words speed: %0.2f words/s" %
"reader cost: %0.2f sec, ips: %0.2f words/sec" %
(step_idx, pass_id, batch_id, total_avg_cost,
total_avg_cost - loss_normalizer,
np.exp([min(total_avg_cost, 100)]),
train_avg_batch_cost, word_speed))
batch_start = time.time()
train_avg_batch_cost,
total_reader_costs / args.print_step, word_speed))

interval_word_num = 0.0
total_reader_costs = 0.0
batch_start = time.time()

if step_idx % args.save_step == 0 and step_idx != 0:
# validation
Expand Down Expand Up @@ -250,6 +256,7 @@ def do_train(args):

batch_id += 1
step_idx += 1
batch_reader_start = time.time()

train_epoch_cost = time.time() - epoch_start
ce_time.append(train_epoch_cost)
Expand Down