From 16dcdf34dca2f0c5d7dc2e0f8c388c1bb8bb1fd0 Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Wed, 24 Feb 2021 11:30:38 +0000 Subject: [PATCH] fix tools --- env.sh | 10 +++++++++ examples/aishell/conf/deepspeech2.yaml | 4 ++-- examples/aishell/local/tune.sh | 28 ++++++++++++++++++++++++ examples/aishell/path.sh | 2 ++ examples/librispeech/path.sh | 2 ++ examples/tiny/path.sh | 2 ++ model_utils/network.py | 4 ++-- setup.sh | 2 +- network_test.py => tests/network_test.py | 2 +- tools/build_vocab.py | 1 - tools/compute_mean_std.py | 1 - 11 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 env.sh create mode 100644 examples/aishell/local/tune.sh rename network_test.py => tests/network_test.py (98%) diff --git a/env.sh b/env.sh new file mode 100644 index 000000000..131c6495a --- /dev/null +++ b/env.sh @@ -0,0 +1,10 @@ +export MAIN_ROOT=${PWD} + +export PATH=${MAIN_ROOT}:${PWD}/tools:${PATH} +export LC_ALL=C + +# Use UTF-8 in Python to avoid UnicodeDecodeError when LC_ALL=C +export PYTHONIOENCODING=UTF-8 +export PYTHONPATH=${MAIN_ROOT}:${PYTHONPATH} + +export export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/ diff --git a/examples/aishell/conf/deepspeech2.yaml b/examples/aishell/conf/deepspeech2.yaml index 56109ac46..a0a9d6295 100644 --- a/examples/aishell/conf/deepspeech2.yaml +++ b/examples/aishell/conf/deepspeech2.yaml @@ -29,9 +29,9 @@ model: use_gru: True share_rnn_weights: False training: - n_epoch: 20 + n_epoch: 30 lr: 5e-4 - lr_decay: 1.0 + lr_decay: 0.83 weight_decay: 1e-06 global_grad_clip: 5.0 max_iteration: 500000 diff --git a/examples/aishell/local/tune.sh b/examples/aishell/local/tune.sh new file mode 100644 index 000000000..1b2f83db2 --- /dev/null +++ b/examples/aishell/local/tune.sh @@ -0,0 +1,28 @@ +#! /usr/bin/env bash + +# grid-search for hyper-parameters in language model +python3 -u ${MAIN_ROOT}/tune.py \ +--device 'gpu' \ +--nproc 1 \ +--config conf/deepspeech2.yaml \ +--num_batches=-1 \ +--batch_size=128 \ +--beam_size=500 \ +--num_proc_bsearch=12 \ +--num_alphas=45 \ +--num_betas=8 \ +--alpha_from=1.0 \ +--alpha_to=3.2 \ +--beta_from=0.1 \ +--beta_to=0.45 \ +--cutoff_prob=1.0 \ +--cutoff_top_n=40 \ +--checkpoint_path ${1} + +if [ $? -ne 0 ]; then + echo "Failed in tuning!" + exit 1 +fi + + +exit 0 diff --git a/examples/aishell/path.sh b/examples/aishell/path.sh index fd1cebba8..a55139e11 100644 --- a/examples/aishell/path.sh +++ b/examples/aishell/path.sh @@ -6,3 +6,5 @@ export LC_ALL=C # Use UTF-8 in Python to avoid UnicodeDecodeError when LC_ALL=C export PYTHONIOENCODING=UTF-8 export PYTHONPATH=${MAIN_ROOT}:${PYTHONPATH} + +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/ diff --git a/examples/librispeech/path.sh b/examples/librispeech/path.sh index fd1cebba8..a55139e11 100644 --- a/examples/librispeech/path.sh +++ b/examples/librispeech/path.sh @@ -6,3 +6,5 @@ export LC_ALL=C # Use UTF-8 in Python to avoid UnicodeDecodeError when LC_ALL=C export PYTHONIOENCODING=UTF-8 export PYTHONPATH=${MAIN_ROOT}:${PYTHONPATH} + +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/ diff --git a/examples/tiny/path.sh b/examples/tiny/path.sh index fd1cebba8..a55139e11 100644 --- a/examples/tiny/path.sh +++ b/examples/tiny/path.sh @@ -6,3 +6,5 @@ export LC_ALL=C # Use UTF-8 in Python to avoid UnicodeDecodeError when LC_ALL=C export PYTHONIOENCODING=UTF-8 export PYTHONPATH=${MAIN_ROOT}:${PYTHONPATH} + +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/ diff --git a/model_utils/network.py b/model_utils/network.py index 0ceb11cce..b536865be 100644 --- a/model_utils/network.py +++ b/model_utils/network.py @@ -281,8 +281,8 @@ class GRUCellShare(nn.RNNCellBase): self.hidden_size = hidden_size self.input_size = input_size self._gate_activation = F.sigmoid - #self._activation = paddle.tanh - self._activation = F.relu + self._activation = paddle.tanh + #self._activation = F.relu def forward(self, inputs, states=None): if states is None: diff --git a/setup.sh b/setup.sh index 497749871..115ddcdc1 100644 --- a/setup.sh +++ b/setup.sh @@ -29,7 +29,7 @@ if [ $? != 0 ]; then fi tar -zxvf libsndfile-1.0.28.tar.gz cd libsndfile-1.0.28 - ./configure > /dev/null && make > /dev/null && make install > /dev/null + ./configure > /dev/null; make > /dev/null; make install > /dev/null cd .. rm -rf libsndfile-1.0.28 rm libsndfile-1.0.28.tar.gz diff --git a/network_test.py b/tests/network_test.py similarity index 98% rename from network_test.py rename to tests/network_test.py index beefbf7fb..ddd3991ed 100644 --- a/network_test.py +++ b/tests/network_test.py @@ -27,7 +27,7 @@ if __name__ == '__main__': text = np.array([[1, 2], [1, 2]], dtype='int32') text_len = np.array([2] * batch_size, dtype='int32') - place = paddle.CUDAPinnedPlace() + place = paddle.CUDAPlace(0) audio = paddle.to_tensor( audio, dtype='float32', place=place, stop_gradient=True) audio_len = paddle.to_tensor( diff --git a/tools/build_vocab.py b/tools/build_vocab.py index 2e47e84e5..5dc6f35bb 100644 --- a/tools/build_vocab.py +++ b/tools/build_vocab.py @@ -22,7 +22,6 @@ import codecs import json from collections import Counter import os.path -import _init_paths from data_utils.utility import read_manifest from utils.utility import add_arguments, print_arguments diff --git a/tools/compute_mean_std.py b/tools/compute_mean_std.py index d40739f32..e0245fc5b 100644 --- a/tools/compute_mean_std.py +++ b/tools/compute_mean_std.py @@ -15,7 +15,6 @@ import argparse import functools -import _init_paths from data_utils.normalizer import FeatureNormalizer from data_utils.augmentor.augmentation import AugmentationPipeline from data_utils.featurizer.audio_featurizer import AudioFeaturizer