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' 的原因主要是版本的问题 解决方法是更新 ...
随机推荐
- java添加新表,接口合成流程必看
生成代码后 创建模块包 先放入 实体类 然后按照 Controller 改成 然后是 service 后impl 然后是mapper 后xml 然后更新 代码
- scrapy-模块
爬虫模块:beautifulsoup4 scrapy_splash: pip install scrapy_splash scrapy_splash模块,与selenium类似,用来获取js渲染后的h ...
- 阿里云物联网平台: Android 连接阿里云物联网平台
说明 这节是是为下一节做铺垫的 只要是按照我提供的学习路线一节一节的认认真真学过来的,这节就十分的简单 有了前两节的基础,这节呢咱让Android 连接阿里云物联网平台 使用这节的代码 https: ...
- getpeername、getsockname
函数原型: #include<sys/socket.h> int getsockname(int sockfd, struct sockaddr *localaddr, socklen_t ...
- elasticsearch容量规划
https://docs.bonsai.io/article/123-capacity-planning Capacity Planning Capacity planning is the proc ...
- C# IE浏览器操作类
using System; using System.Collections.Generic; using System.Drawing; using System.Runtime.InteropSe ...
- 内网服务器离线编译安装mysql5.7并调优
目录 内网服务器离线编译安装mysql5.7并调优 前言 关于MySQL 一.MySQL安装篇 部署环境 前期准备工具 挂载系统ISO镜像,配置yum源 二.MySQL调优篇 1.对MySQL进行安全 ...
- idea 设置默认的maven
idea版本2019.2 设置maven 按照上图中的1-4顺序进行配置,就可以让以后每一个工程使用我们指定的配置了. 1:打开maven配置界面. 2:点击后面的三角符号,使maven列表显示,并在 ...
- 【简记】修改Docker数据目录位置,包含镜像位置
为啥要改? Docker安装后默认下载的位置在/var/lib/docker ,如果/var分区没有独立分出来,Linux下默认是与/根分区在一起.一般我们装Linux系统的时候,除了做邮件服务器外, ...
- Java学习:集合双列Map
数据结构 数据结构: 数据结构_栈:先进后出 入口和出口在同一侧 数据结构_队列:先进先出 入口和出口在集合的两侧 数据结构_数组: 查询快:数组的地址是连续的,我们通过数组的首地址可以找到数组,通过 ...