Skip to content

Commit

Permalink
Better warning message for inputs that are too long
Browse files Browse the repository at this point in the history
  • Loading branch information
myleott committed Jan 22, 2018
1 parent 66314a6 commit 3346943
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fairseq/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,10 @@ def yield_batch(next_idx, num_tokens):
if ignore_invalid_inputs:
ignored.append(idx)
continue
raise Exception(
"Unable to handle input id {} of size {} / {}.".format(
idx, src.sizes[idx], dst.sizes[idx]))
raise Exception((
"Sample #{} has size (src={}, dst={}) but max size is {}."
" Skip this example with --skip-invalid-size-inputs-valid-test"
).format(idx, src.sizes[idx], dst.sizes[idx], max_positions))

sample_len = max(sample_len, src.sizes[idx], dst.sizes[idx])
num_tokens = (len(batch) + 1) * sample_len
Expand Down

0 comments on commit 3346943

Please sign in to comment.