属性错误:模块“tensorflow”没有属性“Summary”

问题描述 投票:0回答:1

运行此代码时:

def scalar_summary(self, tag, value, step):
        """Log a scalar variable."""
        summary = tf.Summary(value=[tf.Summary.Value(tag=tag, simple_value=value)])
        self.writer.add_summary(summary, step)

我收到错误消息:

AttributeError: module 'tensorflow' has no attribute 'Summary'. Did you mean: 'summary'?

我正在尝试在 Google colabs 上运行 https://github.com/InhwanBae/ENet-SAD_Pytorch/blob/master/utils/tensorboard.py 中的代码。我正在尝试使用 CULane 数据集训练 ENet-SAD 模型。

machine-learning pytorch google-colaboratory tensorboard
1个回答
0
投票

从源码来看,tensorflow v2.2.3是最后一个包含

tf.Summary
导出

的版本

https://github.com/tensorflow/tensorflow/blob/v2.2.3/tensorflow/python/__init__.py

本文是 2019 年的,因此我建议您限制 2019 年之前的软件包版本,以避免可能的问题。

© www.soinside.com 2019 - 2024. All rights reserved.