链接如下:

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. CentOS下的安装命令 安装Nginx 更新yum源 kali系统当中的软件管理命令(第五天)

    Linux下软件的安装:方式:yum/rpm/源码安装YUM安装(帮助管理员解决依赖关系):yum search mysqld 在源中搜索软件包yum install mysql-connector- ...

  2. 【LeetCode】最长公共子序列

    [问题]给定两个字符串A和B,长度分别为m和n,要求找出它们最长的公共子串,并返回其长度.例如:A = "HelloWorld"B = "loop"则A与B的最 ...

  3. 【LeetCode】最长回文子串-中心扩展法

    [问题]给定一个字符串 s,找到 s 中最长的回文子串.你可以假设 s 的最大长度为 1000. 示例 : 输入: "babad" 输出: "bab" 注意: ...

  4. js连续的日期判断,判断相差几天

    var startTime=Date.parse(new Date('2020-02-28')); var endTime=Date.parse(new Date('2020-02-29')); $. ...

  5. cf442 B.Andrey and Problem

    看题偷瞄到题解2333(以为是劲题呢..结果是乱贪心,奇怪) 排序之后,如果加入下一个比现在更优就更新答案(奇怪啊) t=ans*(1-a[i])+s*a[i];(ans*(1-a[i])是新的一位不 ...

  6. UltraISO制作manjaro系统盘,使用优盘

    下载系统镜像 默认是清华镜像 刻入方式一定要选RAW方式

  7. 如何保障Assignment写作效率?

    有没有因为开学要交的Assignment而日夜赶工.身心俱疲啊?写Assignment确实是个体力+脑力活,要一直保持旺盛的精力并不容易.精神和身体的疲劳会慢慢分散你的注意力,进而影响效率和写作质量. ...

  8. C#高级编程(第9版) 第08章 委托、lambda表达式和事件 笔记

          本章代码分为以下几个主要的示例文件: 1. 简单委托 2. 冒泡排序 3. lambda表达式 4. 事件示例 5. 弱事件     引用方法 委托是寻址方法的.NET版本.在C++中函数 ...

  9. Gym - 101142C CodeCoder vs TopForces(搜索)

    题意:给定n个人在两个网站上的得分,一个人若能在任意一个网站里战胜另一个人,则认为这个人能战胜那个人.问每个人都能战胜多少人. 分析: 1.战胜具有传递性. 例如: 4 5 2 7 3 3 因为第三个 ...

  10. IDEA--安装

    1:下载IDEA 官网:http://www.jetbrains.com/idea/download/#section=windows(选择下载.zip) 2:解压 3:破解: 1)在C:\Windo ...