【问题标题】:How to design a custom callback in Keras?如何在 Keras 中设计自定义回调?
【发布时间】:2019-12-05 05:21:00
【问题描述】:

我试图用以下信息在 keras 中设计一个自定义回调:


- Number of samples processed in the current batch
- Current epoch
- Time taken to execute the current epoch
- Any metric supplied to the model in its compilation stage
- Number of epochs remaining

应该显示一个进度条来显示纪元数和当前纪元。我尝试使用 tqdm 但不知道如何实现它。任何帮助将不胜感激

【问题讨论】:

  • Keras 已经有进度条了,有什么意义呢?
  • 是为了学习。希望得到答复。
  • Keras 中进度条的代码在这里:github.com/keras-team/keras/blob/master/keras/callbacks/… 使用它作为开始,然后用实际问题改进您的问题。 “任何帮助”在 SO 中并不是一个真正有效的问题。

标签: tensorflow keras callback tqdm


【解决方案1】:

这是@Dr 前面所述的 ProgBar 的 keras 回调的永久链接。史努比(虽然链接断开): https://github.com/keras-team/keras/blob/461c7b1dc1797d2b05110837f5a4cd12886cc390/keras/callbacks.py#L926

这很有趣,我个人一直在寻找这个来改进我自己的回调功能:

def set_params(self, params):
    super().set_params(params)
    self.epochs = params['epochs']

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-15
    • 2019-06-07
    • 2019-11-19
    • 1970-01-01
    • 1970-01-01
    • 2019-01-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多