tf.InteractiveSession()和tf.Session()
tf.InteractiveSession()适合用于python交互环境
tf.Session()适合用于源代码中
1、tf.InteractiveSession()
直接用eval()就可以直接获得结果,无需运行sess.run()

2、tf.Session()一般在代码中使用
import tensorflow as tf
import numpy as np vector_np = np.array([1,2,4])
vector_tf = tf.constant(vector_np) with tf.Session() as sess:
# print (sess.run(tensor_id.get_shape()))
print (sess.run(vector_tf))
注意:我遇到过这种情况,在pycharm编辑器,先在pycharm交互环境使用了tf.InteractiveSession(),没有用sess.close(),结果又在编辑器里运行代码tf.Session(),
结果可以想象报错了,所有在同一编辑器中不能同时使用启动两个session
tf.InteractiveSession()和tf.Session()的更多相关文章
- tf.InteractiveSession()与tf.Session()
tf.InteractiveSession():它能让你在运行图的时候,插入一些计算图,这些计算图是由某些操作(operations)构成的.这对于工作在交互式环境中的人们来说非常便利,比如使用IPy ...
- tf.InteractiveSession() 和 tf.Session() 的区别
tf.InteractiveSession():它能让你在运行图的时候,插入一些计算图,这些计算图是由某些操作(operations)构成的.这对于工作在交互式环境中的人们来说非常便利,比如使用IPy ...
- tf.InteractiveSession()与tf.Session()的区别
Tensorflow依赖于一个高效的C++后端来进行计算.与后端的这个连接叫做session.一般而言,使用TensorFlow程序的流程是先创建一个图,然后在session中启动它. 这里,我们使用 ...
- tensorflow函数解析: tf.Session() 和tf.InteractiveSession()
链接如下: http://stackoverflow.com/questions/41791469/difference-between-tf-session-and-tf-interactivese ...
- TensorFlow--交互式使用--tf.InteractiveSession()
用tf.Session()创建会话时只有在会话中run某个张量才能得到这个张量的运算结果,而交互式环境下如命令行.IPython,想要执行一行就得到结果,这就需要用到tf.InteractiveSes ...
- tf.Session()和tf.InteractiveSession()的区别
官方tutorial是这么说的: The only difference with a regular Session is that an InteractiveSession installs i ...
- tf.Session()、tf.InteractiveSession()
tf.Session()和tf.InteractiveSession()的区别 官方tutorial是这么说的: The only difference with a regular Session ...
- tf.variable和tf.get_Variable以及tf.name_scope和tf.variable_scope的区别
在训练深度网络时,为了减少需要训练参数的个数(比如具有simase结构的LSTM模型).或是多机多卡并行化训练大数据大模型(比如数据并行化)等情况时,往往需要共享变量.另外一方面是当一个深度学习模型变 ...
- TensorFlow 辨异 —— tf.placeholder 与 tf.Variable
https://blog.csdn.net/lanchunhui/article/details/61712830 https://www.cnblogs.com/silence-tommy/p/70 ...
随机推荐
- c++ 条件变量
.条件变量创建 静态创建:pthread_cond_t cond=PTHREAD_COND_INITIALIZER; 动态创建:pthread_cond _t cond; pthread_cond_i ...
- ubuntu更改镜像源
参考 https://blog.csdn.net/weixin_41762173/article/details/79480832 建议使用ustc.edu的源,其他例如清华的,阿里的连sublime ...
- Android实现夜间模式
如今非常多App都有夜间模式,特别是阅读类的App.夜间模式如今已经是阅读类App的标配了,其实,日间模式与夜间模式就是给App定义并应用两套不同颜色的主题,用户能够自己主动或者手动的开启,今天用An ...
- js实现十分钟内在页面无任何操作,页面跳转至登陆页
// 如果10分钟没有操作,退出到登录页 var timer; function startTimer(){ clearTimeout(timer); timer=setTimeout(functio ...
- gitlab-ci + k8s 之gitlab-ci(一)
目前常用的持续集成工具主要是jenkins与gitlab-ci ,我已在另一博文中详细记录了jenkins部署过程(其中包括gitlab的搭建),此篇介绍gitlab-ci的使用. 背景介绍 GitL ...
- sql脚本练习
多写sql语句,才能对数据库操作更加熟练. create database springbootdemo; use springbootdemo; create table user; // 这个脚本 ...
- sql语句的存储过程中的条件处理
SQL语句的crud操作很多可能是相似的,或者重复的,这时可以将其总结我一个存储过程,即函数,这样就可以实现代码复用,也就是函数. 这时候的控制语句就像编程语言c,java的一样,其中有很多关键词CA ...
- Solve Error: Library not loaded: @rpath/RoutingHTTPServer.framework/RoutingHTTPServer
在配置WebDriverAgent的时候,可能会遇到如下的错误: 2018-01-04 09:53:42.759370-0600 WebDriverAgentRunner-Runner[318:133 ...
- python 中的 list dict 与 set 的关系
转自: http://www.cnblogs.com/soaringEveryday/p/5044007.html list arraylist 实现(数组) List 通过内置的 append()方 ...
- 二、JavaScript基础(1)
1.JavaScript 基于对象和事件驱动的脚步语言,主要应用在客户端 特点:交互性(信息的动态交互).安全性(不可直接访问本地硬盘).跨平台性(只要可以解析js的浏览器 都可以执行,与平台无关) ...