tf的tf.concat tf.reshape操作
时间:2022-09-15 05:30:00
1.tf.concat(dim,values,name='concat')
连接两个矩阵的操作
dim:代表从这个维度连接的数值
values:矩阵需要连接
- t1=[[1,2],[3,4]]
- t2=[[5, 6],[7, 8]]
- tf.concat(0,[t1,t2])
- [[1,2],[3,4],[5, 6],[7, 8]]
2.tf.reshape(tensor, shape, name=None)
tensor:变形的向量
shape:变形的结果向量维度通常是一种向量形式,可以有-1,代表任何合适的值,但只有一个-1
- t = [1, 2, 3, 4]
- tf.reshape(t, [2, -1])
- [[1, 2], [3, 4]]