Search code examples
pythontensorflowkeras

Tensorflow 1.15, Keras 2.2.5, on_batch_end or on_train_batch_end not triggering


This is my custom callblack:

class CustomCallback(keras.callbacks.Callback):
    def on_train_begin(self, logs=None):
          print("on_train_begin")
    def on_train_batch_end(self, batch, logs=None):
          print("on_train_batch_end")
    def on_batch_end(self, batch, logs=None):
          print("on_batch_end")

Problem: during training I only see "on_train_begin" appearing in the output.

My Tensorflow version: 1.15 My Keras version: 2.2.5

Any solution ?

Thank you

p.s: I don't want to change my Keras/TF versions


Solution

  • I had to call:

    clist.on_train_batch_end(batch_num, logs)
    

    in the training loop

    With

    clist = CallbackList(callbacks=self.callbacks)