0
$\begingroup$

I am trying to fit this model in keras but getting this error :

 Namespace(batch_size=32, epoch=10, num_classes=2)
Start
Train loading
<class 'numpy.uint8'>
Test loading
<class 'numpy.ndarray'>
Validation loading
done_loading
Traceback (most recent call last):
  File "main.py", line 67, in <module>
    validation_data=(x_val, Y_valHot)
  File "/tools/anaconda3/envs/py35/lib/python3.5/site-packages/keras/engine/training.py", line 1581, in fit
    batch_size=batch_size)
  File "/tools/anaconda3/envs/py35/lib/python3.5/site-packages/keras/engine/training.py", line 1414, in _standardize_user_data
    exception_prefix='input')
  File "/tools/anaconda3/envs/py35/lib/python3.5/site-packages/keras/engine/training.py", line 153, in _standardize_input_data
    str(array.shape))
ValueError: Error when checking input: expected data to have shape (None, 224, 224, 3) but got array with shape (9730, 244, 224, 3)

The function used to fit the model is

model.fit(X_train, Y_train,
          batch_size=batch_size,
          nb_epoch=nb_epoch,
          shuffle=True,
          verbose=1,
          validation_data=(X_valid, Y_valid),
          )

Can someone tell me where I went wrong.

$\endgroup$
  • $\begingroup$ Please provide a model summary as well as some info about input and output data. $\endgroup$ – Alessandro Jul 3 '18 at 11:59
  • $\begingroup$ It's the densenet model, I'm trying to fine tune. $\endgroup$ – Srihari Jul 3 '18 at 13:31
3
$\begingroup$

ValueError: Error when checking input: expected data to have shape (None, 224, 224, 3) but got array with shape (9730, 244, 224, 3) it clearly says that while preprocessing that either X_train or X_valid have (9730, **244**, 224, 3) instead of (9730, **224**, 224, 3)

| improve this answer | |
$\endgroup$
  • $\begingroup$ I'm really careless. Really sorry, the numbers were too similar, I didn't notice. Thank you so much for your reply $\endgroup$ – Srihari Jul 3 '18 at 13:32
  • $\begingroup$ Yeah, if nothing else, closing the question would be highly appreciated. $\endgroup$ – tenshi Jul 3 '18 at 13:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.