InvalidArgumentError: ValueError: `generator` yielded an element of shape (59, 224, 224, 3)

Question:

I tried to follow this popular Tensorflow tutorial.

Which basically should be a copy-paste, but I still get an error in my code.

I have tried use None as a shape but that does not work. And since I am very new at this I am not really sure what to google for.

This is the code where the error occurs;

epochs = 10

history = model.fit(train_generator, 
                    epochs=epochs, 
                    validation_data=val_generator)
InvalidArgumentError  Traceback (most recent call last)
<ipython-input-15-238fbae26d39> in <module>()
      3 history = model.fit(train_generator, 
      4                     epochs=epochs,
----> 5                     validation_data=val_generator)

10 frames
/usr/local/lib/python3.6/dist-packages/six.py in raise_from(value, from_value)

InvalidArgumentError: ValueError: `generator` yielded an element of shape (59, 224, 224, 3) where an element of shape (64, 224, 224, 3) was expected.
Traceback (most recent call last):

  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/script_ops.py", line 235, in __call__
    ret = func(*args)

  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 630, in generator_py_func
    "of shape %s was expected." % (ret_array.shape, expected_shape))

ValueError: `generator` yielded an element of shape (59, 224, 224, 3) where an element of shape (64, 224, 224, 3) was expected.
Asked By: Mário Carvalho

||

Answers:

I think that it could be a bug from tf-nightly(-gpu)-2.0 since I create a virtualenv with standard tensorflow 1.14 and it works.

Answered By: Chung-Hsien Chang

It seems that, for tf1.14 the problem disappears, but for version tf 1.15, this issue shall arise

Answered By: Paul Zhang Ising