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

model.fit_generator gave TypeError: 'NoneType' object is not callable #15

Open
chuagh74 opened this issue Nov 2, 2020 · 7 comments
Open

Comments

@chuagh74
Copy link

chuagh74 commented Nov 2, 2020

No description provided.

@chuagh74 chuagh74 changed the title Hi, Hi, I am using tf 2.2.0 Nov 2, 2020
@chuagh74 chuagh74 changed the title Hi, I am using tf 2.2.0 Hi, I am using tf 2.2.0. However, I ran into the error when running Nov 2, 2020
@chuagh74 chuagh74 changed the title Hi, I am using tf 2.2.0. However, I ran into the error when running model.fit_generator gave TypeError: 'NoneType' object is not callable Nov 2, 2020
@chuagh74
Copy link
Author

chuagh74 commented Nov 2, 2020

This is the error msg I got:


TypeError Traceback (most recent call last)
in
6 validation_data = ValAugmentGenerator(),
7 validation_steps = validation_steps,
----> 8 epochs=num_epochs, callbacks=callbacks)
9 model.save_weights("camvid_model_150_epochs.h5", overwrite=True)

/cm/shared/apps/tensorflow2-py37-cuda10.2-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py in new_func(*args, **kwargs)
322 'in a future version' if date is None else ('after %s' % date),
323 instructions)
--> 324 return func(*args, **kwargs)
325 return tf_decorator.make_decorator(
326 func, new_func, 'deprecated',

/cm/shared/apps/tensorflow2-py37-cuda10.2-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
1477 use_multiprocessing=use_multiprocessing,
1478 shuffle=shuffle,
-> 1479 initial_epoch=initial_epoch)
1480
1481 @deprecation.deprecated(

/cm/shared/apps/tensorflow2-py37-cuda10.2-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py in _method_wrapper(self, *args, **kwargs)
64 def _method_wrapper(self, *args, **kwargs):
65 if not self._in_multi_worker_mode(): # pylint: disable=protected-access
---> 66 return method(self, *args, **kwargs)
67
68 # Running inside run_distribute_coordinator already.

/cm/shared/apps/tensorflow2-py37-cuda10.2-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)
846 batch_size=batch_size):
847 callbacks.on_train_batch_begin(step)
--> 848 tmp_logs = train_function(iterator)
849 # Catch OutOfRangeError for Datasets of unknown size.
850 # This blocks until the batch has finished executing.

/cm/shared/apps/tensorflow2-py37-cuda10.2-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/eager/def_function.py in call(self, *args, **kwds)
578 xla_context.Exit()
579 else:
--> 580 result = self._call(*args, **kwds)
581
582 if tracing_count == self._get_tracing_count():

/cm/shared/apps/tensorflow2-py37-cuda10.2-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/eager/def_function.py in _call(self, *args, **kwds)
609 # In this case we have created variables on the first call, so we run the
610 # defunned version which is guaranteed to never create variables.
--> 611 return self._stateless_fn(*args, **kwds) # pylint: disable=not-callable
612 elif self._stateful_fn is not None:
613 # Release the lock early so that multiple threads can perform the call

TypeError: 'NoneType' object is not callable

@nikithanair95
Copy link

Did you get a solution to this error?

@chuagh74
Copy link
Author

chuagh74 commented Jun 9, 2021

yes. That's because I was not using right version of TF

@nikithanair95
Copy link

Which version did you use to get it right?

@chuagh74
Copy link
Author

chuagh74 commented Jun 9, 2021

According to my technical support, we were using keras ....we should use tf keras....so he removed keras and use tf keras

@nikithanair95
Copy link

We are importing tenserflow.keras everywhere still we are getting error. Could you please tell me where did you exactly change in the code ?

@chuagh74
Copy link
Author

It was very long ago and i can't remember exactly. But what i remembered is we removed keras and reinstalled tensorflow and change import of keras to tensorflow.keras

from tensorflow.keras.models import Model
from tensorflow.keras.regularizers import l2
from tensorflow.keras.layers import *
#from tensorflow.keras.engine import Layer
from tensorflow.keras.applications.vgg16 import *
from tensorflow.keras.models import *
#from tensorflow.keras.applications.imagenet_utils import _obtain_input_shape
import tensorflow.keras.backend as K
import tensorflow as tf
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.layers import Convolution2D, ZeroPadding2D, MaxPooling2D, Cropping2D, Conv2D
from tensorflow.keras.layers import Input, Add, Dropout, Permute, add
from tensorflow.compat.v1.layers import conv2d_transpose
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.python.keras.callbacks import TensorBoard, ModelCheckpoint, EarlyStopping, ReduceLROnPlateau

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