Skip to content

Commit 1d61f1c

Browse files
authored
[src,scripts,egs] Misc small fixes, including fix to TDNN-F results in mini_librispeech (kaldi-asr#2565)
1 parent a630dd2 commit 1d61f1c

File tree

8 files changed

+51
-35
lines changed

8 files changed

+51
-35
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ addons:
2121
- gfortran-4.9
2222
- liblapack-dev
2323
- clang-3.8
24+
- sox
2425

2526
branches:
2627
only:

egs/mini_librispeech/s5/local/chain/tuning/run_tdnn_1h.sh

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
#!/bin/bash
22

33
# 1h is as 1g but a re-tuned model based on resnet-style TDNN-F layers with
4-
# bypass connections. Below, 1h2 is just a rerun of 1h with a different --affix
5-
# option, to give some idea of the run-to-run variation.
6-
7-
# local/chain/compare_wer.sh --online exp/chain/tdnn1g_sp exp/chain/tdnn1h_sp exp/chain/tdnn1h2_sp
8-
# System tdnn1g_sp tdnn1h_sp tdnn1h2_sp
9-
#WER dev_clean_2 (tgsmall) 13.50 13.18 13.04
10-
# [online:] 13.52 13.03 12.97
11-
#WER dev_clean_2 (tglarge) 9.79 9.18 9.16
12-
# [online:] 9.79 9.29 9.24
13-
# Final train prob -0.0460 -0.0531 -0.0590
14-
# Final valid prob -0.0892 -0.0844 -0.0865
15-
# Final train prob (xent) -1.1739 -1.5244 -1.7771
16-
# Final valid prob (xent) -1.4487 -1.7447 -1.9611
17-
# Num-params 6234672 3512112 3512112
18-
19-
# steps/info/chain_dir_info.pl exp/chain/tdnn1{g,h,h2}_sp
4+
# bypass connections. Below, 1h2 and 1h3 are just reruns of 1h with different
5+
# --affix options, to give some idea of the run-to-run variation.
6+
7+
# local/chain/compare_wer.sh --online exp/chain/tdnn1g_sp exp/chain/tdnn1h_sp exp/chain/tdnn1h2_sp exp/chain/tdnn1h3_sp
8+
# System tdnn1g_sp tdnn1h_sp tdnn1h2_sp tdnn1h3_sp
9+
#WER dev_clean_2 (tgsmall) 13.50 12.09 12.23 12.19
10+
# [online:] 13.52 12.11 12.25 12.14
11+
#WER dev_clean_2 (tglarge) 9.79 8.59 8.64 8.73
12+
# [online:] 9.79 8.76 8.65 8.78
13+
# Final train prob -0.0460 -0.0493 -0.0490 -0.0493
14+
# Final valid prob -0.0892 -0.0805 -0.0803 -0.0813
15+
# Final train prob (xent) -1.1739 -1.1730 -1.1742 -1.1749
16+
# Final valid prob (xent) -1.4487 -1.3872 -1.3857 -1.3913
17+
# Num-params 6234672 5207856 5207856 5207856
18+
19+
2020
# exp/chain/tdnn1g_sp: num-iters=25 nj=2..5 num-params=6.2M dim=40+100->2328 combine=-0.056->-0.055 (over 3) xent:train/valid[15,24,final]=(-1.50,-1.23,-1.17/-1.73,-1.52,-1.45) logprob:train/valid[15,24,final]=(-0.063,-0.051,-0.046/-0.101,-0.094,-0.089)
21-
# exp/chain/tdnn1h_sp: num-iters=34 nj=2..5 num-params=3.5M dim=40+100->2328 combine=-0.055->-0.050 (over 4) xent:train/valid[21,33,final]=(-1.97,-1.57,-1.52/-2.11,-1.78,-1.74) logprob:train/valid[21,33,final]=(-0.080,-0.061,-0.053/-0.106,-0.096,-0.084)
22-
# exp/chain/tdnn1h2_sp: num-iters=34 nj=2..5 num-params=3.5M dim=40+100->2328 combine=-0.062->-0.056 (over 4) xent:train/valid[21,33,final]=(-2.21,-1.78,-1.78/-2.34,-1.96,-1.96) logprob:train/valid[21,33,final]=(-0.086,-0.066,-0.059/-0.110,-0.098,-0.087)
21+
# exp/chain/tdnn1h_sp: num-iters=34 nj=2..5 num-params=5.2M dim=40+100->2328 combine=-0.049->-0.046 (over 4) xent:train/valid[21,33,final]=(-1.50,-1.22,-1.17/-1.66,-1.44,-1.39) logprob:train/valid[21,33,final]=(-0.068,-0.055,-0.049/-0.097,-0.088,-0.080)
22+
# exp/chain/tdnn1h2_sp: num-iters=34 nj=2..5 num-params=5.2M dim=40+100->2328 combine=-0.049->-0.046 (over 4) xent:train/valid[21,33,final]=(-1.50,-1.22,-1.17/-1.67,-1.43,-1.39) logprob:train/valid[21,33,final]=(-0.068,-0.055,-0.049/-0.096,-0.087,-0.080)
23+
# exp/chain/tdnn1h3_sp: num-iters=34 nj=2..5 num-params=5.2M dim=40+100->2328 combine=-0.050->-0.046 (over 4) xent:train/valid[21,33,final]=(-1.51,-1.23,-1.17/-1.67,-1.45,-1.39) logprob:train/valid[21,33,final]=(-0.068,-0.055,-0.049/-0.097,-0.089,-0.081)
2324

2425
# Set -e here so that we catch if any executable fails immediately
2526
set -euo pipefail

egs/wsj/s5/steps/decode.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ if [ $(basename $model) != final.alimdl ] ; then
8080
fi
8181

8282
for f in $sdata/1/feats.scp $sdata/1/cmvn.scp $model $graphdir/HCLG.fst; do
83-
[ ! -f $f ] && echo "decode.sh: no such file $f" && exit 1;
83+
[ ! -f $f ] && echo "$0: Error: no such file $f" && exit 1;
8484
done
8585

8686
if [ -f $srcdir/final.mat ]; then feat_type=lda; else feat_type=delta; fi
@@ -96,13 +96,13 @@ thread_string=
9696
case $feat_type in
9797
delta) feats="ark,s,cs:apply-cmvn $cmvn_opts --utt2spk=ark:$sdata/JOB/utt2spk scp:$sdata/JOB/cmvn.scp scp:$sdata/JOB/feats.scp ark:- | add-deltas $delta_opts ark:- ark:- |";;
9898
lda) feats="ark,s,cs:apply-cmvn $cmvn_opts --utt2spk=ark:$sdata/JOB/utt2spk scp:$sdata/JOB/cmvn.scp scp:$sdata/JOB/feats.scp ark:- | splice-feats $splice_opts ark:- ark:- | transform-feats $srcdir/final.mat ark:- ark:- |";;
99-
*) echo "Invalid feature type $feat_type" && exit 1;
99+
*) echo "$0: Error: Invalid feature type $feat_type" && exit 1;
100100
esac
101101
if [ ! -z "$transform_dir" ]; then # add transforms to features...
102102
echo "Using fMLLR transforms from $transform_dir"
103103
[ ! -f $transform_dir/trans.1 ] && echo "Expected $transform_dir/trans.1 to exist."
104104
[ ! -s $transform_dir/num_jobs ] && \
105-
echo "$0: expected $transform_dir/num_jobs to contain the number of jobs." && exit 1;
105+
echo "$0: Error: expected $transform_dir/num_jobs to contain the number of jobs." && exit 1;
106106
nj_orig=$(cat $transform_dir/num_jobs)
107107
if [ $nj -ne $nj_orig ]; then
108108
# Copy the transforms into an archive with an index.
@@ -119,7 +119,7 @@ fi
119119
if [ $stage -le 0 ]; then
120120
if [ -f "$graphdir/num_pdfs" ]; then
121121
[ "`cat $graphdir/num_pdfs`" -eq `am-info --print-args=false $model | grep pdfs | awk '{print $NF}'` ] || \
122-
{ echo "Mismatch in number of pdfs with $model"; exit 1; }
122+
{ echo "$0: Error: Mismatch in number of pdfs with $model"; exit 1; }
123123
fi
124124
$cmd --num-threads $num_threads JOB=1:$nj $dir/log/decode.JOB.log \
125125
gmm-latgen-faster$thread_string --max-active=$max_active --beam=$beam --lattice-beam=$lattice_beam \
@@ -134,9 +134,9 @@ fi
134134

135135
if ! $skip_scoring ; then
136136
[ ! -x local/score.sh ] && \
137-
echo "Not scoring because local/score.sh does not exist or not executable." && exit 1;
137+
echo "$0: Not scoring because local/score.sh does not exist or not executable." && exit 1;
138138
local/score.sh --cmd "$cmd" $scoring_opts $data $graphdir $dir ||
139-
{ echo "$0: Scoring failed. (ignore by '--skip-scoring true')"; exit 1; }
139+
{ echo "$0: Error: scoring failed. (ignore by '--skip-scoring true')"; exit 1; }
140140
fi
141141

142142
exit 0;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../nnet2/remove_egs.sh

src/nnet3/convolution.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ static void ComputeTempMatrixSize(const ConvolutionComputationOptions &opts,
988988
temp_rows = new_num_t_out * computation->num_images;
989989
BaseFloat new_num_megabytes = (4 * temp_rows * temp_cols) / 1000000.0;
990990
// make sure we're within the memory limit.
991-
if (new_num_megabytes > megabyte_limit) {
991+
if (new_num_megabytes > 1.01 * megabyte_limit) {
992992
KALDI_WARN << "Memory consumed in convolution is more than requested "
993993
<< "(maybe very long time sequence?)";
994994
}

src/nnet3/nnet-analyze.cc

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,22 +1441,35 @@ int64 GetMaxMemoryUse(const NnetComputation &computation) {
14411441
max_memory_use = 0;
14421442
int32 num_commands = computation.commands.size(),
14431443
num_submatrices = computation.submatrices.size();
1444+
// the vector 'num_compressed_bytes' is used to remember the number of bytes
1445+
// in the compressed matrices for each submatrix (this will only be used for
1446+
// those that correspond to a 'whole matrix). It's needed because the
1447+
// decompression command doesn't tell us what compression type was used for
1448+
// that matrix.
1449+
std::vector<int32> num_compressed_bytes(num_submatrices, -100000000);
14441450
for (int32 command_index = 0; command_index < num_commands; ++command_index) {
14451451
const NnetComputation::Command &c = computation.commands[command_index];
14461452
int64 this_num_bytes = -100000000,
14471453
this_compressed_num_bytes = -10000000;
1454+
1455+
14481456
if (c.arg1 >= 0 && c.arg1 < num_submatrices) {
14491457
// if arg1 could plausibly be a sub-matrix index...
14501458
const NnetComputation::SubMatrixInfo &submat_info =
14511459
computation.submatrices[c.arg1];
14521460
this_num_bytes = static_cast<int64>(sizeof(BaseFloat)) *
14531461
submat_info.num_rows * submat_info.num_cols;
14541462

1455-
this_compressed_num_bytes =
1456-
((c.arg2 == static_cast<int32>(kCompressedMatrixInt8) ||
1457-
c.arg2 == static_cast<int32>(kCompressedMatrixUint8)) ?
1458-
1 : 2) * static_cast<int64>(submat_info.num_rows) *
1459-
submat_info.num_cols;
1463+
if (c.command_type == kCompressMatrix) {
1464+
this_compressed_num_bytes =
1465+
((c.arg2 == static_cast<int32>(kCompressedMatrixInt8) ||
1466+
c.arg2 == static_cast<int32>(kCompressedMatrixUint8)) ?
1467+
1 : 2) * static_cast<int64>(submat_info.num_rows) *
1468+
submat_info.num_cols;
1469+
num_compressed_bytes[c.arg1] = this_compressed_num_bytes;
1470+
} else if (c.command_type == kDecompressMatrix) {
1471+
this_compressed_num_bytes = num_compressed_bytes[c.arg1];
1472+
}
14601473
}
14611474
switch (c.command_type) {
14621475
case kAllocMatrix:

src/nnet3/nnet-optimize-utils.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4692,7 +4692,7 @@ class MemoryCompressionOptimizer {
46924692

46934693
/** @param [in] nnet The neural net the computation is for.
46944694
@param [in] memory_compression_level. The level of compression:
4695-
0 = no compression (the constructor should not be calle with this value).
4695+
0 = no compression (the constructor should not be called with this value).
46964696
1 = compression that doesn't affect the results (but still takes time).
46974697
2 = compression that affects the results only very slightly
46984698
3 = compression that affects the results a little more.

tools/extras/check_dependencies.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ if ! echo "#include <zlib.h>" | $CXX -E - >&/dev/null; then
6565
add_packages zlib-devel zlib1g-dev zlib-devel
6666
fi
6767

68-
for f in make automake autoconf patch grep bzip2 gzip wget git; do
68+
for f in make automake autoconf patch grep bzip2 gzip wget git sox; do
6969
if ! which $f >&/dev/null; then
7070
echo "$0: $f is not installed."
7171
add_packages $f $f $f
@@ -100,7 +100,7 @@ if ! which python3 >&/dev/null; then
100100
pythonok=false
101101
fi
102102

103-
(
103+
(
104104
#Use a subshell so that sourcing env.sh does not have an influence on the rest of the script
105105
[ -f ./env.sh ] && . ./env.sh
106106
if $pythonok && ! which python2 >&/dev/null; then
@@ -111,14 +111,14 @@ if $pythonok && ! which python2 >&/dev/null; then
111111
fi
112112

113113
if [[ -f $PWD/python/.use_default_python && -f $PWD/python/python ]]; then
114-
rm $PWD/python/python
114+
rm $PWD/python/python
115115
fi
116116

117117
if $pythonok && which python >&/dev/null && [[ ! -f $PWD/python/.use_default_python ]]; then
118118
version=`python 2>&1 --version | awk '{print $2}' `
119119
if [[ $version != "2.7"* ]] ; then
120120
echo "$0: WARNING python 2.7 is not the default python. We fixed this by adding a correct symlink more prominently on the path."
121-
echo "$0: If you really want to use python $version as default, add an empty file $PWD/python/.use_default_python and run this script again."
121+
echo "$0: If you really want to use python $version as default, add an empty file $PWD/python/.use_default_python and run this script again."
122122
mkdir -p $PWD/python
123123
ln -s $(which python2.7) $PWD/python/python
124124
echo "export PATH=$PWD/python:\${PATH}" >> env.sh

0 commit comments

Comments
 (0)