tensorflow中用来拼接张量的函数tf.concat(),用法:
import tensorflow as tf
t1 = [[1, 2, 3], [4, 5, 6]]
t2 = [[7, 8, 9], [10, 11, 12]]
a=tf.concat([t1, t2], 0) # [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]
b=tf.concat([t1, t2], 1) # [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]]
with tf.Session() as sess:
[aa,bb]= sess.run([a,b])
print(aa)#[[ 1 2 3]
# [ 4 5 6]
# [ 7 8 9]
# [10 11 12]]
print(bb)#[[ 1 2 3 7 8 9]
# [ 4 5 6 10 11 12]]