I know that similar questions were asked before, but the solutions didn't helped me.
I have the following model:
model = Sequential()
# CNN
model.add(Conv2D(filters=16, kernel_size=2, input_shape=(40, 2000, 1), activation='relu'))
model.add(MaxPooling2D(pool_size=2))
model.add(Dropout(0.2))
# CNN
model.add(Conv2D(filters=32, kernel_size=2, activation='relu'))
model.add(MaxPooling2D(pool_size=2))
model.add(Dropout(0.2))
# CNN
model.add(Conv2D(filters=64, kernel_size=2, activation='relu'))
model.add(MaxPooling2D(pool_size=2))
model.add(Dropout(0.2))
# CNN
model.add(Conv2D(filters=128, kernel_size=2, activation='relu'))
model.add(MaxPooling2D(pool_size=2))
model.add(Dropout(0.2))
model.add(GlobalAveragePooling2D())
model.add(Dense(num_labels, activation='softmax'))
optimizer = optimizers.SGD(lr=0.002, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy', metrics=['accuracy'], optimizer='adam')
I'm trying to fit the model:
model.fit(X_train, y_train_hot, batch_size=10, epochs=50,
validation_data=(X_test, y_test_hot))
where
X_train.shape = {tuple:3} (246, 40, 2000)
from other post I read (Keras input_shape for conv2d and manually loaded images) it seems that my input is right.
But I'm getting the following error:
ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: [None, 40, 2000]
What am I missing ? and how can I fix it ?