deep-learning-models
deep-learning-models copied to clipboard
ValueError: The model expects 0 input arrays, but only received one array.
Hi,i am in trouble when i use the pre-train model ''InceptionV3" in keras. here's my code:
width = image_size[0]
height = image_size[1]
input_tensor = Input((height, width, 3))
x = input_tensor
base_model = InceptionV3(input_tensor=x, weights='imagenet', include_top=False)
model = Model(base_model.input, GlobalAveragePooling2D()(base_model.output))
gen = ImageDataGenerator()
train_generator = gen.flow_from_directory("train2", image_size, shuffle=False,batch_size=16)
test_generator = gen.flow_from_directory("test2", image_size, shuffle=False, batch_size=16, class_mode=None)
train_step = train_generator.samples / (float)(train_generator.batch_size )
test_step = test_generator.samples / (float)(test_generator.batch_size )
train = model.predict_generator(train_generator, train_step)
test = model.predict_generator(test_generator, test_step)
but when this code runs,it happens a ValueError. here is the traceback:
train = model.predict_generator(train_generator, train_step)
File "/usr/local/lib/python2.7/dist-packages/keras/legacy/interfaces.py", line 88, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 2094, in predict_generator
outs = self.predict_on_batch(x)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1677, in predict_on_batch
self._feed_input_shapes)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 100, in _standardize_input_data
'Found: array with shape ' + str(data.shape))
ValueError: The model expects 0 input arrays, but only received one array. Found: array with shape (16, 299, 299, 3)
what's wrong with my code? it is OK when i use the older version of InceptionV3, and now it is still OK when i use ResNet50 and Xception model. could you help me? , thanks :(
Had the same problem; solved it with help of https://github.com/fchollet/keras/issues/6062