C1W2, Can't compile the student's code. Error when checking input: expected dense_Dense1_input to have 2 dimensions, but got array with shape (None, 28, 28, 1)

I get an error message when i submit my submission in week 2. It says that ‘Can’t compile the student’s code. Error when checking input: expected dense_Dense1_input to have 2 dimensions, but got array with shape (None, 28, 28, 1)’

My code:
model.add(tf.layers.conv2d({ inputShape: [28, 28, 1], kernelSize: 3, filters: 8, activation: ‘relu’}));

What is the caused of the error? Can anyone help me to overcome this error?

Try adding a Flatten layer after the convolutional layers to convert the 4D output into a 2D shape. This will flatten the spatial dimensions (height and width) into a single dimension.