Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: The model expects 0 input arrays, but only received one array. #56

Open
RogerYu123 opened this issue Apr 13, 2017 · 1 comment

Comments

@RogerYu123
Copy link

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 :(

@ayoung01
Copy link

ayoung01 commented Jun 5, 2017

Had the same problem; solved it with help of keras-team/keras#6062

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants