Tensorflow2.0版本中没有Session模块怎么办?


注:安装好Tensorflow2.0后,当使用Session时,报错AtributeError: module ‘tensorflow’ has no attribute ‘Session’:

错误的意思是tensorflow模块没有Session属性,后来查阅资料发现,tensorflow2.0版本中的确没有Session这个属性

解决问题如下:`
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
sess = tf.compat.v1.Session()

在这里插入图片描述


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM