DeepSpeech icon indicating copy to clipboard operation
DeepSpeech copied to clipboard

Assign requires shapes of both tensors to match. lhs shape= [2048,29] rhs shape= [494,29]

Open crs117 opened this issue 9 years ago • 12 comments

I am new to this. I am trying to run the librivox script and am keep getting this error. I see that 494 is defined from shapes=[[None, numcep + (2 * numcep * numcontext)], [], [None, ], []] given numcep = 26 and numcontext = 9 (from debug session).

from documentation:

"Given a WAV audio file at audio_filename, calculates numcep MFCC features at every 0.01s time step with a window length of 0.025s. Appends numcontext context frames to the left and right of each time step, and returns this data in a numpy array."

I do not understand where the second rhs dimension comes from or where any of the lhs dimensions come from. I was hoping to get the librivox data set running while learning, but I keep coming up empty. I have spent 3 days acquiring and processing the data multiple times but this is where i keep getting stuck.

run-ldc93s1.sh works like a champ.

I am wondering if I did something wrong on install or if the data files did not download, unzip, or pre-process properly but this is the only error i get even when trashing the whole data file and starting over.

Thanks in advance for any help.

crs117 avatar Apr 08 '17 21:04 crs117

I think this is a mismatch in model shape from the previous checkpoint from running the run-ldc93s1.sh script. I am looking into clearing the checkpoint.

crs117 avatar Apr 08 '17 22:04 crs117

That's exactly it. We should figure out a way to inform users about this problem before or instead of the cryptic TF error.

On Apr 8, 2017 7:19 PM, "crs117" [email protected] wrote:

I think this is a mismatch in model shape from the previous checkpoint from running the run-ldc93s1.sh script. I am looking into clearing the checkpoint.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mozilla/DeepSpeech/issues/511#issuecomment-292749594, or mute the thread https://github.com/notifications/unsubscribe-auth/AAdH1hmHgvtmwFm9EnFqhevgE7JWHppVks5ruAgJgaJpZM4M31Ek .

reuben avatar Apr 08 '17 22:04 reuben

I feel really dense. I apologize but leave this here for others to find. By providing the flag required in the command line you can define the checkpoint location for each script. example

./bin/run-librivox.sh --checkpoint_dir ~/DeepSpeech/checkpoints/my_librivox_model_dir --dataset_path /media/c/c_store11/data2/librivox/`

Solves the problem by providing the agrs to define the checkpoint directory and as a further example of other flags a different disk for reading the data from which to create the models.

edit removed sudo from command.

crs117 avatar Apr 08 '17 22:04 crs117

I was in the middle of posting and missed the update. I would be more than happy to volunteer to help fix this. I am a VS user trying to navigate pycharm in ubuntu which is why this took a while to figure out.

crs117 avatar Apr 08 '17 23:04 crs117

Sorry for hijacking the thread, but reading a use of sudo really bothers me. There are never good reasons to justify making a sudo call on that kind of use case, and it will become a bad and dangerous habit :)

lissyx avatar Apr 08 '17 23:04 lissyx

@lissyx

Sorry, I am learning a lot of things right now and this was my 3rd installation trying to get everything working. Please tell me how to proceed. I installed from source and I am assuming I installed everything to the root bin folder as opposed to the user bin folder. What is the way to fix this or do I need to uninstall all of the tools and do it all over again?

Thanks.

crs117 avatar Apr 08 '17 23:04 crs117

@reuben

I may be new but I really want to help and I know I have a lot to learn. I do not know the best place to discuss this so I will throw some darts and hope somebody will bite.

The documentation in the README.md can be updated so that search engines can point here for this issue.

pro's:

  • No change to code.
  • People will discover that default checkpoints can this error by mixing models with different shapes.

con's:

  • Other people may associate this error with Deep Speech itself. (either way people find what may be triggering this in TF)

Change the empty flag behavior for "checkpoint_dir" to work more like "dataset_path" by adding the importer name as a separate folder inside the default directory

if len(FLAGS.checkpoint_dir) == 0:
        FLAGS.checkpoint_dir = xdg.save_data_path(os.path.join('deepspeech','checkpoints',FLAGS.importer))

pro's:

  • Creates a new checkpoint folder automatically for each script

con's:

  • I am not sure how people are using this tool, but it changes the default behavior and may cause confusion for other folks that may run custom scripts.

Add a try to except clause around

with tf.train.MonitoredTrainingSession(master='' if server is None else server.target,
                                               is_chief=is_chief,
                                               hooks=hooks,
                                               checkpoint_dir=FLAGS.checkpoint_dir,
                                               save_checkpoint_secs=FLAGS.checkpoint_secs,
                                               config=session_config) as session:

and catch

    except tf.errors.InvalidArgumentError:
        log_error(sys.exc_info()[1])
        log_error("Provide a --checkpoint_dir argument to work with a model with different shapes.")

cons's:

  • I am not sure if this is the best/cleanest/most efficient way to handle this.
  • Not as efficient as checking the checkpoint parameters. I am not sure how this impacts performance for python but I am pretty sure this will only be taken into account for 1 loop.
  • Looks bad.

pro's:

  • we return the exception from TF but provide information to Deep Speech users on how to mitigate this issue at the bottom.

We could do a check to make sure the variables match before using the MonitoredTrainingSession, but it seems as though this would require creating a separate session manager which seems overly complicated given this function to auto handle sessions.

crs117 avatar Apr 09 '17 19:04 crs117

@crs117 You should make a pull request!

It's obvious that you've thought enough about this that the pull request should be easy enough for you to write up.

Also the pull request would be a better forum to discuss some of these good ideas, and we'd get one more contributor on board!

kdavis-mozilla avatar Apr 09 '17 19:04 kdavis-mozilla

@crs117 I like that approach. FLAGS.importer is going away in favor of decoupling the importers from the script, so the first part of the change would have to live in the bin/run-* scripts instead of the code that handles checkpoint_dir. But other than that, it's the same fix. If you make a PR I'll be happy to review it :)

reuben avatar Apr 09 '17 19:04 reuben

FLAGS.importer is going away in favor of decoupling the importers from the script

That's happening here, btw: https://github.com/mozilla/DeepSpeech/pull/506

reuben avatar Apr 09 '17 19:04 reuben

I will create a pull request. I need to figure out how to do it via pycharm =).

Thanks

crs117 avatar Apr 09 '17 20:04 crs117

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 03 '19 17:01 lock[bot]