我根据Tensorflow的官方教程安装了环境,但是示例代码无法正确运行:
conda create --name tensorflow python=3.7.4
安装pythonpip install --upgrade --ignore-installed tensorflow
安装张量流我错过了任何步骤吗?
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
hello = tf.constant("hello world")
sess = tf.compat.v1.Session()
print(sess.run(hello))
追踪(最近通话):
File "E:/dp/dp_01/test.py", line 6, in <module>
print(sess.run(hello))
File "D:\Users\46173\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\client\session.py", line 956, in run
run_metadata_ptr)
File "D:\Users\46173\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\client\session.py", line 1105, in _run
raise RuntimeError('The Session graph is empty. Add operations to the '
RuntimeError: The Session graph is empty. Add operations to the graph before calling run().