tf.stack和tf.unstack
2024-10-20 16:40:25
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
最新文章
- 浅谈:javascript的面向对象编程之基础知识的介绍
- PHP如何通过Http Post请求发送Json对象数据?
- 【目录】Newlife XCode组件相关文章目录
- 8个前沿的 HTML5 &; CSS3 效果【附源码下载】
- FZU 2191 完美的数字
- Sample MultipleFileWordcount CombineFileInputFormat
- weblogic 安装和部署项目(原创)
- python 基础学习(字典对象,set对象)
- DebugDiag收集Dump的使用说明
- lightoj 1020 (博弈)
- leetcode修炼之路——387. First Unique Character in a String
- Makefile中使用foreach生成一类规则
- 身份证js检测
- 【vim】插件管理及代码智能提示与补全环境的配置
- 字符串转json以及获取域名的参数
- BZOJ3613: [Heoi2014]南园满地堆轻絮
- MongoDB 中数据的替换方法实现 --类Replace()函数功能
- python3 字典dict
- Python判断字符集
- apache ab 压力测试工具
热门文章
- HTML5 2D平台游戏开发#4状态机
- c# emit 动态实现接口
- hashCode与equals的作用与区别及应当注意的细节
- jquery 获取 outerHtml
- XMLHttpRequest cannot load ''. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' ' is therefore not allowed access.
- git for windows 无法结束node进程(windows下杀进程)
- 【caffe】Caffe的Python接口-官方教程-00-classification-详细说明(含代码)
- Frege-基于JVM的类Haskell纯函数式编程语言
- C语言补漏(1)--- char到int赋值的一个陷阱
- Android-解决Fail to post notification on channel ";null";的方法