tensorflow API: tf.concat

来源:互联网 发布:大观园网络电视 编辑:程序博客网 时间:2024/06/11 19:00
tf.concatconcat(    values,    axis,    name='concat')

通过给定维度连接张量

例子:

t1 = [[1, 2, 3], [4, 5, 6]]t2 = [[7, 8, 9], [10, 11, 12]]tf.concat([t1, t2], 0)  # [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]tf.concat([t1, t2], 1)  # [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]]

tensor t3 with shape [2, 3]

tensor t4 with shape [2, 3]

tf.shape(tf.concat([t3, t4], 0))  # [4, 3]tf.shape(tf.concat([t3, t4], 1))  # [2, 6]
原创粉丝点击