I added a print to a call function in Keras model, and suspect that the call method is called twice on model.fit - what is the reason for that?
class my_model(keras.Model):
def __init__(self, units = 3, **kargs):
super().__init__(**kargs)
self.hidden = keras.layers.Dense(1)
def call(self, inputs):
outputs = self.hidden(inputs)
print ('my_model call function')
return outputs
model = my_model()
model.compile(loss = "mse")
X = np.random.standard_normal([10,3])
y = np.random.standard_normal([10,1])
history = model.fit(X, y, epochs = 1000, verbose = 0)
Output:
my_model call function
my_model call function