tensorflow tf.reshape()

来源:互联网 发布:rabbitmq 默认端口 编辑:程序博客网 时间:2024/05/18 01:40

tf.reshape(tensor, shape, name=None)
函数的作用是将tensor变换为参数shape的形式。
其中shape为一个列表形式,特殊的一点是列表中可以存在-1。-1代表的含义是不用我们自己指定这一维的大小,函数会自动计算,但列表中只能存在一个-1.
例如:
假设matrix是9个tensor组成的,每个tensor的形状是(?,)
那么:
matrix=tf.reshape(matrix,[-1,3 , 3 , 1])
即表示
把maxtix的形状reshape成[?, 3, 3 ,1]