keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
61.98k stars 19.47k forks source link

'zip' object has no attribute '_assert_compile_was_called' #14669

Closed tbnxyzfz1 closed 3 years ago

tbnxyzfz1 commented 3 years ago

I am using codes from this project https://github.com/abhinavsagar/kaggle-notebooks/blob/master/data_science_bowl_2018.ipynb

results = Model.fit(train_generator, validation_data=val_generator, validation_steps=10, steps_per_epoch=250, epochs=3, callbacks=[earlystopper, checkpointer])#change to model.fit

This code gives this error:

AttributeError: 'zip' object has no attribute '_assert_compile_was_called'

What caused this error and how to solve it? Thank you.

tbnxyzfz1 commented 3 years ago

I tried

import tensorflow.compat.v1 as tf 

Then the error message becomes

\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\eager\def_function.py in _call(self, *args, **kwds)
    853       # In this case we have created variables on the first call, so we run the
    854       # defunned version which is guaranteed to never create variables.
--> 855       return self._stateless_fn(*args, **kwds)  # pylint: disable=not-callable
    856     elif self._stateful_fn is not None:
    857       # Release the lock early so that multiple threads can perform the call

TypeError: 'NoneType' object is not callable
ymodak commented 3 years ago

This is likely due to zip objects as generators in model.fit. You may want try with list object as your input.