AttributeError: module ‘tensorflow‘ has no attribute ‘session‘的解决方案

待检测程序:

import tensorflow as tf 
hello =tf.constant('hello, tensorflow')
#print('Hello python')
sess = tf.session()

问题描述,仍旧接着上一篇,没想到,解决了cudart64_110.dll not found的问题又出现了AttributeError: module 'tensorflow' has no attribute 'session'的问题。

经网络查询资料,https://blog.csdn.net/sinat_36502563/article/details/102302392

把:

sess = tf.session()

改为

sess = tf.compat.v1.Session()

即可。

猜你喜欢

转载自blog.csdn.net/a1456123a/article/details/115097982
今日推荐