Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidArgumentError: Cannot batch tensors with different shapes in component 0. #2

Closed
ElizavetaSedova opened this issue Jan 25, 2022 · 1 comment

Comments

@ElizavetaSedova
Copy link

Hello! Good job! But I have an error. I want to test the model with my audio files. I have created a folder my_test_3.0s_Segmented in date where the audio is tagged by emotion. Everything goes well, but I always get an error at the moment: list(test_dataset.as_numpy_iterator())
InvalidArgumentError: Cannot batch tensors with different shapes in component 0. First element had shape [103,40,1] and element 1 had shape [92,40,1]. [Op:IteratorGetNext]
This prevents me from testing. I used my code on test data generated while training the model. The code works and I get the result. How can I fix it?

@AryaAftab
Copy link
Owner

AryaAftab commented Jan 25, 2022

Hi
I did not fully understand your question. If you have cut or padded your data into 3-second pieces, why does your data have different sizes after converting to MFCC features?
There is a problem with batching if you manually place your data in the desired folders without cutting or padding. You can't batch data with different shapes in one batch. You can use the following two methods to solve this problem:

  1. Equalize your data shape before or after converting it to MFCC features.
  2. Consider each data as a batch. For example, consider a data with a size of (102,40,1) as (1,102,40,1).

If you have more questions, feel free and ask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants