tf.stack和tf.unstack
import tensorflow as tf a = tf.constant([1,2,3])
b = tf.constant([4,5,6]) c1 = tf.stack([a,b],axis=0)
c2 = tf.stack([a,b],axis=1)
#take c2 for example showing results of unstack
d1 = tf.unstack(c2,axis=0) # Return: The list of Tensor objects unstacked from value.
d2 = tf.unstack(c2,axis=1) with tf.Session() as sess:
print('c1(with shape:{}):\n{}'.format(c1.shape, sess.run(c1)))
print('c2(with shape:{}):\n{}'.format(c2.shape, sess.run(c2))) print('d1(with length:{}):\n{}'.format(len(d1), sess.run(d1)))
print('d2(with length:{}):\n{}'.format(len(d2), sess.run(d2)))
运行结果:
官方API:
https://www.tensorflow.org/api_docs/python/tf/stack
https://www.tensorflow.org/api_docs/python/tf/unstack
tf.stack和tf.unstack的更多相关文章
- tf.concat, tf.stack和tf.unstack的用法
tf.concat, tf.stack和tf.unstack的用法 tf.concat相当于numpy中的np.concatenate函数,用于将两个张量在某一个维度(axis)合并起来,例如: a ...
- tf.stack( )和tf.unstack( )
相同点:他们都增加了矩阵的维度,而split()不改变维度! tf.stack()这是一个矩阵拼接的函数,tf.unstack()则是一个矩阵分解的函数 c是拼接,而d和e则是不同维度的分解
- tf.unstack()、tf.stack()
tf.unstack 原型: unstack( value, num=None, axis=0, name='unstack' ) 官方解释:https://tensorflow.google.cn/ ...
- np.stack() 与 tf.stack() 的简单理解
说明:np ----> numpy tf ----> tensorflownp.stack(arrays, axis=0) np.stack(arrays, axis=0) - ...
- tensorflow 基本函数(1.tf.split, 2.tf.concat,3.tf.squeeze, 4.tf.less_equal, 5.tf.where, 6.tf.gather, 7.tf.cast, 8.tf.expand_dims, 9.tf.argmax, 10.tf.reshape, 11.tf.stack, 12tf.less, 13.tf.boolean_mask
1. tf.split(3, group, input) # 拆分函数 3 表示的是在第三个维度上, group表示拆分的次数, input 表示输入的值 import tensorflow ...
- tf.variable和tf.get_Variable以及tf.name_scope和tf.variable_scope的区别
在训练深度网络时,为了减少需要训练参数的个数(比如具有simase结构的LSTM模型).或是多机多卡并行化训练大数据大模型(比如数据并行化)等情况时,往往需要共享变量.另外一方面是当一个深度学习模型变 ...
- 【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`, ...
- TensorFlow 辨异 —— tf.placeholder 与 tf.Variable
https://blog.csdn.net/lanchunhui/article/details/61712830 https://www.cnblogs.com/silence-tommy/p/70 ...
- TF.VARIABLE、TF.GET_VARIABLE、TF.VARIABLE_SCOPE以及TF.NAME_SCOPE关系
1. tf.Variable与tf.get_variable tensorflow提供了通过变量名称来创建或者获取一个变量的机制.通过这个机制,在不同的函数中可以直接通过变量的名字来使用变量,而不需要 ...
随机推荐
- 在C#中怎样推断线程当前所处的状态
在C#中怎样推断线程当前所处的状态 老帅 在C#中.线程对象Thread使用ThreadState属性指示线程状态.它是带Flags特性的枚举类型对象. ThreadState 为线 ...
- webapi设置一个Action同时支持get和post请求
代码如下: [AcceptVerbs("GET", "POST")] public HttpResponseMessage Http([FromUri]Prox ...
- Struts2学习一----------Struts2的工作原理及HelloWorld简单实现
© 版权声明:本文为博主原创文章,转载请注明出处 Struts2工作原理 一个请求在Struts2框架中的处理步骤: 1.客户端初始化一个指向Servlet容器(例如Tomcat)的请求 2.这个请求 ...
- jquery文档处理如after错误
$('.foo').after('<li>0<li>')会添加两个元素 $('.foo').after('<li>o</li>')只会添加一个元素 所以 ...
- JavaScript读书笔记(6)-Array RegExp
1.Array类型 ECMAScript数组的每一项可以保存任何类型的数据,数组的大小也可以动态调整: (1) 创建数组 第一种方式:Array构造函数 var colors=new Array(); ...
- WinDbg调试分析 net站点 CPU100%问题
WinDbg调试分析 asp.net站点 CPU100%问题 公司为了节省成本,最近有一批服务器降了配置,CPU从8核降到了2核.本身是小站点,访问量也不高,CPU总是会飙到100%而且可以一直持续几 ...
- zeroMQ研究(转)
偶尔一个机会,了解了下zeroMQ消息队列. 1 ZeroMQ概述 ZeroMQ是一种基于消息队列的多线程网络库,其对套接字类型.连接处理.帧.甚至路由的底层细节进行抽象,提供跨越多种传输协议的套接 ...
- Mysql 的存储引擎,myisam和innodb的区别。
简单的表达. MyISAM 是非事务的存储引擎. innodb是支持事务的存储引擎. innodb的引擎比较适合于插入和更新操作比较多的应用 而MyISAM 则适合用于频繁查询的应用 MyISAM - ...
- 微信小程序页面布局之弹性布局-Flex介绍
布局的传统解决方案,基于盒状模型,依赖 display 属性 + position属性 + float属性.它对于那些特殊布局非常不方便,比如,垂直居中就不容易实现. 2009年,W3C 提出了一种新 ...
- Java 学习 day05
01-面向对象(概述) 面向对象 -- 冰箱.打开:冰箱.存储:冰箱.关闭: 02-面向对象(举例) 使用和指挥 -- 对象,不需要关注过程,只关注结果: 一切皆对象,万物皆对象 -- 自<T ...