Skip to content

Commit

Permalink
Merge pull request #4843 from pengchengguo/decode_warning
Browse files Browse the repository at this point in the history
Add a warning statement when the hypo length equals to the max out length.
  • Loading branch information
sw005320 committed Dec 29, 2022
2 parents bdd7ab6 + ea03d3d commit b12e08c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions espnet/nets/batch_beam_search_online_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ def forward(
+ "".join([self.token_list[x] for x in best.yseq[1:-1]])
+ "\n"
)
if best.yseq[1:-1].shape[0] == x.shape[0]:
logging.warning(
"best hypo length: {} == max output length: {}".format(
best.yseq[1:-1].shape[0], maxlen
)
)
logging.warning(
"decoding may be stopped by the max output length limitation, "
+ "please consider to increase the maxlenratio."
)
return nbest_hyps

def extend(self, x: torch.Tensor, hyps: Hypothesis) -> List[Hypothesis]:
Expand Down
10 changes: 10 additions & 0 deletions espnet/nets/beam_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,16 @@ def forward(
+ "".join([self.token_list[x] for x in best.yseq[1:-1]])
+ "\n"
)
if best.yseq[1:-1].shape[0] == x.shape[0]:
logging.warning(
"best hypo length: {} == max output length: {}".format(
best.yseq[1:-1].shape[0], maxlen
)
)
logging.warning(
"decoding may be stopped by the max output length limitation, "
+ "please consider to increase the maxlenratio."
)
return nbest_hyps

def post_process(
Expand Down

0 comments on commit b12e08c

Please sign in to comment.