Merge pull request #117 from csukuangfj/fix-empty-lattice

Handle empty lattices in attention decoder rescoring.
This commit is contained in:
Daniel Povey 2021-11-11 16:26:02 +08:00 committed by GitHub
commit b9452235d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -856,6 +856,10 @@ def rescore_with_attention_decoder(
tokens = tokens.remove_values_leq(0)
token_ids = tokens.tolist()
if len(token_ids) == 0:
print("Warning: rescore_with_attention_decoder(): empty token-ids")
return None
nll = model.decoder_nll(
memory=expanded_memory,
memory_key_padding_mask=expanded_memory_key_padding_mask,