[英]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.我正在编写一个 GUI 应用程序来训练各种基于
tf.keras
的模型。 So all the information on accuracy
, loss
etc. should be visible on the GUI instead of the default Keras console output.所以所有关于
accuracy
、 loss
等的信息都应该在 GUI 上可见,而不是默认的 Keras 控制台 output。
Now I managed to get all the relevant information during model training via a custom tf.keras.callbacks.Callback
class, which works fine.现在,我设法通过自定义
tf.keras.callbacks.Callback
class 在 model 训练期间获取所有相关信息,效果很好。 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.但我也想获得当前纪元的进度,即到目前为止已经训练了当前纪元的百分比,即 Keras 在训练期间通过进度条打印到控制台的内容。
Is there any way to retrieve that information in a Keras callback as well?有没有办法在 Keras 回调中检索该信息?
Ok, found the solution.好的,找到了解决方案。 It can be found in the
self.params
attribute of the Callback
class.它可以在
Callback
class 的self.params
属性中找到。
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 .对于 reords,我在
keras-tqdm
GitHub repo 中找到了这个解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.