【发布时间】:2016-07-01 21:54:17
【问题描述】:
import tensorflow as tf
x = tf.constant(35, name='x')
y = tf.Variable(x + 5, name='y')
model = tf.initialize_all_variables()
with tf.Session() as session:
session.run(model)
print(session.run(y))
此代码生成错误提示 Type Error: List of tensors when single tensor expected
可能是什么问题???
系统详情:Virtualbox:Ubuntu 16.04 xenial,张量流 0.9.0,python-3.5
【问题讨论】:
-
我无法重现您的问题 --- 您的代码适用于我并打印“40”。您是否有机会使用交互式 Python 环境?如果是这样,也许尝试重新启动 Python?
-
不,我没有使用交互式 Python 环境,我使用“Sublime”作为核心编辑器,除此之外没有什么不同。我已将文件保存为“tensor_test.py”,当张量源处于活动状态时,我使用基本命令“python tensor_test.py”在终端中运行它。
标签: python-3.x ubuntu tensorflow