NoneType Object is not callable - Python/CNN
Friends, I am new at this. Can you please help me understand why this code:
#Construct the model
model_simple = Sequential()
model_simple.add(Conv2D(strides = 1, kernel_size = 3, filters = 12, use_bias = True, bias_initializer = tf.keras.initializers.RandomUniform(minval=-0.05, maxval=0.05) , padding = "valid", activation = tf.nn.relu))
model_simple.add(Conv2D(strides = 1, kernel_size = 3, filters = 12, use_bias = True, bias_initializer = tf.keras.initializers.RandomUniform(minval=-0.05, maxval=0.05) , padding = "valid", activation = tf.nn.relu))
model_simple.add(Conv2DTranspose(strides = 1, kernel_size = 3, filters = 12, use_bias = True, bias_initializer = tf.keras.initializers.RandomUniform(minval=-0.05, maxval=0.05) , padding = "valid", activation = tf.nn.relu))
model_simple.add(Conv2DTranspose(strides = 1, kernel_size = 3, filters = 3, use_bias = True, bias_initializer = tf.keras.initializers.RandomUniform(minval=-0.05, maxval=0.05) , padding = "valid", activation = tf.nn.relu))
#Compile the model
model_simple.compile(optimizer = tf.keras.optimizers.Adam(epsilon = 1e-8), loss = tf.losses.mean_squared_error)
model_simple.fit(imgs_for_input, imgs_for_output, epochs=3, batch_size=32)
creates this error:
Epoch 1/3
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-33-957812893dc7> in <module>()
----> 1 model_simple.fit(imgs_for_input, imgs_for_output, epochs=3, batch_size=32)
1 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/def_function.py in _call(self, *args, **kwds)
940 # In this case we have created variables on the first call, so we run the
941 # defunned version which is guaranteed to never create variables.
--> 942 return self._stateless_fn(*args, **kwds) # pylint: disable=not-callable
943 elif self._stateful_fn is not None:
944 # Release the lock early so that multiple threads can perform the call
TypeError: 'NoneType' object is not callable
I appreciate your time!
you must build your model before training. E.g.
batch = 32
height = 32
width = 32
channels = 3
inputShape = (batch, height, width, channels)
model_simple.build(inputShape)
model_simple.fit(imgs_for_input, imgs_for_output, epochs=3)