【问题标题】:AttributeError when using callback Tensorboard on Keras: 'Model' object has no attribute 'run_eagerly'在 Keras 上使用回调 Tensorboard 时出现 AttributeError:“模型”对象没有属性“run_eagerly”
【发布时间】:2019-12-04 19:36:18
【问题描述】:

我使用 Keras 的函数式 API 构建了一个模型,当我将 tensorboard 实例添加到我的 model.fit() 函数中的回调时,它会抛出错误:"AttributeError: 'Model' object has no attribute 'run_eagerly'"

Model 类确实没有 run_eagerly 属性,但是在 Keras 文档中,它说它可以作为参数传递给 model.compile() 函数。这将返回

"ValueError: ('Some keys in session_kwargs are not supported at this time: %s', dict_keys(['run_eagerly']))"

这是否意味着我没有合适的 Tensorflow/Keras 版本?

张量流:1.14.0

Keras:2.2.4-tf

model = Model(inputs=[input_ant1, input_ant2], outputs=main_output)

tensorboard = TensorBoard(log_dir='.logs/'.format(time()))

[...]

model.fit([input1, input2],[labels], epochs=10, callbacks=[tensorboard])

【问题讨论】:

  • 这里有类似的问题。
  • 同样的问题。以 TF 1.x 作为后端的 Keras 2.2.4 是否不支持此功能?

标签: python tensorflow keras valueerror


【解决方案1】:

我遇到了同样的错误:AttributeError: 'Model' object has no attribute 'run_eagerly'

经过两次小改动后,我的张量板现在正在运行。

  1. 确保按如下方式导入 tensorboard: from keras.callbacks import TensorBoard

  2. 像这样更改日志目录: tensorboard = TensorBoard(log_dir="logs")

【讨论】:

    【解决方案2】:

    我在使用时收到相同的错误消息: from tensorflow.keras.callbacks import ModelCheckpoint 我通过导入相同的内容来修复它: from keras.callbacks.callbacks import ModelCheckpoint

    【讨论】:

      猜你喜欢
      • 2020-09-14
      • 2020-01-03
      • 2020-05-10
      • 2019-05-21
      • 1970-01-01
      • 2020-10-08
      • 1970-01-01
      • 2019-11-29
      • 2021-10-12
      相关资源
      最近更新 更多