Matthias
Matthias

Reputation: 10379

How to get progress of current epoch during tf.keras training?

I am writing a GUI application for training of various tf.keras-based models. So all the information on accuracy, loss etc. should be visible on the GUI instead of the default Keras console output.

Now I managed to get all the relevant information during model training via a custom tf.keras.callbacks.Callback class, which works fine. But I also want to get the progress of the current epoch, i.e. how much % of the current epoch has been trained so far, i.e. what Keras prints to console during training via the progress bar.

Is there any way to retrieve that information in a Keras callback as well?

Upvotes: 2

Views: 3291

Answers (1)

Matthias
Matthias

Reputation: 10379

Ok, found the solution. It can be found in the self.params attribute of the Callback class.
For me this works:

def on_epoch_begin(self, epoch, logs=None):
    self.epoch_step = 0

def on_batch_end(self, batch, logs=None):
    self.epoch_step += 1
    progress = self.epoch_step / self.params["steps"]

For the reords, I found this solution here in the keras-tqdm GitHub repo.

Upvotes: 3

Related Questions