0

i am basically trying to build a deep model which consists of many convolution2d layers followed by maxpooling 2d as follows :

model.add(Convolution2D(128, 54, 7, input_shape=(1, 54, 180)))
model.add(MaxPooling2D(pool_size=(1, 3)))

model.add(Convolution2D(128, 1, 7))
model.add(MaxPooling2D(pool_size=(1, 3)))

However , i am getting the following error :

File "/home/user/anaconda2/lib/python2.7/site-packages/keras/engine/training.py", line 100, in standardize_input_data str(array.shape)) Exception: Error when checking model input: expected convolution2d_input_1 to have 4 dimensions, but got array with shape (8000, 180, 54) Blockquote

But i am following the (samples, channels, rows, cols) norm. Why is this happening ?

meme mimis
  • 81
  • 1
  • 6

1 Answers1

1

It seems like your input data has the wrong shape. You should print out the shape of the data that you are feeding into the network.

It seems like your array are gray input images and they normally only use 2 dimensions because they only have 1 channel. Therefore the np array is ordered without the third dimension. Normally you have to add this by using np.reshape or allocating your array in another way. When I get an error message like yours i would try:

X # training data
X = np.transpose(X, (0, 2, 1))
X = np.reshape(X, (X.shape[0], 1, X.shape[1], X.shape[2]))
Thomas Pinetz
  • 6,948
  • 2
  • 27
  • 46
  • My input data is text. thanks for the suggestion i am going to try it to see if it would solve the problem. – meme mimis Jan 10 '17 at 14:34