【问题标题】:Customized tf.keras.keras.callbacks.TensorBoard does not work well in tensorflow version >= 1.15.0自定义的 tf.keras.keras.callbacks.TensorBoard 在 tensorflow 版本 >= 1.15.0 中效果不佳
【发布时间】:2020-07-11 16:31:00
【问题描述】:

以下定制的 TensorBoard,克隆自 this github repo,旨在存储学习率和每批结束时的所谓 KL 权重,在 tensorflow 版本 = 1.15.0的每批中。我该如何解决?

class TensorBoardLR(TensorBoard):
    """ A modification to the Tensorboard callback to also include the scalars of learning rate and KL weight"""
    def __init__(self, *args, **kwargs):
        self.kl_weight = kwargs.pop('kl_weight')
        super().__init__(*args, **kwargs)
        self.count = 0

    def on_batch_end(self, batch, logs=None):
        logs.update({'lr': K.eval(self.model.optimizer.lr),
                     'kl_weight': K.eval(self.kl_weight)})
        super().on_batch_end(batch, logs)

【问题讨论】:

  • 它做错了什么?
  • 每批次不记录lrkl_weight。其他都很好。
  • 在某些时候,他们删除了 'on_batch_end' 并将其替换为 'on_train_batch_end' 。对于某些指标,它们已被平均值取代,但我认为您记录的方式应该成为问题。编辑:未添加。

标签: python-3.x tensorflow keras tensorboard


【解决方案1】:

将方法名称从 on_batch_end 更改为 on_train_batch_end

他们保留了遗留代码的方法,https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/callbacks/Callback 这也是 keras 和 tensorflow.keras 的区别。

【讨论】:

  • 已解决。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-09
相关资源
最近更新 更多