Skip to content

ValueError: Error when checking target: expected activation_35 to have shape (2,) but got array with shape (1,) #4

@ropinheiro

Description

@ropinheiro

I installed everything in a Windows 10 machine:

  • Anaconda
  • Spyder
  • Configured an Environment using Python 3.7
  • Created a folder "data" with 3 folders "on", "off", "problem".
  • Each folder containing 5 wav files for each class
  • Then I ran this code:
from pyaudioclassification import feature_extraction, train #, predict
features, labels = feature_extraction('.\data')
model = train(features, labels)

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:

model = train(features, labels)
Traceback (most recent call last):
  File "<ipython-input-40-41e12a9c6c61>", line 1, in <module>
    model = train(features, labels)
  File "(...)\.conda\envs\MyEnv\lib\site-packages\pyaudioclassification\__init__.py", line 48, in train
    model.fit(x, y, batch_size=64, epochs=epochs, verbose=verbose)
  File "(...)\.conda\envs\MyEnv\lib\site-packages\keras\engine\training.py", line 1089, in fit
    batch_size=batch_size)
  File "(...)\.conda\envs\MyEnv\lib\site-packages\keras\engine\training.py", line 795, in _standardize_user_data
    exception_prefix='target')
  File "(...)\.conda\envs\MyEnv\lib\site-packages\keras\engine\training_utils.py", line 141, in standardize_input_data
    str(data_shape))
**ValueError: Error when checking target: expected activation_5 to have shape (2,) but got array with shape (1,)**

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions