Skip to content

Commit 80ac7dc

Browse files
authored
Fix pad usage bug for seq2seq (PaddlePaddle#1216)
1 parent a4c1dce commit 80ac7dc

File tree

1 file changed

+2
-2
lines changed
  • examples/machine_translation/seq2seq

1 file changed

+2
-2
lines changed

examples/machine_translation/seq2seq/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def prepare_train_input(insts, bos_id, eos_id, pad_id):
117117
# Pad sequence using eos id.
118118
src, src_length = Pad(pad_val=pad_id, ret_length=True)(
119119
[inst[0] for inst in insts])
120-
tgt, tgt_length = Pad(pad_val=pad_id, ret_length=True)(
121-
[inst[1] for inst in insts], dtype="int64")
120+
tgt, tgt_length = Pad(pad_val=pad_id, ret_length=True, dtype="int64")(
121+
[inst[1] for inst in insts])
122122
tgt_mask = (tgt[:, :-1] != pad_id).astype("float32")
123123
return src, src_length, tgt[:, :-1], tgt[:, 1:, np.newaxis], tgt_mask

0 commit comments

Comments
 (0)