tensorflow函数解析: tf.Session() 和tf.InteractiveSession()
链接如下:
http://stackoverflow.com/questions/41791469/difference-between-tf-session-and-tf-interactivesession
英文
Question:
Questions says everything, for taking sess=
tf.Session() and sess=tf.InteractiveSession() which cases should be
considered for what purpose ? When I am using former one some function
didn't work and when changed to the later it worked (for
example .eval()).
Answer:
Mainly taken from official documentation:
The
only difference with a regular Session is that an InteractiveSession
installs itself as the default session on construction. The methods
Tensor.eval() and Operation.run() will use
that session to run ops.
This allows to use interactive context, like shell, as it avoids having to pass an explicit Session object to run op:
sess = tf.InteractiveSession()
a = tf.constant(5.0)
b = tf.constant(6.0)
c = a * b
# We can just use 'c.eval()' without passing 'sess'
print(c.eval())
sess.close()
It is also possible to say, that InteractiveSession supports less typing, as allows to run variables without needing to constantly refer to the session object.
中文
问题: tf.Session()和tf.InteractiveSession()的区别?
答案:
唯一的区别在于:tf.InteractiveSession()加载它自身作为默认构建的session,tensor.eval()和operation.run()取决于默认的session.
换句话说:InteractiveSession 输入的代码少,原因就是它允许变量不需要使用session就可以产生结构。
tensorflow函数解析: tf.Session() 和tf.InteractiveSession()的更多相关文章
- tensorflow函数解析:Session.run和Tensor.eval的区别
tensorflow函数解析:Session.run和Tensor.eval 翻译 2017年04月20日 15:05:50 标签: tensorflow / 机器学习 / 深度学习 / python ...
- tensorflow函数解析:Session.run和Tensor.eval
原问题链接: http://stackoverflow.com/questions/33610685/in-tensorflow-what-is-the-difference-between-sess ...
- tf.Session()、tf.InteractiveSession()
tf.Session()和tf.InteractiveSession()的区别 官方tutorial是这么说的: The only difference with a regular Session ...
- 【转载】 TensorFlow函数:tf.Session()和tf.Session().as_default()的区别
原文地址: https://blog.csdn.net/Enchanted_ZhouH/article/details/77571939 ------------------------------- ...
- tf.Session()和tf.InteractiveSession()的区别
官方tutorial是这么说的: The only difference with a regular Session is that an InteractiveSession installs i ...
- tf.transpose函数解析
tf.transpose函数解析 觉得有用的话,欢迎一起讨论相互学习~Follow Me tf.transpose(a, perm = None, name = 'transpose') 解释 将a进 ...
- tf.slice函数解析
tf.slice函数解析 觉得有用的话,欢迎一起讨论相互学习~Follow Me tf.slice(input_, begin, size, name = None) 解释 : 这个函数的作用是从输入 ...
- 【转载】 TensorFlow学习——tf.GPUOptions和tf.ConfigProto用法解析
原文地址: https://blog.csdn.net/c20081052/article/details/82345454 ------------------------------------- ...
- 深度学习原理与框架-Tensorflow基本操作-变量常用操作 1.tf.random_normal(生成正态分布随机数) 2.tf.random_shuffle(进行洗牌操作) 3. tf.assign(赋值操作) 4.tf.convert_to_tensor(转换为tensor类型) 5.tf.add(相加操作) tf.divide(相乘操作) 6.tf.placeholder(输入数据占位
1. 使用tf.random_normal([2, 3], mean=-1, stddev=4) 创建一个正态分布的随机数 参数说明:[2, 3]表示随机数的维度,mean表示平均值,stddev表示 ...
随机推荐
- POJ 1584:A Round Peg in a Ground Hole
A Round Peg in a Ground Hole Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5741 Acc ...
- poj 3693 Maximum repetition substring
呵呵呵呵呵呵呵呵呵呵,sb(神犇)题看了一天,还是不懂 题目要求的是最多重复的,那么就来找重复的,可以先枚举一个重复的单元(比如ababab,就枚举ab)的长度, 然后再原串中,会有ch[0],ch[ ...
- 苹果maccms网站漏洞进行修复解决方法教程
上期发现视频名称中包含木马文件 然后教大家使用标签进行过滤 {$vo.vod_name|mac_filter_html} 可是最近发现现在黑客行为是全字段挂马,修改数据字段格式挂马,多重嵌套挂马. 真 ...
- 关于torch.flatten的笔记
先看函数参数: torch.flatten(input, start_dim=0, end_dim=-1) input: 一个 tensor,即要被“推平”的 tensor. start_dim: “ ...
- Nginx系列p4:进程结构
Nginx 有两种进程结构:单进程结构,多进程结构.本篇文章我们主要说多进程结构. 问:那为什么 Nginx 采用多进程结构,而不是多线程结构呢? 答:这是因为 Nginx 最核心的目的就是要保证高可 ...
- POJ - 1127 Jack Straws(几何)
题意:桌子上放着n根木棍,已知木棍两端的坐标.给定几对木棍,判断每对木棍是否相连.当两根木棍之间有公共点或可以通过相连的木棍间接的连在一起,则认为是相连的. 分析: 1.若线段i与j平行,且有部分重合 ...
- Tensorflow学习教程------tensorboard网络运行和可视化
tensorboard可以将训练过程中的一些参数可视化,比如我们最关注的loss值和accuracy值,简单来说就是把这些值的变化记录在日志里,然后将日志里的这些数据可视化. 首先运行训练代码 #co ...
- ..\OBJ\LED.axf: Error: L6218E: Undefined symbol EXTI_Init (referred from exti.o). 错误修改
今天在移植野火的程序到元子的开发平台上时候,发现自己在中断初话中断函数的时候出现了:..\OBJ\LED.axf: Error: L6218E: Undefined symbol EXTI_Init ...
- BZOJ [Cqoi2017] 小Q的棋盘
题解:枚举最后在哪里停止,然后剩下的步数/2 也就是找最大深度 枚举终止位置算是一种思路吧 #include<iostream> #include<cstdio> #inclu ...
- Python中Opencv和PIL.Image读取图片的差异对比
近日,在进行深度学习进行推理的时候,发现不管怎么样都得不出正确的结果,再仔细和正确的代码进行对比了后发现原来是Python中不同的库读取的图片数组是有差异的. image = np.array(Ima ...