From 525c1ea277101a03c716036c3c755114889a1ac6 Mon Sep 17 00:00:00 2001 From: yaozengwei Date: Fri, 27 May 2022 18:07:07 +0800 Subject: [PATCH 1/9] update RESULT.md about pruned_transducer_stateless4 --- egs/librispeech/ASR/RESULTS.md | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/egs/librispeech/ASR/RESULTS.md b/egs/librispeech/ASR/RESULTS.md index 453751ba57..4a8e036433 100644 --- a/egs/librispeech/ASR/RESULTS.md +++ b/egs/librispeech/ASR/RESULTS.md @@ -193,6 +193,86 @@ You can find a pretrained model, training logs, decoding logs, and decoding results at: + +### LibriSpeech BPE training results (Pruned Transducer 4) + +[pruned_transducer_stateless4](./pruned_transducer_stateless4) +This version saves averaged model during training, and decodes with averaged model. +See for details about the idea of model averaging. + +#### Training on full librispeech + +See + +Using commit `ec0b0e92297cc03fdb09f48cd235e84d2c04156b`. + +The WERs are: + +| | test-clean | test-other | comment | +|-------------------------------------|------------|------------|-------------------------------------------------------------------------------| +| greedy search (max sym per frame 1) | 2.77 | 6.78 | --epoch 30 --avg 5 --use_averaged_model False | +| greedy search (max sym per frame 1) | 2.72 | 6.67 | --epoch 30 --avg 5 --use_averaged_model True | +| greedy search (max sym per frame 1) | 2.78 | 6.68 | --epoch 30 --avg 10 --use_averaged_model False | +| greedy search (max sym per frame 1) | 2.74 | 6.67 | --epoch 30 --avg 10 --use_averaged_model True | +| fast beam search | 2.73 | 6.65 | --epoch 30 --avg 5 --use_averaged_model False | +| fast beam search | 2.69 | 6.61 | --epoch 30 --avg 5 --use_averaged_model True | +| fast beam search | 2.68 | 6.61 | --epoch 30 --avg 10 --use_averaged_model False | +| fast beam search | 2.7 | 6.57 | --epoch 30 --avg 10 --use_averaged_model True | +| modified beam search | 2.71 | 6.69 | --epoch 30 --avg 5 --use_averaged_model False | +| modified beam search | 2.65 | 6.6 | --epoch 30 --avg 5 --use_averaged_model True | +| modified beam search | 2.69 | 6.61 | --epoch 30 --avg 10 --use_averaged_model False | +| modified beam search | 2.68 | 6.56 | --epoch 30 --avg 10 --use_averaged_model True | + +The training command is: + +./pruned_transducer_stateless4/train.py \ + --world-size 6 \ + --num-epochs 30 \ + --start-epoch 1 \ + --exp-dir pruned_transducer_stateless4/exp \ + --full-libri 1 \ + --max-duration 300 \ + --save-every-n 8000 \ + --keep-last-k 20 \ + --average-period 100 + +#### Training on train-clean-100 + +See + +Using commit `ec0b0e92297cc03fdb09f48cd235e84d2c04156b`. + +The WERs are: + +| | test-clean | test-other | comment | +|-------------------------------------|------------|------------|-------------------------------------------------------------------------------| +| greedy search (max sym per frame 1) | 7.13 | 19.31 | --epoch 30 --avg 5 --use_averaged_model False | +| greedy search (max sym per frame 1) | 7.03 | 18.84 | --epoch 30 --avg 5 --use_averaged_model True | +| greedy search (max sym per frame 1) | 7.0 | 18.95 | --epoch 30 --avg 10 --use_averaged_model False | +| greedy search (max sym per frame 1) | 6.92 | 18.65 | --epoch 30 --avg 10 --use_averaged_model True | +| fast beam search | 6.96 | 18.78 | --epoch 30 --avg 5 --use_averaged_model False | +| fast beam search | 6.88 | 18.43 | --epoch 30 --avg 5 --use_averaged_model True | +| fast beam search | 6.82 | 18.47 | --epoch 30 --avg 10 --use_averaged_model False | +| fast beam search | 6.74 | 18.2 | --epoch 30 --avg 10 --use_averaged_model True | +| modified beam search | 6.86 | 18.76 | --epoch 30 --avg 5 --use_averaged_model False | +| modified beam search | 6.83 | 18.31 | --epoch 30 --avg 5 --use_averaged_model True | +| modified beam search | 6.74 | 18.39 | --epoch 30 --avg 10 --use_averaged_model False | +| modified beam search | 6.74 | 18.12 | --epoch 30 --avg 10 --use_averaged_model True | + +The training command is: + +./pruned_transducer_stateless4/train.py \ + --world-size 3 \ + --num-epochs 30 \ + --start-epoch 1 \ + --exp-dir pruned_transducer_stateless4/exp \ + --full-libri 0 \ + --max-duration 300 \ + --save-every-n 8000 \ + --keep-last-k 20 \ + --average-period 100 + + ### LibriSpeech BPE training results (Pruned Stateless Transducer 3, 2022-04-29) [pruned_transducer_stateless3](./pruned_transducer_stateless3) From 9bc7c313500bd36d7cb3caf095f063e934db6b12 Mon Sep 17 00:00:00 2001 From: Zengwei Yao Date: Fri, 27 May 2022 18:13:37 +0800 Subject: [PATCH 2/9] Update RESULT.md This PR is only to update RESULT.md about pruned_transducer_stateless4. --- egs/librispeech/ASR/RESULTS.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/egs/librispeech/ASR/RESULTS.md b/egs/librispeech/ASR/RESULTS.md index 4a8e036433..38e9717c51 100644 --- a/egs/librispeech/ASR/RESULTS.md +++ b/egs/librispeech/ASR/RESULTS.md @@ -194,10 +194,12 @@ results at: -### LibriSpeech BPE training results (Pruned Transducer 4) +### LibriSpeech BPE training results (Pruned Stateless Transducer 4) [pruned_transducer_stateless4](./pruned_transducer_stateless4) + This version saves averaged model during training, and decodes with averaged model. + See for details about the idea of model averaging. #### Training on full librispeech @@ -225,6 +227,7 @@ The WERs are: The training command is: +```bash ./pruned_transducer_stateless4/train.py \ --world-size 6 \ --num-epochs 30 \ @@ -235,6 +238,7 @@ The training command is: --save-every-n 8000 \ --keep-last-k 20 \ --average-period 100 +``` #### Training on train-clean-100 @@ -261,6 +265,7 @@ The WERs are: The training command is: +```bash ./pruned_transducer_stateless4/train.py \ --world-size 3 \ --num-epochs 30 \ @@ -271,7 +276,7 @@ The training command is: --save-every-n 8000 \ --keep-last-k 20 \ --average-period 100 - +``` ### LibriSpeech BPE training results (Pruned Stateless Transducer 3, 2022-04-29) From bc659d5dcfbaa4b07fc00684510b2725f8613b8e Mon Sep 17 00:00:00 2001 From: yaozengwei Date: Fri, 27 May 2022 18:17:26 +0800 Subject: [PATCH 3/9] set default value of --use-averaged-model to True --- egs/librispeech/ASR/pruned_transducer_stateless4/decode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egs/librispeech/ASR/pruned_transducer_stateless4/decode.py b/egs/librispeech/ASR/pruned_transducer_stateless4/decode.py index d1af63aaa8..70afc3ea32 100755 --- a/egs/librispeech/ASR/pruned_transducer_stateless4/decode.py +++ b/egs/librispeech/ASR/pruned_transducer_stateless4/decode.py @@ -128,7 +128,7 @@ def get_parser(): parser.add_argument( "--use-averaged-model", type=str2bool, - default=False, + default=True, help="Whether to load averaged model. Currently it only supports " "using --epoch. If True, it would decode with the averaged model " "over the epoch range from `epoch-avg` (excluded) to `epoch`." From a6ca4d283a5636bf3ea06acaebbe3f776bbf3ca2 Mon Sep 17 00:00:00 2001 From: yaozengwei Date: Sat, 28 May 2022 14:02:26 +0800 Subject: [PATCH 4/9] update RESULTS.md and add decode command --- egs/librispeech/ASR/RESULTS.md | 61 ++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/egs/librispeech/ASR/RESULTS.md b/egs/librispeech/ASR/RESULTS.md index 38e9717c51..e30acfc664 100644 --- a/egs/librispeech/ASR/RESULTS.md +++ b/egs/librispeech/ASR/RESULTS.md @@ -212,18 +212,12 @@ The WERs are: | | test-clean | test-other | comment | |-------------------------------------|------------|------------|-------------------------------------------------------------------------------| -| greedy search (max sym per frame 1) | 2.77 | 6.78 | --epoch 30 --avg 5 --use_averaged_model False | -| greedy search (max sym per frame 1) | 2.72 | 6.67 | --epoch 30 --avg 5 --use_averaged_model True | -| greedy search (max sym per frame 1) | 2.78 | 6.68 | --epoch 30 --avg 10 --use_averaged_model False | -| greedy search (max sym per frame 1) | 2.74 | 6.67 | --epoch 30 --avg 10 --use_averaged_model True | -| fast beam search | 2.73 | 6.65 | --epoch 30 --avg 5 --use_averaged_model False | -| fast beam search | 2.69 | 6.61 | --epoch 30 --avg 5 --use_averaged_model True | -| fast beam search | 2.68 | 6.61 | --epoch 30 --avg 10 --use_averaged_model False | -| fast beam search | 2.7 | 6.57 | --epoch 30 --avg 10 --use_averaged_model True | -| modified beam search | 2.71 | 6.69 | --epoch 30 --avg 5 --use_averaged_model False | -| modified beam search | 2.65 | 6.6 | --epoch 30 --avg 5 --use_averaged_model True | -| modified beam search | 2.69 | 6.61 | --epoch 30 --avg 10 --use_averaged_model False | -| modified beam search | 2.68 | 6.56 | --epoch 30 --avg 10 --use_averaged_model True | +| greedy search (max sym per frame 1) | 2.75 | 6.74 | --epoch 29 --avg 6 --use_averaged_model False | +| greedy search (max sym per frame 1) | 2.69 | 6.64 | --epoch 29 --avg 6 --use_averaged_model True | +| fast beam search | 2.72 | 6.67 | --epoch 29 --avg 6 --use_averaged_model False | +| fast beam search | 2.66 | 6.6 | --epoch 29 --avg 6 --use_averaged_model True | +| modified beam search | 2.67 | 6.68 | --epoch 29 --avg 6 --use_averaged_model False | +| modified beam search | 2.62 | 6.57 | --epoch 29 --avg 6 --use_averaged_model True | The training command is: @@ -240,6 +234,43 @@ The training command is: --average-period 100 ``` +The decoding command using greedy search is: +```bash +./pruned_transducer_stateless4/decode.py \ + --epoch 29 \ + --avg 6 \ + --exp-dir pruned_transducer_stateless4/exp \ + --max-duration 300 \ + --decoding-method greedy_search \ + --use-averaged-model True +``` + +The decoding command using fast beam search is: +```bash +./pruned_transducer_stateless4/decode.py \ + --epoch 29 \ + --avg 6 \ + --exp-dir pruned_transducer_stateless4/exp \ + --max-duration 300 \ + --decoding-method fast_beam_search \ + --use-averaged-model True \ + --beam 4 \ + --max-contexts 4 \ + --max-states 8 +``` + +The decoding command using modified beam search is: +```bash +./pruned_transducer_stateless4/decode.py \ + --epoch 29 \ + --avg 6 \ + --exp-dir pruned_transducer_stateless4/exp \ + --max-duration 300 \ + --decoding-method modified_beam_search \ + --use-averaged-model True \ + --beam-size 4 +``` + #### Training on train-clean-100 See @@ -250,16 +281,10 @@ The WERs are: | | test-clean | test-other | comment | |-------------------------------------|------------|------------|-------------------------------------------------------------------------------| -| greedy search (max sym per frame 1) | 7.13 | 19.31 | --epoch 30 --avg 5 --use_averaged_model False | -| greedy search (max sym per frame 1) | 7.03 | 18.84 | --epoch 30 --avg 5 --use_averaged_model True | | greedy search (max sym per frame 1) | 7.0 | 18.95 | --epoch 30 --avg 10 --use_averaged_model False | | greedy search (max sym per frame 1) | 6.92 | 18.65 | --epoch 30 --avg 10 --use_averaged_model True | -| fast beam search | 6.96 | 18.78 | --epoch 30 --avg 5 --use_averaged_model False | -| fast beam search | 6.88 | 18.43 | --epoch 30 --avg 5 --use_averaged_model True | | fast beam search | 6.82 | 18.47 | --epoch 30 --avg 10 --use_averaged_model False | | fast beam search | 6.74 | 18.2 | --epoch 30 --avg 10 --use_averaged_model True | -| modified beam search | 6.86 | 18.76 | --epoch 30 --avg 5 --use_averaged_model False | -| modified beam search | 6.83 | 18.31 | --epoch 30 --avg 5 --use_averaged_model True | | modified beam search | 6.74 | 18.39 | --epoch 30 --avg 10 --use_averaged_model False | | modified beam search | 6.74 | 18.12 | --epoch 30 --avg 10 --use_averaged_model True | From cebadffc9dbb361c03c99d7a793985ef4e9e3466 Mon Sep 17 00:00:00 2001 From: yaozengwei Date: Sat, 28 May 2022 14:06:24 +0800 Subject: [PATCH 5/9] minor fix --- egs/librispeech/ASR/RESULTS.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/egs/librispeech/ASR/RESULTS.md b/egs/librispeech/ASR/RESULTS.md index e30acfc664..1b03d7de5f 100644 --- a/egs/librispeech/ASR/RESULTS.md +++ b/egs/librispeech/ASR/RESULTS.md @@ -212,12 +212,12 @@ The WERs are: | | test-clean | test-other | comment | |-------------------------------------|------------|------------|-------------------------------------------------------------------------------| -| greedy search (max sym per frame 1) | 2.75 | 6.74 | --epoch 29 --avg 6 --use_averaged_model False | -| greedy search (max sym per frame 1) | 2.69 | 6.64 | --epoch 29 --avg 6 --use_averaged_model True | -| fast beam search | 2.72 | 6.67 | --epoch 29 --avg 6 --use_averaged_model False | -| fast beam search | 2.66 | 6.6 | --epoch 29 --avg 6 --use_averaged_model True | -| modified beam search | 2.67 | 6.68 | --epoch 29 --avg 6 --use_averaged_model False | -| modified beam search | 2.62 | 6.57 | --epoch 29 --avg 6 --use_averaged_model True | +| greedy search (max sym per frame 1) | 2.75 | 6.74 | --epoch 30 --avg 6 --use_averaged_model False | +| greedy search (max sym per frame 1) | 2.69 | 6.64 | --epoch 30 --avg 6 --use_averaged_model True | +| fast beam search | 2.72 | 6.67 | --epoch 30 --avg 6 --use_averaged_model False | +| fast beam search | 2.66 | 6.6 | --epoch 30 --avg 6 --use_averaged_model True | +| modified beam search | 2.67 | 6.68 | --epoch 30 --avg 6 --use_averaged_model False | +| modified beam search | 2.62 | 6.57 | --epoch 30 --avg 6 --use_averaged_model True | The training command is: @@ -237,7 +237,7 @@ The training command is: The decoding command using greedy search is: ```bash ./pruned_transducer_stateless4/decode.py \ - --epoch 29 \ + --epoch 30 \ --avg 6 \ --exp-dir pruned_transducer_stateless4/exp \ --max-duration 300 \ @@ -248,7 +248,7 @@ The decoding command using greedy search is: The decoding command using fast beam search is: ```bash ./pruned_transducer_stateless4/decode.py \ - --epoch 29 \ + --epoch 30 \ --avg 6 \ --exp-dir pruned_transducer_stateless4/exp \ --max-duration 300 \ @@ -262,7 +262,7 @@ The decoding command using fast beam search is: The decoding command using modified beam search is: ```bash ./pruned_transducer_stateless4/decode.py \ - --epoch 29 \ + --epoch 30 \ --avg 6 \ --exp-dir pruned_transducer_stateless4/exp \ --max-duration 300 \ From ab86e441cee705dc2a131089db9c6409c53af12d Mon Sep 17 00:00:00 2001 From: yaozengwei Date: Sat, 4 Jun 2022 12:51:33 +0800 Subject: [PATCH 6/9] update export.py --- .../pruned_transducer_stateless4/export.py | 274 +++++++++++++++++- 1 file changed, 273 insertions(+), 1 deletion(-) mode change 120000 => 100755 egs/librispeech/ASR/pruned_transducer_stateless4/export.py diff --git a/egs/librispeech/ASR/pruned_transducer_stateless4/export.py b/egs/librispeech/ASR/pruned_transducer_stateless4/export.py deleted file mode 120000 index 19c56a722d..0000000000 --- a/egs/librispeech/ASR/pruned_transducer_stateless4/export.py +++ /dev/null @@ -1 +0,0 @@ -../pruned_transducer_stateless2/export.py \ No newline at end of file diff --git a/egs/librispeech/ASR/pruned_transducer_stateless4/export.py b/egs/librispeech/ASR/pruned_transducer_stateless4/export.py new file mode 100755 index 0000000000..8636bf634a --- /dev/null +++ b/egs/librispeech/ASR/pruned_transducer_stateless4/export.py @@ -0,0 +1,273 @@ +#!/usr/bin/env python3 +# +# Copyright 2021 Xiaomi Corporation (Author: Fangjun Kuang) +# +# See ../../../../LICENSE for clarification regarding multiple authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This script converts several saved checkpoints +# to a single one using model averaging. +""" +Usage: +./pruned_transducer_stateless4/export.py \ + --exp-dir ./pruned_transducer_stateless4/exp \ + --bpe-model data/lang_bpe_500/bpe.model \ + --epoch 20 \ + --avg 10 + +It will generate a file exp_dir/pretrained.pt + +To use the generated file with `pruned_transducer_stateless2/decode.py`, +you can do: + + cd /path/to/exp_dir + ln -s pretrained.pt epoch-9999.pt + + cd /path/to/egs/librispeech/ASR + ./pruned_transducer_stateless4/decode.py \ + --exp-dir ./pruned_transducer_stateless4/exp \ + --epoch 9999 \ + --avg 1 \ + --max-duration 100 \ + --bpe-model data/lang_bpe_500/bpe.model \ + --use-averaged-model False +""" + +import argparse +import logging +from pathlib import Path + +import sentencepiece as spm +import torch +from train import get_params, get_transducer_model + +from icefall.checkpoint import ( + average_checkpoints, + average_checkpoints_with_averaged_model, + find_checkpoints, + load_checkpoint, +) +from icefall.utils import str2bool + + +def get_parser(): + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter + ) + + parser.add_argument( + "--epoch", + type=int, + default=28, + help="""It specifies the checkpoint to use for averaging. + Note: Epoch counts from 0. + You can specify --avg to use more checkpoints for model averaging.""", + ) + + parser.add_argument( + "--iter", + type=int, + default=0, + help="""If positive, --epoch is ignored and it + will use the checkpoint exp_dir/checkpoint-iter.pt. + You can specify --avg to use more checkpoints for model averaging. + """, + ) + + parser.add_argument( + "--avg", + type=int, + default=15, + help="Number of checkpoints to average. Automatically select " + "consecutive checkpoints before the checkpoint specified by " + "'--epoch' and '--iter'", + ) + + parser.add_argument( + "--exp-dir", + type=str, + default="pruned_transducer_stateless2/exp", + help="""It specifies the directory where all training related + files, e.g., checkpoints, log, etc, are saved + """, + ) + + parser.add_argument( + "--bpe-model", + type=str, + default="data/lang_bpe_500/bpe.model", + help="Path to the BPE model", + ) + + parser.add_argument( + "--jit", + type=str2bool, + default=False, + help="""True to save a model after applying torch.jit.script. + """, + ) + + parser.add_argument( + "--context-size", + type=int, + default=2, + help="The context size in the decoder. 1 means bigram; " + "2 means tri-gram", + ) + + parser.add_argument( + "--use-averaged-model", + type=str2bool, + default=True, + help="Whether to load averaged model. Currently it only supports " + "using --epoch. If True, it would decode with the averaged model " + "over the epoch range from `epoch-avg` (excluded) to `epoch`." + "Actually only the models with epoch number of `epoch-avg` and " + "`epoch` are loaded for averaging. ", + ) + + return parser + + +def main(): + args = get_parser().parse_args() + args.exp_dir = Path(args.exp_dir) + + params = get_params() + params.update(vars(args)) + + device = torch.device("cpu") + + logging.info(f"device: {device}") + + sp = spm.SentencePieceProcessor() + sp.load(params.bpe_model) + + # is defined in local/train_bpe_model.py + params.blank_id = sp.piece_to_id("") + params.vocab_size = sp.get_piece_size() + + logging.info(params) + + logging.info("About to create model") + model = get_transducer_model(params) + + model.to(device) + + if not params.use_averaged_model: + if params.iter > 0: + filenames = find_checkpoints( + params.exp_dir, iteration=-params.iter + )[: params.avg] + if len(filenames) == 0: + raise ValueError( + f"No checkpoints found for" + f" --iter {params.iter}, --avg {params.avg}" + ) + elif len(filenames) < params.avg: + raise ValueError( + f"Not enough checkpoints ({len(filenames)}) found for" + f" --iter {params.iter}, --avg {params.avg}" + ) + logging.info(f"averaging {filenames}") + model.to(device) + model.load_state_dict(average_checkpoints(filenames, device=device)) + elif params.avg == 1: + load_checkpoint(f"{params.exp_dir}/epoch-{params.epoch}.pt", model) + else: + start = params.epoch - params.avg + 1 + filenames = [] + for i in range(start, params.epoch + 1): + if i >= 1: + filenames.append(f"{params.exp_dir}/epoch-{i}.pt") + logging.info(f"averaging {filenames}") + model.to(device) + model.load_state_dict(average_checkpoints(filenames, device=device)) + else: + if params.iter > 0: + filenames = find_checkpoints( + params.exp_dir, iteration=-params.iter + )[: params.avg + 1] + if len(filenames) == 0: + raise ValueError( + f"No checkpoints found for" + f" --iter {params.iter}, --avg {params.avg}" + ) + elif len(filenames) < params.avg + 1: + raise ValueError( + f"Not enough checkpoints ({len(filenames)}) found for" + f" --iter {params.iter}, --avg {params.avg}" + ) + filename_start = filenames[-1] + filename_end = filenames[0] + logging.info( + "Calculating the averaged model over iteration checkpoints" + f" from {filename_start} (excluded) to {filename_end}" + ) + model.to(device) + model.load_state_dict( + average_checkpoints_with_averaged_model( + filename_start=filename_start, + filename_end=filename_end, + device=device, + ) + ) + else: + assert params.avg > 0, params.avg + start = params.epoch - params.avg + assert start >= 1, start + filename_start = f"{params.exp_dir}/epoch-{start}.pt" + filename_end = f"{params.exp_dir}/epoch-{params.epoch}.pt" + logging.info( + f"Calculating the averaged model over epoch range from " + f"{start} (excluded) to {params.epoch}" + ) + model.to(device) + model.load_state_dict( + average_checkpoints_with_averaged_model( + filename_start=filename_start, + filename_end=filename_end, + device=device, + ) + ) + + model.eval() + + if params.jit: + # We won't use the forward() method of the model in C++, so just ignore + # it here. + # Otherwise, one of its arguments is a ragged tensor and is not + # torch scriptabe. + model.__class__.forward = torch.jit.ignore(model.__class__.forward) + logging.info("Using torch.jit.script") + model = torch.jit.script(model) + filename = params.exp_dir / "cpu_jit.pt" + model.save(str(filename)) + logging.info(f"Saved to {filename}") + else: + logging.info("Not using torch.jit.script") + # Save it using a format so that it can be loaded + # by :func:`load_checkpoint` + filename = params.exp_dir / "pretrained.pt" + torch.save({"model": model.state_dict()}, str(filename)) + logging.info(f"Saved to {filename}") + + +if __name__ == "__main__": + formatter = ( + "%(asctime)s %(levelname)s [%(filename)s:%(lineno)d] %(message)s" + ) + + logging.basicConfig(format=formatter, level=logging.INFO) + main() From 26b358a9eafa2b06722984fafd9b1f3e62592a42 Mon Sep 17 00:00:00 2001 From: yaozengwei Date: Sat, 4 Jun 2022 13:04:03 +0800 Subject: [PATCH 7/9] add uploaded files links --- egs/librispeech/ASR/RESULTS.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/egs/librispeech/ASR/RESULTS.md b/egs/librispeech/ASR/RESULTS.md index 1b03d7de5f..7903df42e0 100644 --- a/egs/librispeech/ASR/RESULTS.md +++ b/egs/librispeech/ASR/RESULTS.md @@ -234,6 +234,9 @@ The training command is: --average-period 100 ``` +The tensorboard log can be found at + + The decoding command using greedy search is: ```bash ./pruned_transducer_stateless4/decode.py \ @@ -271,6 +274,10 @@ The decoding command using modified beam search is: --beam-size 4 ``` +Pretrained models, training logs, decoding logs, and decoding results +are available at + + #### Training on train-clean-100 See From 0baf4981d54aab2ff74f852511e4d6c13ff7b364 Mon Sep 17 00:00:00 2001 From: yaozengwei Date: Sat, 4 Jun 2022 13:17:26 +0800 Subject: [PATCH 8/9] update link --- egs/librispeech/ASR/RESULTS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/egs/librispeech/ASR/RESULTS.md b/egs/librispeech/ASR/RESULTS.md index 7903df42e0..d92077fdd5 100644 --- a/egs/librispeech/ASR/RESULTS.md +++ b/egs/librispeech/ASR/RESULTS.md @@ -310,6 +310,9 @@ The training command is: --average-period 100 ``` +The tensorboard log can be found at + + ### LibriSpeech BPE training results (Pruned Stateless Transducer 3, 2022-04-29) [pruned_transducer_stateless3](./pruned_transducer_stateless3) From 0177918f41dd3f47989c877a695ab7eea8f87166 Mon Sep 17 00:00:00 2001 From: yaozengwei Date: Sat, 4 Jun 2022 13:33:46 +0800 Subject: [PATCH 9/9] fix typos --- egs/librispeech/ASR/pruned_transducer_stateless4/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egs/librispeech/ASR/pruned_transducer_stateless4/export.py b/egs/librispeech/ASR/pruned_transducer_stateless4/export.py index 8636bf634a..8f64b5d64e 100755 --- a/egs/librispeech/ASR/pruned_transducer_stateless4/export.py +++ b/egs/librispeech/ASR/pruned_transducer_stateless4/export.py @@ -28,7 +28,7 @@ It will generate a file exp_dir/pretrained.pt -To use the generated file with `pruned_transducer_stateless2/decode.py`, +To use the generated file with `pruned_transducer_stateless4/decode.py`, you can do: cd /path/to/exp_dir