tf.stack(dim,axis,name)
在目标检测代码中用到这个函数,举例说明:
t1 = [[1,2,3],[4,5,6]] t2 = [[7,8,9],[10,11,12]] with tf.Session() as sess: print(sess.run(tf.stack([t1,t2],axis=0))) print('===================================') print(sess.run(tf.stack([t1, t2], axis=1)))
输出:
[[[ 1 2 3]
[ 4 5 6]]
[[ 7 8 9]
[10 11 12]]]
===================================
[[[ 1 2 3]
[ 7 8 9]]
[[ 4 5 6]
[10 11 12]]]
tf.concat(concat_dim,axis,name)
t1 = [[1,2,3],[4,5,6]] t2 = [[7,8,9],[10,11,12]] with tf.Session() as sess: print(sess.run(tf.concat([t1,t2],axis=0))) print('===================================') print(sess.run(tf.concat([t1, t2], axis=1)))
输出:
[[ 1 2 3]
[ 4 5 6]
[ 7 8 9]
[10 11 12]]
===================================
[[ 1 2 3 7 8 9]
[ 4 5 6 10 11 12]]