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' 的原因主要是版本的问题 解决方法是更新 ...
随机推荐
- 解决github clone慢的问题
github clone非常慢,解决方法,首先要有vpn 参考 https://www.zhihu.com/question/27159393 第一种方法 这种是没有vpn的方法,测试从10k到 几十 ...
- 加入mapstruct后出现 找不到符号 符号: 方法 setXX 的解决方法
加入lombok解决 <build> <plugins> <plugin> <groupId>org.springframework.boot</ ...
- 浅谈设计模式-visitor访问者模式
先看一个和visitor无关的案例.假设你现在有一个书架,这个书架有两种操作,1添加书籍2阅读每一本书籍的简介. //书架public class Bookcase { List<Book> ...
- Maven 教程(15)— 实现多个项目关联自动化构建(maven-invoker-plugin插件的使用)
原文地址:https://blog.csdn.net/liupeifeng3514/article/details/79726664 一.场景设想一个团队正在开发一个项目 bus-core-api,并 ...
- JVM一些问题
1. 类的实例化顺序,比如父类静态数据,构造函数,字段,子类静态数据,构造函数,字段,他们的执行顺序 答:先静态.先父后子. 先静态:父静态 > 子静态 优先级:父类 > 子类 静态代码块 ...
- CentOS7-部署测试Apollo
linux部署apollo环境要求:jdk1.8.mysql5.7 centos7安装jdk1.8跟mysql5.7可以参考我这两篇文章 https://www.cnblogs.com/reasonz ...
- Controller如何进行重定向跳转
因为在Controller的返回都是默认走视图解析器的InternalResourceViewResolver,而视图解析器都是进行请求转发,需要在返回时地址前加入字符redirect: 视图解析器不 ...
- 【洛谷】P1022 计算器的改良-全AC题解
#include <iostream> #include <cstring> #include <iomanip> using namespace std; int ...
- react项目添加本地音频
<audio src="./res/audio/alarm.mp3" autoplay="autoplay" loop="loop" ...
- log4net自动删除日志文件
晚上关于删除的日志文件主要有 https://blog.csdn.net/hellolib/article/details/78316253, 其实我这里的实现方式和他差不多,不过我这里不用配置时间, ...