def on_train_batch_begin(self, batch, logs=None):
    super(TensorBoardCallBack, self).on_train_batch_begin(batch, logs)
    try:
        lr = self.model.optimizer.learning_rate(batch)
    except TypeError:
        lr = self.model.optimizer.learning_rate
    if ((batch % 100) == 0):
        try:
            with self.writer.as_default():
                tf.summary.scalar('learning rate', tensor=lr)
                self.writer.flush()
        except AttributeError:
            logging.info('TensorBoard not init yet')
def on_train_batch_begin(self, batch, logs=None):
    super(TensorBoardCallBack, self).on_train_batch_begin(batch, logs)
    try:
        lr = self.model.optimizer.learning_rate(batch)
    except TypeError:
        lr = self.model.optimizer.learning_rate
    if ((batch % 100) == 0):
        try:
            with self.writer.as_default():
                tf.summary.scalar('learning rate', tensor=lr)
                self.writer.flush()
        except AttributeError:
            logging.info('TensorBoard not init yet')