Skip to content

Commit c2c5892

Browse files
authored
[egs,scripts] Updates for smooth chain2 training (#4290)
1 parent 3ce241b commit c2c5892

File tree

5 files changed

+16
-22
lines changed

5 files changed

+16
-22
lines changed

egs/mini_librispeech/s5/local/chain2/tuning/run_tdnn_1a.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,7 @@ if [ $stage -le 12 ]; then
148148
# This will be a two-level tree (with the smaller number of leaves specified
149149
# by the '--num-clusters' option); this is needed by the adaptation framework
150150
# search below for 'tree.map'
151-
if [ -f $tree_dir/final.mdl ]; then
152-
echo "$0: $tree_dir/final.mdl already exists, refusing to overwrite it."
153-
exit 1;
154-
fi
155-
steps/nnet3/chain/build_tree.sh \
151+
steps/nnet3/chain/build_tree.sh \
156152
--frame-subsampling-factor ${frame_subsampling_factor} \
157153
--context-opts "--context-width=2 --central-position=1" \
158154
--cmd "$train_cmd" 3500 ${lores_train_data_dir} \
@@ -200,17 +196,18 @@ if [ $stage -le 14 ]; then
200196
output-layer name=output-default-xent input=prefinal-xent dim=$num_leaves learning-rate-factor=$learning_rate_factor max-change=1.5
201197
EOF
202198
steps/nnet3/xconfig_to_configs.py --xconfig-file $dir/configs/default.xconfig --config-dir $dir/configs/
203-
if [ $dir/init/default_trans.mdl ]; then # checking this because it may have been copied in a previous run of the same script
204-
copy-transition-model $tree_dir/final.mdl $dir/init/default_trans.mdl || exit 1 &
205-
else
206-
echo "Keeping the old $dir/init/default_trans.mdl as it already exists."
207-
fi
208199
fi
209200
wait;
210201

211202
init_info=$dir/init/info.txt
212203
if [ $stage -le 15 ]; then
213204

205+
if [ $dir/init/default_trans.mdl ]; then # checking this because it may have been copied in a previous run of the same script
206+
copy-transition-model $tree_dir/final.mdl $dir/init/default_trans.mdl || exit 1 &
207+
else
208+
echo "Keeping the old $dir/init/default_trans.mdl as it already exists."
209+
fi
210+
214211
if [ ! -f $dir/configs/ref.raw ]; then
215212
echo "Expected $dir/configs/ref.raw to exist"
216213
exit

egs/wsj/s5/steps/nnet3/chain2/compute_preconditioning_matrix.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ if [ $stage -le 2 ]; then
7676
$ldafolder/lda.mat $ldafolder/lda_stats || exit 1
7777

7878
rm $ldafolder/lda_stats
79-
ln -rs $ldafolder/lda.mat $ldafolder/configs/lda.mat
79+
ln -sf $ldafolder/lda.mat $ldafolder/configs/lda.mat
8080
fi
8181

8282
echo "$0: Finished computing LDA transform"

egs/wsj/s5/steps/nnet3/chain2/get_raw_egs.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ latdir=$3
130130
dir=$4
131131

132132
tree=$chaindir/${lang}.tree
133-
trans_mdl=$chaindir/init/${lang}.mdl # contains the transition model and a nnet, but
134-
# we won't be making use of the nnet part.
133+
trans_mdl=$chaindir/init/${lang}_trans.mdl
135134
normalization_fst=$chaindir/den_fsts/${lang}.normalization.fst
136135
den_fst=$chaindir/den_fsts/${lang}.den.fst
137136

@@ -142,13 +141,6 @@ for f in $data/feats.scp $latdir/lat.1.gz $latdir/final.mdl \
142141
$tree $normalization_fst $den_fst $extra_files; do
143142
[ ! -f $f ] && echo "$0: no such file $f" && exit 1;
144143
done
145-
if [ ! -f $trans_mdl ]; then
146-
trans_mdl=$chaindir/init/${lang}_trans.mdl
147-
if [ ! -f $trans_mdl ]; then
148-
echo "$0: cannot find transition model in $chaindir/init/${lang}_trans.mdl or $trans_mdl"
149-
exit 1
150-
fi
151-
fi
152144

153145
nj=$(cat $latdir/num_jobs) || exit 1
154146
if [ -f $latdir/per_utt ]; then
@@ -227,7 +219,7 @@ else
227219
fi
228220

229221
feats="scp:$sdata/JOB/feats.scp"
230-
if [ ! -z $cmvn_opts ]; then
222+
if [ ! -z "$cmvn_opts" ]; then
231223
if [ ! -f $data/cmvn.scp ]; then
232224
echo "Cannot find $data/cmvn.scp. But cmvn_opts=$cmvn_opts"
233225
exit 1

egs/wsj/s5/steps/nnet3/chain2/internal/get_best_model.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ output=output
1515
if [ -f path.sh ]; then . ./path.sh; fi
1616
. parse_options.sh || exit 1;
1717

18-
if [ $# -le 1 ]; then
18+
if [ $# -lt 1 ]; then
1919
echo "Usage: $0: [options] <model-1-log> <model-2-log> .... <model-N-log>"
2020
echo "where <model-n> is one of the n models to choose from."
2121
echo ""

egs/wsj/s5/steps/nnet3/chain2/train.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,12 @@ while [ $x -lt $num_iters ]; do
191191
"nnet3-copy --learning-rate=$lrate $dir/${x}.raw - |" $den_fst_dir \
192192
"ark:nnet3-chain-copy-egs $egs_opts scp:$egs_dir/${name}_subset.scp ark:- | nnet3-chain-merge-egs $multilingual_eg_opts --minibatch-size=1:64 ark:- ark:-|" \
193193
$dir/${next_x}_${name}.mdl || touch $dir/.error_diagnostic &
194+
195+
# Make sure we do not run more than $num_jobs_final at once
196+
[ $num_jobs_final -eq 1 ] && wait
197+
194198
done
199+
wait
195200
fi
196201

197202
if [ $x -gt 0 ]; then

0 commit comments

Comments
 (0)