Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.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中的tensorflow会话称为tensorflow.session吗?_Python_Tensorflow - Fatal编程技术网

python中的tensorflow会话称为tensorflow.session吗?

python中的tensorflow会话称为tensorflow.session吗?,python,tensorflow,Python,Tensorflow,我在jupyter笔记本上尝试了以下代码: import tensorflow as tf x = 2 y = 3 add_op = tf.add(x, y, name='Add') mul_op = tf.multiply(x, y, name='Multiply') pow_op = tf.pow(add_op, mul_op, name='Power') useless_op = tf.multiply(x, add_op, name='Useless') with tf.Session

我在jupyter笔记本上尝试了以下代码:

import tensorflow as tf
x = 2
y = 3
add_op = tf.add(x, y, name='Add')
mul_op = tf.multiply(x, y, name='Multiply')
pow_op = tf.pow(add_op, mul_op, name='Power')
useless_op = tf.multiply(x, add_op, name='Useless')

with tf.Session() as sess:
    pow_out, useless_out = sess.run([pow_op, useless_op])

并显示以下错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-22-15afa07cd8e3> in <module>
      7 useless_op = tf.multiply(x, add_op, name='Useless')
      8 
----> 9 with tf.Session() as sess:
     10     pow_out, useless_out = sess.run([pow_op, useless_op])

AttributeError: module 'tensorflow' has no attribute 'Session'


---------------------------------------------------------------------------
AttributeError回溯(最近一次呼叫上次)
在里面
7无用的,无用的乘(x,加上,name='无用的')
8.
---->9将tf.Session()作为SES:
10功率输出,无用输出=成功运行([功率输出,无用输出])
AttributeError:模块“tensorflow”没有属性“Session”
有人能帮我解决这个问题吗

我在github上看到:

pip3 install --upgrade --force-reinstall tensorflow-gpu
或者这个:

with tf.compat.v1.Session() as sess:


它对您有用吗?

您可能正在使用TF2.0,您需要降级到TF1.x