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

最新文章

  1. 浅谈:javascript的面向对象编程之基础知识的介绍
  2. PHP如何通过Http Post请求发送Json对象数据?
  3. 【目录】Newlife XCode组件相关文章目录
  4. 8个前沿的 HTML5 & CSS3 效果【附源码下载】
  5. FZU 2191 完美的数字
  6. Sample MultipleFileWordcount CombineFileInputFormat
  7. weblogic 安装和部署项目(原创)
  8. python 基础学习(字典对象,set对象)
  9. DebugDiag收集Dump的使用说明
  10. lightoj 1020 (博弈)
  11. leetcode修炼之路——387. First Unique Character in a String
  12. Makefile中使用foreach生成一类规则
  13. 身份证js检测
  14. 【vim】插件管理及代码智能提示与补全环境的配置
  15. 字符串转json以及获取域名的参数
  16. BZOJ3613: [Heoi2014]南园满地堆轻絮
  17. MongoDB 中数据的替换方法实现 --类Replace()函数功能
  18. python3 字典dict
  19. Python判断字符集
  20. apache ab 压力测试工具

热门文章

  1. HTML5 2D平台游戏开发#4状态机
  2. c# emit 动态实现接口
  3. hashCode与equals的作用与区别及应当注意的细节
  4. jquery 获取 outerHtml
  5. XMLHttpRequest cannot load ''. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' ' is therefore not allowed access.
  6. git for windows 无法结束node进程(windows下杀进程)
  7. 【caffe】Caffe的Python接口-官方教程-00-classification-详细说明(含代码)
  8. Frege-基于JVM的类Haskell纯函数式编程语言
  9. C语言补漏(1)--- char到int赋值的一个陷阱
  10. Android-解决Fail to post notification on channel "null"的方法