TensorFlow学习笔记(十八)tf.reshape矩阵变形
来源:互联网 发布:淘宝网首页登陆电脑版 编辑:程序博客网 时间:2024/06/11 22:48
tf.reshape(tensor, shape, name=None)
矩阵变形是常用的操作,在Tensorflow中调用方式有多种,例如:
1. tf.reshape
- tf.reshape(L3, [-1, W4.get_shape().as_list()[0]])
2. object.reshape
- mnist.test.images.reshape(-1, 28, 28, 1)
所有reshape函数中,关键的是shape这个参数
下以tf.reshape为例介绍shape参数对结果的影响
- tf.reshape(tensor, shape, name=None)
- # tensor 't' is [1, 2, 3, 4, 5, 6, 7, 8, 9]
- # tensor 't' has shape [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' has shape [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' has shape [3, 2, 3]
- # pass '[-1]' to flatten 't'
- reshape(t, [-1]) ==> [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]
- # -1 can also be used to infer the shape
- # -1 is inferred to be 9:
- reshape(t, [2, -1]) ==> [[1, 1, 1, 2, 2, 2, 3, 3, 3],
- [4, 4, 4, 5, 5, 5, 6, 6, 6]]
- # -1 is inferred to be 2:
- reshape(t, [-1, 9]) ==> [[1, 1, 1, 2, 2, 2, 3, 3, 3],
- [4, 4, 4, 5, 5, 5, 6, 6, 6]]
- # -1 is inferred to be 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 `[]` reshapes to a scalar
- reshape(t, []) ==> 7
阅读全文
0 0
- TensorFlow学习笔记(十八)tf.reshape矩阵变形
- TensorFlow学习笔记(五):tf.reshape用法
- 【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学习笔记(十六)tf.random_normal
- tensorflow学习笔记(三十):tf.gradients 与 tf.stop_gradient()
- tensorflow学习笔记(二十八):collection
- #tensorflow学习笔记#tf.gather
- tensorflow学习笔记--tf.one_hot
- TensorFlow学习笔记(5)----TF生成数据的方法
- tensorflow学习笔记(九):tf.shape()与tensor.get_shape()
- tensorflow学习笔记(二十六):构建TF代码
- Locker UVA
- Matlab 常用功能
- HBase架构中各组件的功能作用
- 自定义标识符的规范
- Ice系列--IceBox(1)
- TensorFlow学习笔记(十八)tf.reshape矩阵变形
- 史上最简单的 SpringCloud 教程 | 终章
- 关于原形值的优先级问题
- memcpy
- 面试题12:打印1到最大的n位数
- mysql大数据分库和分表 php解决方案
- ROS Robotics Projects(7)自主移动机器人
- Spark 数据倾斜 join 调优
- JAVA注释