AttributeError: module 'tensorflow' has no attribute 'Session'
运行:
import tensorflow as tf
sess=tf.Session(config=tf.ConfigProto(log_device_placement=True))
- 1
- 2
出现:
AttributeError: module 'tensorflow' has no attribute 'Session'
原因:
因为是tensorflow 2.0版本
怎么解决:
此时须用
tf.compat.v1.Session()
替代
tf.Session()`
上述代码须为:
import tensorflow as tf
sess=tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(log_device_placement=True))
两个版本tensorflow函数对照:
参考链接:
https://docs.google.com/spreadsheets/d/1FLFJLzg7WNP6JHODX5q8BDgptKafq_slHpnHVbJIteQ/edit#gid=0
AttributeError: module 'tensorflow' has no attribute 'Session'的更多相关文章
- AttributeError: module 'tensorflow' has no attribute 'enable_eager_execution'
Traceback (most recent call last): File "linear_regression_eager_api.py", line 15, in < ...
- AttributeError: module 'tensorflow' has no attribute 'sub'
官方的例子:运行之后出现以下错误 # 进入一个交互式 TensorFlow 会话. import tensorflow as tf sess = tf.InteractiveSession() x = ...
- python3 ,AttributeError: module 'tensorflow' has no attribute 'merge_summary'
error:tensorflow有些方法属性被改了, self.summary_writer = tf.train.SummaryWriter(summary_dir)改为:summary.FileW ...
- AttributeError: module 'tensorflow' has no attribute 'set_random_seed'
anaconda3 python3.7 安装好tensorflow 后出现上面的问题,原因是安装的tensorflow版本是2.0的,所以使用以前的代码tensorflow中的函数不兼容.
- 吴裕雄--天生自然 pythonTensorFlow图形数据处理:解决module 'tensorflow' has no attribute 'Session'
原因:因为是tensorflow 2.0版本
- Debug 路漫漫-14:Python: AttributeError: module 'tensorflow' has no attribute 'sub'
在调试 <Neural Factorization Machines for Sparse Predictive Analytics>论文的源码(https://github.com/he ...
- Tensorflow之AttributeError: module 'tensorflow' has no attribute 'mul'
tf.mul已经在新版本中被移除,请使用 tf.multiply 代替
- 【pycharm】pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法
pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法 解决方法: 在pycharm的安装目 ...
- AttributeError: module ‘tensorflow.python.ops.nn’ has no attribute ‘leaky_relu’
#AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu' 的原因主要是版本的问题 解决方法是更新 ...
随机推荐
- 研究下vc++的abort函数
最近在调试几个问题时,发现跟abort函数有关,以前只是简单使用,现在却发现不简单,就多留意了下. 简介 abort中止当前进程并返回错误代码.异常终止一个进程.中止当前进程,返回一个错误代码.错误代 ...
- Vue模板语法(一)
Vue模板语法 一.插值 1.1.1 文本 {{msg}} 1.1.2 html 使用v-html指令用于输出html代码 1.1.3 属性 HTML属性中的值应使用v-bind指令 1.1.4 表达 ...
- mysql实现行转列功能
实现从图一转行成图二的功能: 图一: 图二: 建表语句: CREATE TABLE `t_user_score` ( `id` ) NOT NULL AUTO_INCREMENT COMMENT '主 ...
- 关于m3u8格式的视频文件ts转mp4下载和key加密问题
一,利用网站浏览器F12键,利用谷歌浏览器插件找到视频的.m3u8文件,并打开. 二,打开m3u8文件后,里面有很多.ts的链接,和key的链接. 三,保存为html文件,下载ts文件,代码如下:可加 ...
- python3 mqtt 添加用户名以及密码
import paho.mqtt.client as mqtt client = mqtt.Client(client_id, transport='tcp') client.username_pw_ ...
- 获取最新的中国IP的脚本,给ROS可以使用的脚本
wget http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latestecho "/ip firewall address-li ...
- Executor多线程框架
啥都别说了,上代码: import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; impor ...
- github执行clone操作时报错
在执行github上的clone操作时,报 ssh_exchange_identification: Connection closed by remote host 在网上找了好多种解决办法,都没有 ...
- Linux 就该这么学 CH07 使用RAID和LVM磁盘阵列技术
1 RAID (独立冗余磁盘阵列) RAID 技术通过把多个硬盘设备组合成一个容量更大.安全性更好的磁盘阵列,并把数据切割成多个区段之后分别存在各个不同的物理硬盘设备上,然后利用分散读写计数来提升磁盘 ...
- Python OpenCV4获取轮廓最大内切圆和外接圆
为了方便讲解,我们先来创建一个多边形做演示 第一步:创建图像,并绘制一个六边形.代码和生成图像如下: # Create an image r = 100 src = np.zeros((4*r, 4* ...