Skip to content

Commit ce520c5

Browse files
committed
more
1 parent f7296de commit ce520c5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

users/zeyer/experiments/exp2024_04_23_baselines/ctc_recog_ext.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from typing import Optional, Any, Tuple, Dict
66
import functools
7+
import numpy as np
78

89
from returnn.tensor import Tensor, Dim
910
import returnn.frontend as rf
@@ -322,6 +323,33 @@ def py():
322323
res.output,
323324
)
324325

326+
# Tune scales on N-best list with rescoring. (Efficient.)
327+
beam_size = 128
328+
for prior_scale in np.linspace(0.0, 1.0, 11):
329+
for lm_scale in np.linspace(0.0, 2.0, 21):
330+
res = recog_model(
331+
task=task,
332+
model=ctc_model,
333+
recog_def=model_recog_ctc_only,
334+
config={"beam_size": beam_size},
335+
recog_pre_post_proc_funcs_ext=[
336+
functools.partial(
337+
lm_framewise_prior_rescore,
338+
# framewise standard prior
339+
prior=Prior(file=prior, type="prob", vocab=vocab_w_blank_file),
340+
prior_scale=prior_scale,
341+
lm=lm,
342+
lm_scale=lm_scale,
343+
vocab=vocab_file,
344+
vocab_opts_file=vocab_opts_file,
345+
)
346+
],
347+
)
348+
tk.register_output(
349+
f"{prefix}/rescore-beam{beam_size}-lm_{lm_out_name}-lmScale{lm_scale}-priorScale{prior_scale}",
350+
res.output,
351+
)
352+
325353

326354
_sis_prefix: Optional[str] = None
327355

0 commit comments

Comments
 (0)