Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TypeError:无法将int32转换为张量或运算_Python_Tensorflow - Fatal编程技术网

Python TypeError:无法将int32转换为张量或运算

Python TypeError:无法将int32转换为张量或运算,python,tensorflow,Python,Tensorflow,我在python 3.6上运行以下操作: import tensorflow as tf x = 2 y = 3 add_op = tf.add(x, y) mul_op = tf.mul(x, y) useless = tf.mul(x, add_op) pow_op = tf.pow(add_op, mul_op) with tf.Session() as sess: z, not_useless = sess.run([op3, useless]) 得到了这个错误: T

我在python 3.6上运行以下操作:

import tensorflow as tf
x = 2
y = 3
add_op = tf.add(x, y)
mul_op = tf.mul(x, y)
useless = tf.mul(x, add_op)
pow_op = tf.pow(add_op, mul_op)
with tf.Session() as sess:
      z, not_useless = sess.run([op3, useless])
得到了这个错误:

   TypeError: Can not convert a int32 into a Tensor or Operation.

这是指某一行吗?它必须是关于最后一行的。代码来自下一张幻灯片的第41页确定找到了问题!:)使用tf.Session()作为sess:z,not_unavouse=sess.run([pow_op,unavouse])print(z)print(not_unavouse)好吧,那么我们用什么作为
op3
?作者在幻灯片中混淆了op3和pow_op