【Tensorflow】tf.reshape 函数
来源:互联网 发布:2015网络热门词汇 编辑:程序博客网 时间:2024/05/22 04:31
tf.reshape(tensor, shape, name=None) 数据重定形状函数
参数:
- tensor:输入数据
- shape:目标形状
- name:名称
例:
# tensor 't' is [1, 2, 3, 4, 5, 6, 7, 8, 9]# tensor 't' 的形状就是 [9]reshape(t, [3, 3]) ==> [[1, 2, 3], [4, 5, 6], [7, 8, 9]]# tensor 't' is [[[1, 1], [2, 2]],# [[3, 3], [4, 4]]]# tensor 't' 当前形状是 [2, 2, 2]reshape(t, [2, 4]) ==> [[1, 1, 2, 2], [3, 3, 4, 4]]# tensor 't' is [[[1, 1, 1],# [2, 2, 2]],# [[3, 3, 3],# [4, 4, 4]],# [[5, 5, 5],# [6, 6, 6]]]# tensor 't' 形状是 [3, 2, 3]# pass '[-1]' 扁平化 't'reshape(t, [-1]) ==> [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]# -1 也可以被用于shape中# -1 被推断结果是 9:reshape(t, [2, -1]) ==> [[1, 1, 1, 2, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 5, 6, 6, 6]]# -1 被推断结果是 2:reshape(t, [-1, 9]) ==> [[1, 1, 1, 2, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 5, 6, 6, 6]]# -1 被推断结果是 3:reshape(t, [ 2, -1, 3]) ==> [[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]]# tensor 't' is [7]# shape `[]` 重塑为标量,用[]的时候,t只是有一个元素,不然会报错reshape(t, []) ==> 7测试代码import tensorflow as tft = [7]k = tf.reshape(t,[])sess = tf.Session()kk = sess.run(k)print(kk)
0 0
- 【Tensorflow】tf.reshape 函数
- tensorflow: tf.reshape探究
- tensorflow tf.reshape()
- TensorFlow的reshape操作 tf.reshape
- TensorFlow的reshape操作 tf.reshape
- TensorFlow的reshape操作 tf.reshape
- TensorFlow的reshape操作 tf.reshape
- tensorflow的reshape操作tf.reshape()
- Tensorflow里的reshape函数
- tf.reshape
- tf.reshape()
- 【Tensorflow】tf.placeholder函数
- 【Tensorflow】tf.argmax函数
- Tensorflow tf.placeholder函数
- 【Tensorflow】tf.Graph()函数
- 【Tensorflow】tf.placeholder函数
- 【Tensorflow】tf.concat函数
- TensorFlow学习笔记(五):tf.reshape用法
- csdn博客暂停使用通知
- Django项目开发举例之用户界面表单(6)
- 【Linux】 JDK安装及配置 (tar.gz版)
- android sqlite数据库并发问题的详细描述和解决方案
- 微信多图上传,解决android多图上传失败问题
- 【Tensorflow】tf.reshape 函数
- 热更新Tinker研究(四):TinkerLoader
- 在C/C++中调用Java代码
- 接口测试-postman入门基础
- MyBatis参数传递的问题
- 解析地图api工具类
- java爬虫 抓取国家统计局:统计用区划代码和城乡划分代码(抓取省市区镇县办事处村委会数据)生成json
- linux 消息队列机制
- 静态联编与动态联编