tf.concat(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] ] 按照接拼接,多了三列 类似的函数还有一个tf.stack tf.stack(values, axis=0, name='stack'):按照指定的新建的轴进行拼接 tf.concat([t1, t2], 1) ==> [ [1, 2, 3, 7, 8, 9] [4, 5, 6, 10, 11, 12] ] tf.stack([t1, t2], 0) ==> [ [[1, 2, 3], [4, 5, 6]] [[7, 8, 9], [10, 11, 12]] ] 结果是三维矩阵,就0维和1维像堆叠在一起一样 tf.stack([t1, t2], 1) ==> [[[1, 2, 3], [7, 8, 9]], [[4, 5, 6], [10, 11, 12]]] tf.stack([t1, t2], 2) ==> [[[1, 7], [2, 8], [3, 9]], [[4, 10], [5, 11], [6, 12]]] 例子参见: https://colab.research.google.com/drive/1MWUJKxqbXHeVmzh3JctTRTNDtBf7WF-4