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提供了通过变量名称来创建或者获取一个变量的机制.通过这个机制,在不同的函数中可以直接通过变量的名字来使用变量,而不需要 ...
随机推荐
- 设计模式之Protocol实现代理模式
使用场合 使用步骤 不使用protocol实现代理 使用protocol实现代理 一.使用场合 A想让B帮忙,就让B代理 A想通知B发生了一些事情,或者传一些数据给B 观察者模式 二.使用步骤 定义一 ...
- Oracle的主键约束、唯一约束与外键约束
http://www.shangxueba.com/jingyan/122163.html主键: 1.主键约束: 一个表只能有一个主键约束.主键可以是单个字段,也可以是多个字段.无论是哪种情况,其所 ...
- 系统安全-Google authenticator
对于某些人来说,盗取密码会比你想象的更简单 以下任意一种常见的操作都可能让你的密码面临被盗的风险: 在多个网站上使用同一个密码 从互联网上下载软件 点击电子邮件中的链接 两步验证可以将别有用心的人阻 ...
- VS中单元测试用法
using System; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace UnitTestProject1 { [Test ...
- 跟我一起写 Makefile(一)[转]
原文链接 http://bbs.chinaunix.net/thread-408225-1-1.html(出处: http://bbs.chinaunix.net/) 陈皓 概述—— 什么是makef ...
- 移动应用开发测试工具Bugtags集成和使用教程【转载】
前段时间,有很多APP突然走红,最终却都是樱花一现.作为一个创业团队,突然爆红是非常难得的机会.然并卵,由于没有经过充分的测试,再加上用户的激增,APP闪退.服务器数据异常等问题就被暴露出来,用户的流 ...
- CentOS 配置网络
1.编辑ifcfg-eth0 vi /etc/sysconfig/network-scripts/ifcfg-eth0 2.修改NOBOOT=yes 3.重启服务 service network re ...
- 10个迷惑新手的Cocoa&Objective-c开发问题
本文转载至 http://blog.csdn.net/lvxiangan/article/details/27964733 language background runtime thre ...
- 14、AppWidget及Launcher RemoteViews
一.Launcher的简单研究 1 什么是Launcher Android系统启动后加载的第一个程序 . 这个程序是其他应用程序的入口 . Launcher构成: HomeScreen : (Work ...
- Channel (digital image) 通道 色彩深度 Color_depth
en.wikipedia.org/wiki/Channel_(digital_image) Color digital images are made of pixels, and pixels ar ...