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()

在这里插入图片描述

发布了25 篇原创文章 · 获赞 2 · 访问量 407

猜你喜欢

转载自blog.csdn.net/yuan_xiangjun/article/details/105469721