【问题标题】:Module 'Tensorflow' has no attribute 'summary'模块 'Tensorflow' 没有属性 'summary'
【发布时间】:2020-11-23 07:11:14
【问题描述】:

我正在执行一个包含以下行的程序:

def write_log(callback, name, loss, batch_no):
    """
    Write training summary to TensorBoard
    """
    summary = tf.Summary()
    summary_value = summary.value.add()
    summary_value.simple_value = loss
    summary_value.tag = name
    callback.writer.add_summary(summary, batch_no)
    callback.writer.flush()

summary = tf.Summary() 导致以下错误

错误:AttributeError:模块'tensorflow'没有属性'Summary'

我使用的 Tensorflow 版本是 2.3.0。与“TensorFlow”相关的其余功能运行良好。

我该如何解决这个问题?

【问题讨论】:

  • 能否提供错误信息和您使用的TensorFlow版本等信息?
  • 是的,更新了@Panther314

标签: tensorflow summary


【解决方案1】:

看张量流的documentation,张量板总结的用法现在不一样了:

writer = tf.summary.create_file_writer("/tmp/mylogs")
with writer.as_default():
  for step in range(100):
    # other model code would go here
    tf.summary.scalar("my_metric", 0.5, step=step)
    writer.flush()

【讨论】:

    猜你喜欢
    • 2020-10-17
    • 1970-01-01
    • 2020-06-05
    • 2020-02-04
    • 2019-09-18
    • 2019-09-16
    • 2019-10-13
    • 1970-01-01
    • 2019-10-05
    相关资源
    最近更新 更多