I wanna train a convolutional neural network to convert an input image to an output image, where the input and output images are of the same dimensions (50 pixels wide, 300 pixels high and greyscale). So, x_test.shape is (11264, 300, 50, 1).

When I try to put together a super-simple model (the actual model is intended to have multiple convolutional layers), I run into problems with dimensions. The model is as follows:

input_shape = (300, 50, 1)
model = Sequential()
model.add(Conv2D(300, kernel_size=(5, 5), strides=(1, 1), padding='same', input_shape=input_shape, activation='tanh'))
model.compile(loss="categorical_crossentropy", optimizer="nadam", metrics=['accuracy'])

When I attempt to train it I encounter the following error:

Error when checking target: expected conv2d_25 to have shape (300, 50, 300) but got array with shape (300, 50, 1)

I'm obviously getting some simple wee thing wrong here. Could I get a hint at how to proceed?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.