python - AttributeError:模块“tensorflow_core.summary”没有属性“FileWriter”
问题描述
我在使用 Tensorflow v2.1.0 时遇到错误:
AttributeError: module 'tensorflow_core.summary' has no attribute 'FileWriter
我的代码是:
import tensorflow as tf
a = tf.constant(5.0)
b = tf.constant(6.0)
c = a*b
sess = tf.compat.v1.Session()
File_Writer = tf.summary.FileWriter(r"C:\Users\Name\Desktop\TensorFlow\graph", sess.graph)
print(sess.run(c))
输出错误是:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-19-898c56a41b1a> in <module>
6 sess = tf.compat.v1.Session()
7
----> 8 File_Writer = tf.summary.FileWriter(r"C:\Users\Name\Desktop\TensorFlow\graph", sess.graph)
9
10 print(sess.run(c))
AttributeError: module 'tensorflow_core.summary' has no attribute 'FileWriter'
我该怎么做才能修复它?
解决方案
利用tf.summary.create_file_writer('log_path')
推荐阅读
- python - 如何保护我的 ren'py 项目不被复制?
- clickhouse - clickhouse 是否提供任何工具,例如 red gate sql toolbelt
- linux - 在 apache 配置中未显示预期输出
- node.js - 为什么我不能将 @bundled-es-modules/chai 别名为 chai?
- python - 在 Matplotlib 中同时使用 blitting 为一个子图设置动画,而在 Matplotlib 中通过重绘为另一个子图设置动画
- windows-10 - 在 Power Automate Desktop 中获取列表中的第一项
- r - 在样本中添加值
- javascript - parcel serve 为 SourceMap 请求和不存在的 url 返回 index.html
- python - 如果我在 Django 项目中创建和使用批处理文件,则没有名为错误的模块
- python - 以下人工神经网络的输入层节点数是多少?