I've been training a TF2 model like
class MyModel():
def __init__(self):
self.inp = Input(name='inp', shape=[None, self.inp_tgt.n_feat], dtype='float32')
self.network = MyAttentionModel()
self.model = Model(inputs=self.inp, outputs=self.network.outp)
self.model.summary()
def train(self):
train_dataset = self.dataset(max_epochs)
opt = Adam()
loss = BinaryCrossentropy()
self.model.compile(loss=loss,optimizer=opt)
self.model.fit(
x=train_dataset,
epochs=max_epochs,
steps_per_epoch=self.n_iter
)
The issue is the training precess runs too slow, I've checked each inner function in my model offline, but things seem to work fine seperately.
I'd like to use datetime.now() to check the time used in each part of my model like I use in pytorch. But in tensorflow, program seems not running seriesly, thus print(end_time - start_time) output nothing
There're some method I've tried,
printtime costed- cProfile
- tensorflow-profiler
cProfile and tensorflow-profiler outputs mainly python operation's time cost, which difficult to find the bottleneck in my model.
Is there any other methods may help if I want to calculate the time cost of each component of the network?