我正在完成这个使用Keras创建图像分类器的精彩教程.一旦我训练了模型,我将其保存到一个文件中,然后将其重新加载到下面显示的测试脚本中的模型中.
当我使用新的,前所未见的图像评估模型时,我得到以下异常:
错误:
Traceback (most recent call last):
File "test_classifier.py", line 48, in <module>
score = model.evaluate(x, y, batch_size=16)
File "/Library/Python/2.7/site-packages/keras/models.py", line 655, in evaluate
sample_weight=sample_weight)
File "/Library/Python/2.7/site-packages/keras/engine/training.py", line 1131, in evaluate
batch_size=batch_size)
File "/Library/Python/2.7/site-packages/keras/engine/training.py", line 959, in _standardize_user_data
exception_prefix='model input')
File "/Library/Python/2.7/site-packages/keras/engine/training.py", line 108, in standardize_input_data
str(array.shape))
Exception: Error when checking model input: expected convolution2d_input_1 to have shape (None, 3, 150, 150) but got array with shape (1, 3, 150, 198)`
Run Code Online (Sandbox Code Playgroud)
是我训练的模型的问题还是我如何调用evaluate方法?
码:
from keras.preprocessing.image …Run Code Online (Sandbox Code Playgroud)