gpt4 book ai didi

tensorflow - 模块 'Tensorflow' 没有属性 'summary'

转载 作者:行者123 更新时间:2023-12-04 14:10:24 25 4
gpt4 key购买 nike

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

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() 导致以下错误

Error: AttributeError: module 'tensorflow' has no attribute 'Summary'

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

我该如何解决这个问题?

最佳答案

查看 documentation tensorflow的,现在tensorboard summary的用法不同了:

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()

关于tensorflow - 模块 'Tensorflow' 没有属性 'summary',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64963915/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com