Retraining on my own data

Hi

I would like to retrain the pre-trained deepspeech model on my own data. How can a load the model into my python code, and use transfer learning on my own data. I have downloaded the pre-trained model, but I am not sure how to load the pb and pbmm model into my code, or how I can train the model from there. Thanks for any response.

Hi, you need to use the checkpoints.

You will need to add the flags for you new checkpoints and the source of the checkpoints of the trained model. Currently the transfer-learning branch is failing for me, it crashes due to something related to tflite, the branch transfer-learning2 is running for me.

Here’s an example of the command that you need to use:

My downloaded model directory does not have ckpt files. I only have binary, pb graph and pbmm graph. How can I get the ckpt file?

Also, how did you create the csv files? Did you make a collumn for the path to every audio file, or just to the audiofiles of the same class. My audiofiles of the same class does not save the same size. Should I resize them?

Please download the checkpoint tarball, not the models one.

!python3 -u DeepSpeech.py
–nofine_tune
–export_dir “/content/drive/My Drive/DeepSpeech/models_new”
–summary_dir “/content/drive/My Drive/DeepSpeech/summary_dir”
–checkpoint_dir “/content/drive/My Drive/DeepSpeech/destination_checkpoints”
–drop_source_layers 1
–source_model_checkpoint_dir “/content/drive/My Drive/DeepSpeech/source_checkpoints”
–n_hidden 2048
–epoch -25
–earlystop_nsteps 0.5
–train_batch_size 24
–dev_batch_size 48
–test_batch_size 48
–learning_rate 0.0001
–dropout_rate 0.2
–display_step 0
–validation_step 1
–summary_secs 60
–train_files “/content/drive/My Drive/DeepSpeech/models/train/train.csv”
–dev_files “/content/drive/My Drive/DeepSpeech/models/dev/dev.csv”
–test_files “/content/drive/My Drive/DeepSpeech/models/test/test.csv”
–alphabet_config_path “/content/drive/My Drive/DeepSpeech/models/alphabet.txt”
–lm_binary_path “/content/drive/My Drive/DeepSpeech/models/lm.binary”
–lm_trie_path “/content/drive/My Drive/DeepSpeech/models/trie”

sir,
I have run the following command but the epoch is starting from 0 and also, there are 198 wav files in my train directory but the output is showing that it is processing on 8 files only

here is my output-

WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/data/ops/dataset_ops.py:429: py_func (from tensorflow.python.ops.script_ops) is deprecated and will be removed in a future version.
Instructions for updating:
tf.py_func is deprecated in TF V2. Instead, use
tf.py_function, which takes a python function which manipulates tf eager
tensors instead of numpy arrays. It’s easy to convert a tf eager tensor to
an ndarray (just call tensor.numpy()) but having access to eager tensors
means tf.py_functions can use accelerators such as GPUs as well as
being differentiable using a gradient tape.

WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/data/ops/iterator_ops.py:358: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/contrib/rnn/python/ops/lstm_ops.py:696: to_int64 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
I Initializing variables…
I STARTING Optimization
I Training epoch 0…
100% (8 of 8) |###########################| Elapsed Time: 0:00:26 Time: 0:00:26
I Finished training epoch 0 - loss: 331.999172
I Validating epoch 0…
100% (1 of 1) |###########################| Elapsed Time: 0:00:02 Time: 0:00:02
I Finished validating epoch 0 - loss: 270.261383
I Saved new best validating model with loss 270.261383 to: /content/drive/My Drive/DeepSpeech/destination_checkpoints/best_dev-8
I Training epoch 1…
100% (8 of 8) |###########################| Elapsed Time: 0:00:26 Time: 0:00:26
I Finished training epoch 1 - loss: 276.995941
I Validating epoch 1…
100% (1 of 1) |###########################| Elapsed Time: 0:00:02 Time: 0:00:02
I Finished validating epoch 1 - loss: 265.541168
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/training/saver.py:966: remove_checkpoint (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.
Instructions for updating:
Use standard file APIs to delete files with this prefix.
I Saved new best validating model with loss 265.541168 to: /content/drive/My Drive/DeepSpeech/destination_checkpoints/best_dev-16
I Training epoch 2…
100% (8 of 8) |###########################| Elapsed Time: 0:00:26 Time: 0:00:26
I Finished training epoch 2 - loss: 272.432255
I Validating epoch 2…
100% (1 of 1) |###########################| Elapsed Time: 0:00:02 Time: 0:00:02
I Finished validating epoch 2 - loss: 263.560822
I Saved new best validating model with loss 263.560822 to: /content/drive/My Drive/DeepSpeech/destination_checkpoints/best_dev-24
I Training epoch 3…
100% (8 of 8) |###########################| Elapsed Time: 0:00:26 Time: 0:00:26
I Finished training epoch 3 - loss: 270.764479
I Validating epoch 3…
100% (1 of 1) |###########################| Elapsed Time: 0:00:02 Time: 0:00:02
I Finished validating epoch 3 - loss: 262.600586
I Saved new best validating model with loss 262.600586 to: /content/drive/My Drive/DeepSpeech/destination_checkpoints/best_dev-32
I Training epoch 4…
62% (5 of 8) |################ | Elapsed Time: 0:00:11 ETA: 0:00:09

Did you checkout transfer-learning2 branch? And the 8 are correct, it matches your batch size.

Sir, can you please share the link of transfer learning 2 branch
i think i have used https://github.com/mozilla/DeepSpeech/tree/transfer-learning branch

https://github.com/mozilla/DeepSpeech/tree/transfer-learning2

Okei, but how do I correctly create the csv file for my training and testing data? Do you have an example?

Hi

I too wants to retrain to model on Indian accent data set. For that purpose i am collecting data. Could you please tell me how much data would be enough for that?