Open Abonia1 opened 4 years ago
I have the same issue and stuck with it. Did you fix that?
Hey, did you solve it?
Same problem as well. In my case I was using keras sub classing for creating the model.
In my case I'm subclassing the keras Model class, just as an example:
class Basic(tf.keras.Model):
def __init__(self):
super().__init__()
self.dense1 = tf.keras.layers.Dense(32, input_shape=(10,), activation='relu')
self.dense2 = tf.keras.layers.Dense(2, activation='sigmoid')
def __call__(self, inputs):
x = self.dense1(inputs)
x = self.dense2(x)
return x
model = Basic()
model.compile(loss="categorical_crossentropy", optimizer='Adam', metrics=["accuracy"])
model.fit(X_encoded, y)
Running this I got this error: TypeError: __call__() got an unexpected keyword argument 'training'
The only thing I needed was to add training=False
parameter to the __call__
function, so the code would be:
class Basic(tf.keras.Model):
def __init__(self):
super().__init__()
self.dense1 = tf.keras.layers.Dense(32, input_shape=(10,), activation='relu')
self.dense2 = tf.keras.layers.Dense(1, activation='sigmoid')
def __call__(self, inputs, training=False):
x = self.dense1(inputs)
x = self.dense2(x)
return x
model = Basic()
model.compile(loss="categorical_crossentropy", optimizer='Adam', metrics=["accuracy"])
model.fit(X_encoded, y)
Hope this helps
Thanks!..I did the same
I think you need to define your custom call function as :
def call(self, inputs):
<do stuff>
return output
If you use __call__
, you are essentially overloading the core python codes..
Hello I have issue in using dynamic_decode in tfa as below with tensorflow 2.X
I really appreciate if anyone have already resolved this issue as I have spent last 4 hours in it but still no solution out there.