简体   繁体   中英

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, ie how much % of the current epoch has been trained so far, ie 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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM