Input 0 is incompatible with layer conv2d_2: expected ndim=4, found ndim=3 I get this error in Tensor flow, What does it mean and how can I fix it?
The error is likely to come from this line:
model.add(Conv2D(32, kernel_size=(3, 3),activation='relu',input_shape=X.shape[1:]))

Input_shape should be a 4dim vectors as stated in the keras doc:

Input shape
4D tensor with shape: (batch, channels, rows,
cols) if data_format is &quot;channels_first&quot; or 4D tensor with
shape: (batch, rows, cols,
channels) if data_format is &quot;channels_last&quot;.

You may have to reshape your data, as stated here:
https://stackoverflow.com/q/43895750/8119313