I am working on MNIST dataset, in which X_train = (42000,28,28,1)
is the training set. y_train = (42000,10)
is the corresponding label set. Now I create an iterator from the image generator using Keras as follows;
iter=datagen.flow(X_train,y_train,batch_size=32)
which works fine.
Then I train the model using;
model.fit_generator(iter,steps_per_epoch=len(X_train)/32,epochs=1)
Here it gives the following error;
ValueError: Error when checking input: expected dense_9_input to have 2 dimensions, but got array with shape (32, 28, 28, 1)
I tried but failed to find the mistake. Also I searched here but there was no answer:
expected dense_218_input to have 2 dimensions, but got array with shape (512, 28, 28, 1)
BTW this is the summary of my model
Please help me.
Update:
model=Sequential()
model.add(Dense(256,activation='relu',kernel_initializer='he_normal',input_shape=(28,28,1)))
model.add(Flatten())
model.add(Dense(10,activation='softmax',kernel_initializer='he_normal'))