python - 如何修复:模块“tensorflow”没有属性“会话”
问题描述
import tensorflow as tf
a=tf.constant(2)
b=tf.constant(3)
c=a+b
sess=tf.Session(c)
sess.run()
我收到错误消息模块“tensorflow”没有属性“会话”
解决方案
从官方文档中尝试以下操作:
# Build a graph.
a = tf.constant(5.0)
b = tf.constant(6.0)
c = a * b
# Launch the graph in a session.
sess = tf.compat.v1.Session()
# Evaluate the tensor `c`.
print(sess.run(c))
推荐阅读
- vhdl - 是否可以在测试台中定义循环函数
- ios - 如何在 Swift Flutter 插件中接收应用程序委托调用?
- javascript - Freecodecamp 上的“排队”练习
- vue.js - 从本地项目文件夹中打开 vue.js 中的 pdf 文件时出错
- runtime - 有没有解决运行时错误的有效方法?
- node.js - 从 Node.js 连接 MongoDB Atlas 的问题
- swift - 使用 swift 5 将字符串转换为 Int
- java - Spring Boot Jpa 删除除最后 50 条以外的所有记录
- flutter - 如何从 Flutter 中的另一个小部件更改 DropdownButton 值?
- javascript - 如何使用循环在导航列表中创建链接?