问题遇到的现象和发生背景
在anaconda4.11.0上测试安装的tensorflow2.8.0。
问题相关代码,请勿粘贴截图
import tensorflow as tf
hello = tf.constant('hello,tensorf')
sess = tf.Session()
print(sess.run(hello))
出现:
AttributeError: module 'tensorflow' has no attribute 'Session'
自己查找修改为:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
hello = tf.constant('hello,tensorf')
sess = tf.Session()
print(sess.run(hello))
结果还是错误
运行结果及报错内容
WARNING:tensorflow:From D:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\compat\v2_compat.py:107: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
b'hello,tensorf'
为什么出现 b'hello,tensorf'这个结果
我的解答思路和尝试过的方法
无
我想要达到的结果
'hello,tensorf'