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 ...
随机推荐
- 【Qt】信号和槽对值传递参数和引用传递参数的总结
在同一个线程中 当信号和槽都在同一个线程中时,值传递参数和引用传递参数有区别: 值传递会复制对象:(测试时,打印传递前后的地址不同) 引用传递不会复制对象:(测试时,打印传递前后的地址相同) 不在同一 ...
- ubuntu安装thrift
ubuntu环境下安装thrift-0.10.0 1.解压 2.编译安装 ./configure -with-cpp -with-boost -without-python -without-csha ...
- centos7 RTMP直播服务器搭建
首先需要下载 nginx-1.8.1 : http://nginx.org/download/nginx-1.8.1.tar.gz nginx-rtmp-module : https://github ...
- zookeeper使用
ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,它包含一个简单的原语集,分布式应用程序可以基于它实现同步服务,配置维护和命名服务等.Zookeeper是hadoop的一个子项目,其 ...
- CentOS上安装配置Ruby on Rails
0.install sublime editor(optional) ref:http://www.tecmint.com/install-sublime-text-editor-in-linux/ ...
- 卸载ie
今天卸载ie11失败,最后使用下面这个命令实现了卸载,记录下 IE11卸载命令如下: FORFILES /P %WINDIR%\servicing\Packages /M Microsoft-Wind ...
- MYSQL中动态行数据转列数据
最近用到城市矩阵相关 需要将城市与城市距离转化为二维表 通过动态SQL直接实现 贴出来一起学习: 表就三个字段,包含在sql内. SET @sql:=''; SELECT @sql:=GROUP_CO ...
- c++ protobuf序列化
只看了int类型的序列化,后面的有时间再研究 #include <vector> #include <iostream> int main() { ; while (true) ...
- 五、Sql Server 基础培训《进度5-数据类型(知识点+实际操作)》
知识点: ================================================= ============================================= ...
- [转]GREP for Windows
http://www.interlog.com/~tcharron/grep.html A very flexible grep for windows GREP is a well known to ...