Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions egs/swbd/s5c/local/chain/run_tdnn_lstm.sh
10 changes: 10 additions & 0 deletions egs/swbd/s5c/local/chain/tuning/run_blstm_6j.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
# and bias-stddev=0 initialization.
# This run also accounts for changes in training due to the BackpropTruncationComponent

#System blstm_6i blstm_6j
#WER on train_dev(tg) 14.11 13.80
#WER on train_dev(fg) 13.04 12.64
#WER on eval2000(tg) 16.2 15.6
#WER on eval2000(fg) 14.6 14.2
#Final train prob -0.0615713-0.0552637
#Final valid prob -0.0829338-0.0765151
#Final train prob (xent) -1.16518 -0.777318
#Final valid prob (xent) -1.26028 -0.912595

set -e

# configs for 'chain'
Expand Down
26 changes: 12 additions & 14 deletions egs/swbd/s5c/local/chain/tuning/run_lstm_6j.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@
# 6j is same as 6i but using the xconfig format of network specification.
# Also, the model is trained without layer-wise discriminative pretraining.
# Another minor change is that the final-affine component has param-stddev-0
# and bias-stddev=0 initialization.
# and bias-stddev=0 initialization. The results also account for changes
# due to BackpropTruncationComponent in place of ClipGradientComponent.
# Note that removal of layerwise discriminative pretraining does not result
# in a lot of improvement in LSTMs, compared to TDNNs (7f vs 7g).



# This run is affected by the bug that per-element-scale components do not have
# max-change. The updated results without the bug will be submitted soon.
#System lstm_6i_ld5 lstm_6j_ld5
#WER on train_dev(tg) 14.65 14.43
#WER on train_dev(fg) 13.38 13.17
#WER on eval2000(tg) 16.9 16.9
#WER on eval2000(fg) 15.4 15.3
#Final train prob -0.0751668-0.0795697
#Final valid prob -0.0928206-0.0926466
#Final train prob (xent) -1.34549 -1.16067
#Final valid prob (xent) -1.41301 -1.23679
#WER on train_dev(tg) 14.65 14.66
#WER on train_dev(fg) 13.38 13.42
#WER on eval2000(tg) 16.9 16.8
#WER on eval2000(fg) 15.4 15.4
#Final train prob -0.0751668-0.0824531
#Final valid prob -0.0928206-0.0989325
#Final train prob (xent) -1.34549 -1.15506
#Final valid prob (xent) -1.41301 -1.24364
#

set -e

# configs for 'chain'
Expand Down
221 changes: 221 additions & 0 deletions egs/swbd/s5c/local/chain/tuning/run_tdnn_7i.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
#!/bin/bash

# Same as 7h but double the number of parameters (27983950 vs 15551509)

set -e


#System tdnn_7h tdnn_7i
#WER on train_dev(tg) 13.84 13.48
#WER on train_dev(fg) 12.84 12.47
#WER on eval2000(tg) 16.5 16.4
#WER on eval2000(fg) 14.8 14.9
#Final train prob -0.0889771-0.0785415
#Final valid prob -0.113102 -0.105757
#Final train prob (xent) -1.2533 -1.15785
#Final valid prob (xent) -1.36743 -1.28397
#
# configs for 'chain'
affix=
stage=12
train_stage=0
get_egs_stage=-10
speed_perturb=true
dir=exp/chain/tdnn_7i # Note: _sp will get added to this if $speed_perturb == true.
decode_iter=

# training options
num_epochs=4
initial_effective_lrate=0.001
final_effective_lrate=0.0001
leftmost_questions_truncate=-1
max_param_change=2.0
final_layer_normalize_target=0.5
num_jobs_initial=3
num_jobs_final=16
minibatch_size=128
frames_per_eg=150
remove_egs=false
common_egs_dir=exp/chain/tdnn_7g_sp/egs
xent_regularize=0.1

# End configuration section.
echo "$0 $@" # Print the command line for logging

. ./cmd.sh
. ./path.sh
. ./utils/parse_options.sh

if ! cuda-compiled; then
cat <<EOF && exit 1
This script is intended to be used with GPUs but you have not compiled Kaldi with CUDA
If you want to use GPUs (and have them), go to src/, and configure and make on a machine
where "nvcc" is installed.
EOF
fi

# The iVector-extraction and feature-dumping parts are the same as the standard
# nnet3 setup, and you can skip them by setting "--stage 8" if you have already
# run those things.

suffix=
if [ "$speed_perturb" == "true" ]; then
suffix=_sp
fi

dir=${dir}${affix:+_$affix}$suffix
train_set=train_nodup$suffix
ali_dir=exp/tri4_ali_nodup$suffix
treedir=exp/chain/tri5_7d_tree$suffix
lang=data/lang_chain_2y


# if we are using the speed-perturbed data we need to generate
# alignments for it.
local/nnet3/run_ivector_common.sh --stage $stage \
--speed-perturb $speed_perturb \
--generate-alignments $speed_perturb || exit 1;


if [ $stage -le 9 ]; then
# Get the alignments as lattices (gives the LF-MMI training more freedom).
# use the same num-jobs as the alignments
nj=$(cat exp/tri4_ali_nodup$suffix/num_jobs) || exit 1;
steps/align_fmllr_lats.sh --nj $nj --cmd "$train_cmd" data/$train_set \
data/lang exp/tri4 exp/tri4_lats_nodup$suffix
rm exp/tri4_lats_nodup$suffix/fsts.*.gz # save space
fi


if [ $stage -le 10 ]; then
# Create a version of the lang/ directory that has one state per phone in the
# topo file. [note, it really has two states.. the first one is only repeated
# once, the second one has zero or more repeats.]
rm -rf $lang
cp -r data/lang $lang
silphonelist=$(cat $lang/phones/silence.csl) || exit 1;
nonsilphonelist=$(cat $lang/phones/nonsilence.csl) || exit 1;
# Use our special topology... note that later on may have to tune this
# topology.
steps/nnet3/chain/gen_topo.py $nonsilphonelist $silphonelist >$lang/topo
fi

if [ $stage -le 11 ]; then
# Build a tree using our new topology. This is the critically different
# step compared with other recipes.
steps/nnet3/chain/build_tree.sh --frame-subsampling-factor 3 \
--leftmost-questions-truncate $leftmost_questions_truncate \
--context-opts "--context-width=2 --central-position=1" \
--cmd "$train_cmd" 7000 data/$train_set $lang $ali_dir $treedir
fi

if [ $stage -le 12 ]; then
echo "$0: creating neural net configs using the xconfig parser";

num_targets=$(tree-info exp/chain/tri5_7d_tree_sp/tree |grep num-pdfs|awk '{print $2}')
learning_rate_factor=$(echo "print 0.5/$xent_regularize" | python)

mkdir -p $dir/configs
cat <<EOF > $dir/configs/network.xconfig
input dim=100 name=ivector
input dim=40 name=input

# please note that it is important to have input layer with the name=input
# as the layer immediately preceding the fixed-affine-layer to enable
# the use of short notation for the descriptor
fixed-affine-layer name=lda input=Append(-1,0,1,ReplaceIndex(ivector, t, 0)) affine-transform-file=$dir/configs/lda.mat

# the first splicing is moved before the lda layer, so no splicing here
relu-renorm-layer name=tdnn1 dim=1024
relu-renorm-layer name=tdnn2 input=Append(-1,0,1) dim=1024
relu-renorm-layer name=tdnn3 input=Append(-1,0,1) dim=1024
relu-renorm-layer name=tdnn4 input=Append(-3,0,3) dim=1024
relu-renorm-layer name=tdnn5 input=Append(-3,0,3) dim=1024
relu-renorm-layer name=tdnn6 input=Append(-3,0,3) dim=1024
relu-renorm-layer name=tdnn7 input=Append(-3,0,3) dim=1024

## adding the layers for chain branch
relu-renorm-layer name=prefinal-chain input=tdnn7 dim=625 target-rms=0.5
output-layer name=output include-log-softmax=false dim=$num_targets max-change=1.5

# adding the layers for xent branch
# This block prints the configs for a separate output that will be
# trained with a cross-entropy objective in the 'chain' models... this
# has the effect of regularizing the hidden parts of the model. we use
# 0.5 / args.xent_regularize as the learning rate factor- the factor of
# 0.5 / args.xent_regularize is suitable as it means the xent
# final-layer learns at a rate independent of the regularization
# constant; and the 0.5 was tuned so as to make the relative progress
# similar in the xent and regular final layers.
relu-renorm-layer name=prefinal-xent input=tdnn7 dim=625 target-rms=0.5
output-layer name=output-xent dim=$num_targets learning-rate-factor=$learning_rate_factor max-change=1.5

EOF
steps/nnet3/xconfig_to_configs.py --xconfig-file $dir/configs/network.xconfig --config-dir $dir/configs/
fi

if [ $stage -le 13 ]; then
if [[ $(hostname -f) == *.clsp.jhu.edu ]] && [ ! -d $dir/egs/storage ]; then
utils/create_split_dir.pl \
/export/b0{5,6,7,8}/$USER/kaldi-data/egs/swbd-$(date +'%m_%d_%H_%M')/s5c/$dir/egs/storage $dir/egs/storage
fi

steps/nnet3/chain/train.py --stage $train_stage \
--cmd "$decode_cmd" \
--feat.online-ivector-dir exp/nnet3/ivectors_${train_set} \
--feat.cmvn-opts "--norm-means=false --norm-vars=false" \
--chain.xent-regularize $xent_regularize \
--chain.leaky-hmm-coefficient 0.1 \
--chain.l2-regularize 0.00005 \
--chain.apply-deriv-weights false \
--chain.lm-opts="--num-extra-lm-states=2000" \
--egs.dir "$common_egs_dir" \
--egs.stage $get_egs_stage \
--egs.opts "--frames-overlap-per-eg 0" \
--egs.chunk-width $frames_per_eg \
--trainer.num-chunk-per-minibatch $minibatch_size \
--trainer.frames-per-iter 1500000 \
--trainer.num-epochs $num_epochs \
--trainer.optimization.num-jobs-initial $num_jobs_initial \
--trainer.optimization.num-jobs-final $num_jobs_final \
--trainer.optimization.initial-effective-lrate $initial_effective_lrate \
--trainer.optimization.final-effective-lrate $final_effective_lrate \
--trainer.max-param-change $max_param_change \
--cleanup.remove-egs $remove_egs \
--feat-dir data/${train_set}_hires \
--tree-dir $treedir \
--lat-dir exp/tri4_lats_nodup$suffix \
--dir $dir || exit 1;

fi

if [ $stage -le 14 ]; then
# Note: it might appear that this $lang directory is mismatched, and it is as
# far as the 'topo' is concerned, but this script doesn't read the 'topo' from
# the lang directory.
utils/mkgraph.sh --left-biphone --self-loop-scale 1.0 data/lang_sw1_tg $dir $dir/graph_sw1_tg
fi

decode_suff=sw1_tg
graph_dir=$dir/graph_sw1_tg
if [ $stage -le 15 ]; then
iter_opts=
if [ ! -z $decode_iter ]; then
iter_opts=" --iter $decode_iter "
fi
for decode_set in train_dev eval2000; do
(
steps/nnet3/decode.sh --acwt 1.0 --post-decode-acwt 10.0 \
--nj 50 --cmd "$decode_cmd" $iter_opts \
--online-ivector-dir exp/nnet3/ivectors_${decode_set} \
$graph_dir data/${decode_set}_hires $dir/decode_${decode_set}${decode_iter:+_$decode_iter}_${decode_suff} || exit 1;
if $has_fisher; then
steps/lmrescore_const_arpa.sh --cmd "$decode_cmd" \
data/lang_sw1_{tg,fsh_fg} data/${decode_set}_hires \
$dir/decode_${decode_set}${decode_iter:+_$decode_iter}_sw1_{tg,fsh_fg} || exit 1;
fi
) &
done
fi
wait;
exit 0;
Loading