TensorFlow--交互式使用--tf.InteractiveSession()
用tf.Session()创建会话时只有在会话中run某个张量才能得到这个张量的运算结果,而交互式环境下如命令行、IPython,想要执行一行就得到结果,这就需要用到tf.InteractiveSession(),并且可以使用Tensor.eval() 得到张量的具体值。
import tensorflow as tf
sess = tf.InteractiveSession() a = tf.truncated_normal([1,5],stddev=0.1) # 创建一个1x5的随机张量 print(a) # >> Tensor("truncated_normal_1:0", shape=(1, 5), dtype=float32)
print(a.eval())
# >> array([[ 0.0331782 , -0.0733152 , 0.01366828, 0.01550526, 0.06196761]],dtype=float32)
TensorFlow--交互式使用--tf.InteractiveSession()的更多相关文章
- TensorFlow——交互式使用会话:InteractiveSession类
目的是在交互式环境下(如jupyter),手动设定当前会话为默认会话,从而省去每次都要显示地说明sess的繁琐,如:Tensor.ecal(session=sess)或sess.Operation.r ...
- tensorflow函数解析: tf.Session() 和tf.InteractiveSession()
链接如下: http://stackoverflow.com/questions/41791469/difference-between-tf-session-and-tf-interactivese ...
- 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.InteractiveSession()和tf.Session()
tf.InteractiveSession()适合用于python交互环境 tf.Session()适合用于源代码中 1.tf.InteractiveSession() 直接用eval()就可以直接获 ...
- TensorFlow高级API(tf.contrib.learn)及可视化工具TensorBoard的使用
一.TensorFlow高层次机器学习API (tf.contrib.learn) 1.tf.contrib.learn.datasets.base.load_csv_with_header 加载cs ...
- tf.InteractiveSession()与tf.Session()
tf.InteractiveSession():它能让你在运行图的时候,插入一些计算图,这些计算图是由某些操作(operations)构成的.这对于工作在交互式环境中的人们来说非常便利,比如使用IPy ...
- tf.InteractiveSession() 和 tf.Session() 的区别
tf.InteractiveSession():它能让你在运行图的时候,插入一些计算图,这些计算图是由某些操作(operations)构成的.这对于工作在交互式环境中的人们来说非常便利,比如使用IPy ...
- 【TensorFlow基础】tf.add 和 tf.nn.bias_add 的区别
1. tf.add(x, y, name) Args: x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, ...
随机推荐
- 「POJ3613」Cow Relays
「POJ3613」Cow Relays 传送门 就一个思想:\(N\) 遍 \(\text{Floyd}\) 求出经过 \(N\) 个点的最短路 看一眼数据范围,想到离散化+矩阵快速幂 代码: #in ...
- C语言for循环嵌套示例
打印九九乘法表 #include <stdio.h> int main() { int n,i,j; for (i=1;i<=9;i++) printf("%-4d&q ...
- 认识iOS系统架构
关于本文: 文章主要介绍iOS系统架构中的四层结构的内容.常用的框架.大致的功能,然后对iOS开发人员的发展提出自己的一些拙见. 一.iOS系统是基于UNIX系统,所有从系统稳定性上来说的确比其他操作 ...
- P3919 【模板】可持久化数组 -初步探究主席树
本篇blog主要是给自己(大家)看的. 感谢longlongzhu123奆佬(此人初二LCT)的指点,使本蒟蒻可以快速开始主席树入门. what is 主席树? $ $主席树这个名字只不 ...
- 微软结合Veritas,使用Azure云中的混合存储
导读 在与Symantec(Symantec)脱离10年(通常令人不愉快的关系)一周年之际,Veritas Technologies在2月22日宣布与Microsoft Corp. 建立了多年战略全球 ...
- ELK/EFK——日志收集分析平台
ELK——日志收集分析平台 ELK简介:在开源的日志管理方案之中,最出名的莫过于ELK了,ELK由ElasticSearch.Logstash和Kiabana三个开源工具组成.1)ElasticSea ...
- SpringMVC controller中业务方法的参数、返回值
业务方法的参数 业务方法的参数类型.参数个数是任意的,根据需要使用. 常见的参数类型: HttpServletRequest.HttpServletResponse.HttpSession 获取 ...
- 【Unity】双击物体
using UnityEngine; using System.Collections; using System; public class Click_yushe : MonoBehaviour ...
- Eclipse创建一个普通maven项目详细步骤
首先找到Eclipse最顶部左边的File,new一个 Maven Project项目 下一步,勾选第二个即可 下一步,选择 maven-archetype-webapp Group Id 写域名倒 ...
- greenplum 导入数据方式
参考: http://gpdb.docs.pivotal.io/4390/admin_guide/load/topics/g-working-with-file-based-ext-tables.ht ...