-
Notifications
You must be signed in to change notification settings - Fork 22
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
ValueError: Error when checking target: expected activation_35 to have shape (2,) but got array with shape (1,) #4
Comments
I think the issue is somewhat related with the fact that the feature size (after reading the wav files with the feature_extract method) is always 193. Probably it should be some multiple of 2 due to the way the inner things work inside the Keras neural network calculations. E.g. if I use Keras directly instead of the feature_extraction:
I get this error:
That 32 rang me a bell, as 32 x 6 = 192 (one less than 193, that is the feature size). I will do some tests to validate this hypothesis that the problem is with the 193-size array. |
I hacked the 193 number of bytes in the pyAudioClassification files to have the arrays being returned as 192, with no better result. The problem continued, so the 193 was not the cause. Meanwhile, I was playing with the model.compile() parameters and found that I got no error when using 'sparse_categorical_crossentropy' as the loss function. So it seems that a workaround is to use a different loss function. I checked the train() code and noticed that there is a parameter loss_type that replaces the %s in loss='%s_crossentropy', so I tried to call it this way:
... as it will append the "_crossentropy" part to the end. A new error occurred:
Err, I gave up. This library seems nice to collect the features from audio files, but not to model the neural network. I will use Keras directly for this purpose. |
Proposed are a few changes I implemented to solve issues I ran into. These are not tested on binary data conditions! - Line 30 of the proposed changes addresses micah5#4 - Line 74 of the proposed changes addresses an undocumented issue I had. Additionally, the workaround tested by @ropinheiro in micah5#4, shows that user loss_types may be categorical which are not necessary == 'categorical'. A future improvement may be to modify line 41 similar to: ```if 'categorical' in loss_type:```
I installed everything in a Windows 10 machine:
First and second lines run without error. The features and labels are correctly loaded. I can even see them and validate they have shape of 15 (3 folders x 5 files each). Each feature is an array of 193 numbers.
But the third line gives this error:
So as you can see, it seems to be a bug somewhere that is causing an array to be of shape 1 when it should be 2. The "activation_xx" name that appears (where xx seems to jump from 5 in 5 numbers each repeated execution: _5, _10, _15...) makes me think in some bug in an activation function executed at some point in the weight calculation algorithms.
The text was updated successfully, but these errors were encountered: