import tensorflow as tf
import numpy as np
x=np.random.rand(20,10,64)
y=np.random.randint(10,size=(20,1))
class mymodel(tf.keras.Model):
def __init__(self):
super(mymodel,self).__init__()
self.l1 = tf.keras.layers.LSTM(10,return_state=True)
self.l2 = tf.keras.layers.Dense(10,activation=tf.keras.activations.softmax)
def call(self,input):
print('hi')
x=self.l1(input)
# tf.print(x[0],x[1],x[2])
x=self.l2(x[0])
return x
model =mymodel()
model.compile(loss = tf.keras.losses.SparseCategoricalCrossentropy())
model.fit(x,y)
When I run the code above I get 2 hi printed out.There is only 1 epoch and within that epoch 1 batch(batch size being 20) in this example then why is call method getting called twice.