I am training a CNN on a classification problem. The input shape is a number with x_train.shape = (6352,) and I have 10 classes.
I built this model:
# Add a Conv1D layer
input_shape=(6352,1)
model = keras.Sequential()
model.add(keras.layers.Conv1D(16, kernel_size=3, activation='relu', input_shape=input_shape))
model.add(keras.layers.MaxPooling1D(pool_size=3))
model.add(keras.layers.Conv1D(32, kernel_size=2, activation='relu'))
model.add(keras.layers.MaxPooling1D(pool_size=3))
model.add(keras.layers.Flatten())
model.add(keras.layers.Dense(64, activation='relu'))
model.add(keras.layers.Dropout(0.5))
model.add(keras.layers.Dense(10, activation='softmax'))
model.summary()
but when I try to fit the model, I get this:
WARNING:tensorflow:Model was constructed with shape (None, 6352, 1) for input KerasTensor(type_spec=TensorSpec(shape=(None, 6352, 1), dtype=tf.float32, name='conv1d_3_input'), name='conv1d_3_input', description="created by layer 'conv1d_3_input'"), but it was called on an input with incompatible shape (None,).
ValueError: Exception encountered when calling layer 'sequential_3' (type Sequential).
Input 0 of layer "conv1d_3" is incompatible with the layer: expected min_ndim=3, found ndim=1. Full shape received: (None,)
Call arguments received by layer 'sequential_3' (type Sequential):
• inputs=tf.Tensor(shape=(None,), dtype=float32)
• training=True
• mask=None
How to know the correct input shape and how to track the shape through the layers so that the model can work?
I have tried several input shapes but nothing is working