From c38dc099d36fd593c0ff27e475014bf72a32c94e Mon Sep 17 00:00:00 2001 From: kdavis-mozilla Date: Thu, 11 Oct 2018 12:23:24 +0200 Subject: [PATCH] Fixed #1638 (Update Hyperparameters for 0.3.0) --- DeepSpeech.py | 2 +- bin/run-tc-ldc93s1_new.sh | 2 +- examples/vad_transcriber/wavTranscriber.py | 4 +-- native_client/client.cc | 2 +- native_client/javascript/client.js | 2 +- native_client/python/client.py | 2 +- tc-tests-utils.sh | 30 ++++++++++++---------- 7 files changed, 24 insertions(+), 20 deletions(-) diff --git a/DeepSpeech.py b/DeepSpeech.py index dd4ef113..c94868a5 100755 --- a/DeepSpeech.py +++ b/DeepSpeech.py @@ -162,7 +162,7 @@ def create_flags(): tf.app.flags.DEFINE_string ('lm_trie_path', 'data/lm/trie', 'path to the language model trie file created with native_client/generate_trie') tf.app.flags.DEFINE_integer ('beam_width', 1024, 'beam width used in the CTC decoder when building candidate transcriptions') tf.app.flags.DEFINE_float ('lm_weight', 1.50, 'the alpha hyperparameter of the CTC decoder. Language Model weight.') - tf.app.flags.DEFINE_float ('valid_word_count_weight', 2.25, 'valid word insertion weight. This is used to lessen the word insertion penalty when the inserted word is part of the vocabulary.') + tf.app.flags.DEFINE_float ('valid_word_count_weight', 2.10, 'valid word insertion weight. This is used to lessen the word insertion penalty when the inserted word is part of the vocabulary.') # Inference mode diff --git a/bin/run-tc-ldc93s1_new.sh b/bin/run-tc-ldc93s1_new.sh index 524c9f06..1aabd98d 100755 --- a/bin/run-tc-ldc93s1_new.sh +++ b/bin/run-tc-ldc93s1_new.sh @@ -14,7 +14,7 @@ python -u DeepSpeech.py \ --train_files ${ldc93s1_csv} --train_batch_size 1 \ --dev_files ${ldc93s1_csv} --dev_batch_size 1 \ --test_files ${ldc93s1_csv} --test_batch_size 1 \ - --n_hidden 494 --epoch 85 --random_seed 4567 --default_stddev 0.046875 \ + --n_hidden 494 --epoch 105 --random_seed 4567 --default_stddev 0.046875 \ --max_to_keep 1 --checkpoint_dir '/tmp/ckpt' --checkpoint_secs 0 \ --learning_rate 0.001 --dropout_rate 0.05 --export_dir '/tmp/train' \ --decoder_library_path '/tmp/ds/libctc_decoder_with_kenlm.so' \ diff --git a/examples/vad_transcriber/wavTranscriber.py b/examples/vad_transcriber/wavTranscriber.py index 5fdcb394..b3f0d272 100644 --- a/examples/vad_transcriber/wavTranscriber.py +++ b/examples/vad_transcriber/wavTranscriber.py @@ -19,8 +19,8 @@ def load_model(models, alphabet, lm, trie): N_FEATURES = 26 N_CONTEXT = 9 BEAM_WIDTH = 500 - LM_WEIGHT = 1.75 - VALID_WORD_COUNT_WEIGHT = 1.00 + LM_WEIGHT = 1.50 + VALID_WORD_COUNT_WEIGHT = 2.10 model_load_start = timer() ds = Model(models, N_FEATURES, N_CONTEXT, alphabet, BEAM_WIDTH) diff --git a/native_client/client.cc b/native_client/client.cc index b2cda25d..f6220140 100644 --- a/native_client/client.cc +++ b/native_client/client.cc @@ -23,7 +23,7 @@ #define N_CONTEXT 9 #define BEAM_WIDTH 500 #define LM_WEIGHT 1.50f -#define VALID_WORD_COUNT_WEIGHT 2.25f +#define VALID_WORD_COUNT_WEIGHT 2.10f typedef struct { const char* string; diff --git a/native_client/javascript/client.js b/native_client/javascript/client.js index 3f6c78ac..1e92379f 100644 --- a/native_client/javascript/client.js +++ b/native_client/javascript/client.js @@ -19,7 +19,7 @@ const LM_WEIGHT = 1.50; // Valid word insertion weight. This is used to lessen the word insertion penalty // when the inserted word is part of the vocabulary -const VALID_WORD_COUNT_WEIGHT = 2.25; +const VALID_WORD_COUNT_WEIGHT = 2.10; // These constants are tied to the shape of the graph used (changing them changes diff --git a/native_client/python/client.py b/native_client/python/client.py index 7becb3e0..60e8097c 100644 --- a/native_client/python/client.py +++ b/native_client/python/client.py @@ -27,7 +27,7 @@ LM_WEIGHT = 1.50 # Valid word insertion weight. This is used to lessen the word insertion penalty # when the inserted word is part of the vocabulary -VALID_WORD_COUNT_WEIGHT = 2.25 +VALID_WORD_COUNT_WEIGHT = 2.10 # These constants are tied to the shape of the graph used (changing them changes diff --git a/tc-tests-utils.sh b/tc-tests-utils.sh index 93a8fa0c..525e3683 100755 --- a/tc-tests-utils.sh +++ b/tc-tests-utils.sh @@ -135,26 +135,30 @@ assert_shows_something() assert_correct_ldc93s1() { - # FIXME: RE-ENABLE AFTER FIXING LM HYPERPARAMETERS - # assert_correct_inference "$1" "she had your dark suit in greasy wash water all year" - assert_working_inference "$1" "she had" + assert_correct_inference "$1" "she had your dark suit in greasy wash water all year" +} + +assert_correct_ldc93s1_lm() +{ + assert_correct_inference "$1" "she had your dark suit in greasy wash water all year" } assert_correct_multi_ldc93s1() { - # FIXME: RE-ENABLE AFTER FIXING LM HYPERPARAMETERS - #assert_shows_something "$1" "/LDC93S1.wav%she had your dark suit in greasy wash water all year%" - #assert_shows_something "$1" "/LDC93S1_pcms16le_2_44100.wav%she had your dark suit in greasy wash water all year%" - return 0 + assert_shows_something "$1" "/LDC93S1.wav%she had your dark suit in greasy wash water all year%" + assert_shows_something "$1" "/LDC93S1_pcms16le_2_44100.wav%she had your dark suit in greasy wash water all year%" ## 8k will output garbage anyway ... # assert_shows_something "$1" "/LDC93S1_pcms16le_1_8000.wav%she hayorasryrtl lyreasy asr watal w water all year%" } assert_correct_ldc93s1_prodmodel() { - # FIXME: RE-ENABLE AFTER FIXING LM HYPERPARAMETERS - #assert_correct_inference "$1" "she had tired or so and greasy wash war or year" - assert_working_inference "$1" "she had" + assert_correct_inference "$1" "she hadered or so and greasy wash war or year" +} + +assert_correct_ldc93s1_prodmodel_stereo_44k() +{ + assert_correct_inference "$1" "she had tered or so and greasy wash war or year" } assert_correct_warning_upsampling() @@ -185,13 +189,13 @@ run_all_inference_tests() assert_correct_ldc93s1 "${phrase_pbmodel_nolm}" phrase_pbmodel_withlm=$(deepspeech --model ${TASKCLUSTER_TMP_DIR}/${model_name_mmap} --alphabet ${TASKCLUSTER_TMP_DIR}/alphabet.txt --lm ${TASKCLUSTER_TMP_DIR}/lm.binary --trie ${TASKCLUSTER_TMP_DIR}/trie --audio ${TASKCLUSTER_TMP_DIR}/LDC93S1.wav) - assert_correct_ldc93s1 "${phrase_pbmodel_withlm}" + assert_correct_ldc93s1_lm "${phrase_pbmodel_withlm}" phrase_pbmodel_nolm_stereo_44k=$(deepspeech --model ${TASKCLUSTER_TMP_DIR}/${model_name_mmap} --alphabet ${TASKCLUSTER_TMP_DIR}/alphabet.txt --audio ${TASKCLUSTER_TMP_DIR}/LDC93S1_pcms16le_2_44100.wav) assert_correct_ldc93s1 "${phrase_pbmodel_nolm_stereo_44k}" phrase_pbmodel_withlm_stereo_44k=$(deepspeech --model ${TASKCLUSTER_TMP_DIR}/${model_name_mmap} --alphabet ${TASKCLUSTER_TMP_DIR}/alphabet.txt --lm ${TASKCLUSTER_TMP_DIR}/lm.binary --trie ${TASKCLUSTER_TMP_DIR}/trie --audio ${TASKCLUSTER_TMP_DIR}/LDC93S1_pcms16le_2_44100.wav) - assert_correct_ldc93s1 "${phrase_pbmodel_withlm_stereo_44k}" + assert_correct_ldc93s1_lm "${phrase_pbmodel_withlm_stereo_44k}" phrase_pbmodel_nolm_mono_8k=$(deepspeech --model ${TASKCLUSTER_TMP_DIR}/${model_name_mmap} --alphabet ${TASKCLUSTER_TMP_DIR}/alphabet.txt --audio ${TASKCLUSTER_TMP_DIR}/LDC93S1_pcms16le_1_8000.wav 2>&1 1>/dev/null) assert_correct_warning_upsampling "${phrase_pbmodel_nolm_mono_8k}" @@ -209,7 +213,7 @@ run_prod_inference_tests() assert_correct_ldc93s1_prodmodel "${phrase_pbmodel_withlm}" phrase_pbmodel_withlm_stereo_44k=$(deepspeech --model ${TASKCLUSTER_TMP_DIR}/${model_name_mmap} --alphabet ${TASKCLUSTER_TMP_DIR}/alphabet.txt --lm ${TASKCLUSTER_TMP_DIR}/lm.binary --trie ${TASKCLUSTER_TMP_DIR}/trie --audio ${TASKCLUSTER_TMP_DIR}/LDC93S1_pcms16le_2_44100.wav) - assert_correct_ldc93s1_prodmodel "${phrase_pbmodel_withlm_stereo_44k}" + assert_correct_ldc93s1_prodmodel_stereo_44k "${phrase_pbmodel_withlm_stereo_44k}" phrase_pbmodel_withlm_mono_8k=$(deepspeech --model ${TASKCLUSTER_TMP_DIR}/${model_name_mmap} --alphabet ${TASKCLUSTER_TMP_DIR}/alphabet.txt --lm ${TASKCLUSTER_TMP_DIR}/lm.binary --trie ${TASKCLUSTER_TMP_DIR}/trie --audio ${TASKCLUSTER_TMP_DIR}/LDC93S1_pcms16le_1_8000.wav 2>&1 1>/dev/null) assert_correct_warning_upsampling "${phrase_pbmodel_withlm_mono_8k}"