anujshah1003 / own_data_cnn_implementation_keras

A complete tutorial on using own dataset to train a CNN from scratch in Keras (TF & Theano Backend)-
175 stars 94 forks source link

Conv2D Error - First Layer of CNN #9

Closed Shraddha2702 closed 5 years ago

Shraddha2702 commented 6 years ago

ValueError: Error when checking input: expected conv2d_59_input to have 4 dimensions, but got an array with shape (88, 128, 128) Things look fine to me, not sure what's wrong.

screenshot 5

JaimePv commented 5 years ago

I'm having the same issue, but with conv2d_1_input. ValueError: Error when checking input: expected conv2d_1_input to have 4dimensions, but got array with shape (2369, 200, 200). Any ideas to solve it??

JaimePv commented 5 years ago

Finally, i solved it by moving the lines 65-68 (from the file "updated_custom_data_cnn.py") to the line 138 above the input_shape definition.

# Defining the model #Shuffle the dataset x,y = shuffle(img_data,Y, random_state=2) # Split the dataset X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=2)

input_shape=img_data[0].shape

model = Sequential()

I hope you enjoy it!