ValueError: Cannot feed value of shape (29,) for Tensor 'layer_6/bias/Initializer/zeros:0', which has shape '(32,)'

Hello,

I want to start my DeepSpeech.py as root with:

python3 DeepSpeech.py --train_files /media/sf_de/clips/train.csv --dev_files /media/sf_de/clips/dev.csv --test_files /media/sf_de/clips/test.csv

but I got this error:

ValueError: Cannot feed value of shape (29,) for Tensor ‘layer_6/bias/Initializer/zeros:0’, which has shape ‘(32,)’

Did you have some ideas how iI can solve this problem?

It’s never a good idea to run as root, there is no legitimate reason to do that. Please avoid this habit.

Can you describe what you are doing? DeepSpeech training version? Dataset? Have you read the documentation?

this is symptom of:

  • previous checkpoint being loaded
  • different alphabet in the current run than in checkpoint
1 Like

I know, but I had some problems with permissions and I used it in a VM, so there is no security risk.

I had install install Deepspeech, like in this documentation: https://deepspeech.readthedocs.io/en/v0.7.4/?badge=latest

I use DeepSpeech version 7.4.0.

I use this german Dataset:

I had import the Dataset one time again. But with my edited aphabet, which contains (ä,ü,ö), that was my mistake.
I had found that by testing different alphabet’s. And I found out that (32,) is the number of letters in my edited alphabet version and (29,) the nummber of letters in the standard version.
And I haven’t had this Error again, but then came this Error:
ValueError: Alphabet cannot encode transcript “ich hoffe es” while processing sample “/media/sf_de/clips/common_voice_de_21632146.wav”, check that your alphabet contains all characters in the training corpus. Missing characters are: [’ ', ’ '].

But thanks for helping @lissyx!

And yet your command line does not show any specific alphabet being passed, which is consistent with your error.

The reason I’m asking is because obviously there is something wrong, so just telling us “I followed that doc” does not really help: we know the doc. Maybe you did something else, prior.

Like, have you checked what I said, about a prior checkpoint being reloaded automatically and that would have been produced with a different alphabet than yours?

Hello @lissyx,
thanks for the quick answer.

I had saved the new alphabet to the same path like the old one was saved.
So I don’t had to add the “–alphabet_config_path” arrgument.

Yes, I understand your point.

I had remove all checkpoints in $USER/.local/share/deepspeech/checkpoints/.
Is there another path where they are stored, or do I need to enter any command to check this?

Do you mean you just did, or you did that prior to the error ?

That depends if you pass a specific checkpoint dir.

Hi again @lissyx,

I did it naturally before the error, when testing.

No, I have not set a specific checkpoint memory point.
I have also adopted the standard setting here.

Did you have an other idea?

No. There’s something that still refers to default english alphabet with 29 chars …

We really cannot help more without more full context, the error is very likely on your side, unfortunately.

Sorry @lissyx,
I think I expressed myself wrong, I solved the error with (29,) and (32,) by replacing the English alphabet with the German one when importing.

Now I stuck with this Error:

But I think for this I should open a new discussion. Right?

Thanks for helping.

Ok, I was mislead and thought you still had the error

Well, it looks like your alphabet does not match what you have in your data, you need to fix that as well. Likely you have some UTF-8 non breaking space?

Hello @lissyx

I’dont know what was wrong, but now I had used check_characters.py from deepspeech 0.6.1 and compared that to my alphabet. It looks same. I do Copy&Paste and now it works. Maybe you were right. :slight_smile:

Thank you very much.

I am also facing the same error related to outer layer shape mismatch.
This is the way I am trying to replace the hindi alphabet file with the english one and provide pre-trained deepspeech model for initialisation.

python DeepSpeech.py \
    --drop_source_layers 1\
    --alphabet_config_path /home/ubuntu/nitin/workspace/content/DeepSpeech/data/alphabet_hin.txt \
    --save_checkpoint_dir /home/ubuntu/nitin/workspace/content/DeepSpeech/checkpoints/hindi_base_model \
    --load_checkpoint_dir /home/ubuntu/nitin/workspace/content/model_checkpoints/deepspeech-0.8.2-checkpoint \

Am I doing something wrong here?

You don’t give much information, but it says above that you can’t change the alphabet for a trained model. I guess you did change that? Hard to tell without the error msg and some more info.