Negative dimension size caused by subtracting 3 from 1 for ‘conv2d_2/convolution’

By default, Convolution2D (https://keras.io/layers/convolutional/) expects the input to be in the format (samples, rows, cols, channels), which is “channels-last”. Your data seems to be in the format (samples, channels, rows, cols). You should be able to fix this using the optional keyword data_format="channels_first" when declaring the Convolution2D layer.

model.add(Convolution2D(32, (3, 3), activation='relu', input_shape=(1,28,28), data_format="channels_first"))

Leave a Comment