简体   繁体   English

如何在 tf.keras 训练期间获得当前时代的进度?

[英]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.所以所有关于accuracyloss等的信息都应该在 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.

相关问题 tf.keras 在训练期间获得计算梯度 - tf.keras get computed gradient during training 是否可以使用张量流回调将纪元结果记录在tf.keras模型中,以便在训练结束时保存? - Is it possible to log the epoch results in the tf.keras model using a tensorflow callback, in order to save at the end of training? 在 Keras 批量训练期间显示每个 epoch 的进度条 - Show progress bar for each epoch during batchwise training in Keras 恢复训练 tf.keras Tensorboard - Resume Training tf.keras Tensorboard 在 tf.keras 模型训练期间“无法找到可以减少输出时间的可调参数” - "Failed to find a tunable parameter that would decrease the output time" during tf.keras model training 有没有一种方法可以将模型保存在tf.keras中的指定纪元? - Is there a way to save a model at a specified epoch in tf.keras? 使用tf.keras和Inception-v3转移学习:没有进行任何培训 - Transfer learning with tf.keras and Inception-v3: No training is happening TF.Keras 自定义 Scratch 训练中的多输出-多类分类 - Multioutput-Multiclass Classification in Custom Scratch Training in TF.Keras 如何使用 tf.keras 加载模型? - How to load a model with tf.keras? 使用tf.distribute时,如何避免在每个tf.keras纪元上重新填充tf.data随机缓冲区? - How can I avoid repopulating my tf.data shuffle buffer on each tf.keras epoch when using tf.distribute?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM