链接如下:

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. 2016蓝桥杯决赛C/C++A组第四题 路径之谜

    题意: 小明冒充X星球的骑士,进入了一个奇怪的城堡.城堡里边什么都没有,只有方形石头铺成的地面. 假设城堡地面是 n x n 个方格.[如图1.png]所示. 按习俗,骑士要从西北角走到东南角.可以横 ...

  2. 每天一点点之vue框架开发 - 使用vue-router路由

    1.安装路由(安装过的跳过此步) // 进入项目根目录 cd frontend // 安装 npm install vue-router --save-dev 2.在入口文件main.js中引入路由 ...

  3. POJ 2187:Beauty Contest 求给定一些点集里最远的两个点距离

    Beauty Contest Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 31414   Accepted: 9749 D ...

  4. bzoj 1009GT考试

    做了上一道题,全程懵逼,再做这一道,,,23333继续 貌似那些东西都是差不多的.(参见cf621E) 这个为什么b[][]+=1很困惑,为什么不是从b[-1][??]转移的呢?想了一下,因为每一次都 ...

  5. Flexslider插件实现图片轮播、文字图片相结合滑动切换效果

    插件下载: 点击下载 密码: fbeg Flexslider具有以下特性: 支持滑动和淡入淡出效果. 支持水平.垂直方向滑动. 支持键盘方向键控制. 支持触控滑动. 支持图文混排,支持各种html元素 ...

  6. repr. str, ascii in Python

    repr和str a="Hello" print(str(a)) print(repr(a)) 结果: Hello 'Hello' 可以看出,repr的结果中多了左右两个引号. r ...

  7. UVA - 10285 Longest Run on a Snowboard(最长的滑雪路径)(dp---记忆化搜索)

    题意:在一个R*C(R, C<=100)的整数矩阵上找一条高度严格递减的最长路.起点任意,但每次只能沿着上下左右4个方向之一走一格,并且不能走出矩阵外.矩阵中的数均为0~100. 分析:dp[x ...

  8. form——验证器Validators

    form表单最大的作用就是验证功能了,通过cleaned_data清洗,我们可以获取传来的值,通过参数.验证器.自定义验证方法,我们可以做到很多的验证. 验证器可用于在不同类型的字段之间重用验证逻辑. ...

  9. HTML5 Canvas——基础入门

    认识canvas html5的新标签 <canvas>标签只是图像容器,必须使用js来绘制图形 可以通过多种方法使用canvas绘制路径,盒,圆,字符以及添加图像 canvas画布 < ...

  10. 算概率(dp,数论)

    链接:https://ac.nowcoder.com/acm/contest/3003/C来源:牛客网 题目描述 牛牛刚刚考完了期末,尽管牛牛做答了所有 n 道题目,但他不知道有多少题是正确的. 不过 ...