I am using a dataset of 11 classes of audio files and by using Convolutional Neural Network I tried to classify those audio files.
My model:
train_data = np.array(X)
train_labels = np.array(y)
model = Sequential()
model.add(layers.Conv2D(32, (3,3), activation='relu', input_shape=train_data.shape))
model.add(layers.MaxPool2D(2,2))
model.add(layers.Conv2D(32, (3,3), activation='relu'))
model.add(layers.MaxPool2D(2,2))
model.add(layers.Flatten())
model.add(layers.Dense(128, activation="relu"))
model.add(layers.Dense(34, activation="relu"))
model.add(layers.Dense(NUM_LABELS))
model.summary()
train_data is audio loaded using librosa with the shape of (6705, 20, 130)
train_label is an array of one-hot vectors with the shape of (6705, 11)
Whether I expand dimensions: reshaped_train_data = np.expand_dims(train_data, axis=3)
or reshape it: reshaped_train_data = train_data.reshape(-1, train_data.shape[1], train_data.shape[2], 1)
and tried to train it: history = model.fit(reshaped_train_data , train_labels, epochs=50, validation_split=0.1)
It gives me the following error: ValueError: Error when checking input: expected conv2d_5_input to have a shape (6705, 20, 130) but got an array with shape (20, 130, 1)
How to reshape it or expand it in a way so that I could train my model?