I want to apply the CNN model by adding CNN followed by fully connected followed by CNN, but I get an error?
#defining model
model=Sequential()
#part 3 CNN followed by fully connected followed by CNN
#adding convolution layer
model.add(Conv1D(32,3, activation='relu', padding='same',
input_shape = (X_train.shape[1],1)))
#adding fully connected layer
model.add(Flatten())
model.add(Dense(256,activation='relu'))
model.add(Dense(128,activation='relu'))
model.add(Dense(32,activation='relu'))
#adding convolution layer
model.add(Conv1D(64,3, activation='relu', padding='same'))
#adding pooling layer
model.add(MaxPool1D(pool_size=(2,), strides=2, padding='same'))
#adding output layer
model.add(Dense(2,activation='softmax'))
#compiling the model
model.compile(loss='sparse_categorical_crossentropy',optimizer='adam',metrics=['accuracy'])
model.summary()
the error : ValueError: Input 0 of layer conv1d_39 is incompatible with the layer: : expected min_ndim=3, found ndim=2. Full shape received: (None, 64)