链接如下:

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()的更多相关文章

  1. tensorflow函数解析:Session.run和Tensor.eval的区别

    tensorflow函数解析:Session.run和Tensor.eval 翻译 2017年04月20日 15:05:50 标签: tensorflow / 机器学习 / 深度学习 / python ...

  2. tensorflow函数解析:Session.run和Tensor.eval

    原问题链接: http://stackoverflow.com/questions/33610685/in-tensorflow-what-is-the-difference-between-sess ...

  3. tf.Session()、tf.InteractiveSession()

    tf.Session()和tf.InteractiveSession()的区别 官方tutorial是这么说的: The only difference with a regular Session ...

  4. 【转载】 TensorFlow函数:tf.Session()和tf.Session().as_default()的区别

    原文地址: https://blog.csdn.net/Enchanted_ZhouH/article/details/77571939 ------------------------------- ...

  5. tf.Session()和tf.InteractiveSession()的区别

    官方tutorial是这么说的: The only difference with a regular Session is that an InteractiveSession installs i ...

  6. tf.transpose函数解析

    tf.transpose函数解析 觉得有用的话,欢迎一起讨论相互学习~Follow Me tf.transpose(a, perm = None, name = 'transpose') 解释 将a进 ...

  7. tf.slice函数解析

    tf.slice函数解析 觉得有用的话,欢迎一起讨论相互学习~Follow Me tf.slice(input_, begin, size, name = None) 解释 : 这个函数的作用是从输入 ...

  8. 【转载】 TensorFlow学习——tf.GPUOptions和tf.ConfigProto用法解析

    原文地址: https://blog.csdn.net/c20081052/article/details/82345454 ------------------------------------- ...

  9. 深度学习原理与框架-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表示 ...

随机推荐

  1. 关于数据库text字段

    问题描述: maven项目中,使用MBG代码生成器自动生成的实体类对象时,当数据库中表的字段有 text 类型时,对应到java类中是String类型的,在前端页面通过ajax获取到 json 格式的 ...

  2. 业务全都在yun上能放心吗?

    导读 组织将其业务在云上进行“全押”,这与扑克游戏中的这个激动人心时刻有着同样的吸引力.这种举动感觉很大胆,但却向外界传达了自己的信心,表明将会果断行动赢得比赛. 大多数银行对处理零售银行业务方式需要 ...

  3. Day3-T3

    原题目 Describe:又是这种最大子矩阵捆绑一堆条件的题 code: #pragma GCC optimize(2) #include<bits/stdc++.h> #define j ...

  4. Java TCP发送与接收

    IP地址?端口号?主机名? 什么是Socket? 什么是UDP? 什么是TCP? UDP和TCP区别? 以上问题请自行百度,有标准解释,此处不再赘述,直接上干货! 实例: 发送端: public cl ...

  5. php-fpm启动 关闭 重启

    http://www.cnblogs.com/GaZeon/p/5421906.html 最近安装了mysqli扩展,重启了nginx后,phpinfo()没有显示出mysqli,后来搞不出原因,直接 ...

  6. GTK入门

    环境准备 官网下载 GTK 源码包,因为本机 GLib 版本不够,下载一个非最新版的 GTK3.8.0 先学习用 直接阅读 "/gtk+-3.8.0/docs/reference/gtk/h ...

  7. js事件函数中function(e){}

    简单来说就是指向了当前发生的事件(click.mouseover等等),保存了当前事件的信息.如鼠标点击事件,有鼠标的坐标信息.其中,e是标准浏览器传递进去的事件参数,低版本IE不会传递,事件参数放置 ...

  8. C++ DirectShow读取摄像头后然后保存图像数据

    #include <stdio.h> #include "camerads.h" #include <highgui.h> const char *g_sz ...

  9. js正则 -180 到180 小数点后无限位

    正则 -180 到180 小数点后无限位/^0$|^-?0\.\d*[1-9]$|^-?[1-9](\.\d*[1-9])?$|^-?[1-9]\d(\.\d*[1-9])?$|^-?1[0-7]\d ...

  10. Shell脚本exit用法与区别

    在Shell脚本中,往往会遇到一些判断类型为某个值不符合预期值的时候就退出主脚本/当前脚本/当前函数,那么Exit与return的用法与区别是什么呢? 下面先使用Exit举个简单例子,脚本内容如下 # ...