I'm trying to compile a dataset with Sequential() with the Keras module, but I get back a value error:
ValueError: Error when checking model input: expected dense_input_1 to have shape (None, 33) but got array with shape (32, 36)
I went through my code many times, but couldn't find any possible error.
I have a dataset with 32 items, all which are converted into floats.
Here is the code for my neural network:
# Build neural network
# Sequential
model = Sequential()
# Neural network
model.add(Dense(36, input_dim=34, init='uniform', activation='sigmoid' ))
model.add(Dense(32, init='uniform', activation='sigmoid'))
model.add(Dense(32, init='uniform', activation='sigmoid'))
model.add(Dense(32, init='uniform', activation='sigmoid'))
model.add(Dense(33, init='uniform', activation='sigmoid'))
# Compile model
model.compile(loss='mean_squared_logarithmic_error', optimizer='SGD', metrics=['accuracy'])
# Fit model
history = model.fit(X, Y, nb_epoch=20, validation_split=0.2, batch_size=3)
Here is the complete error message I received:
Traceback (most recent call last):
File "/Users/cliang/Desktop/Laurence/Python/Programs/Python/Collaborative_Projects/Cancer_screening/neural_network_alls_1.py", line 111, in <module>
history = model.fit(X, Y, nb_epoch=20, validation_split=0.2, batch_size=3)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/models.py", line 672, in fit
initial_epoch=initial_epoch)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/engine/training.py", line 1116, in fit
batch_size=batch_size)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/engine/training.py", line 1029, in _standardize_user_data
exception_prefix='model input')
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/engine/training.py", line 124, in standardize_input_data
str(array.shape))
ValueError: Error when checking model input: expected dense_input_1 to have shape (None, 34) but got array with shape (32, 36)