tf.concat(values,axis, name='concat'
)
作用:
在axis维度上对输入矩阵进行拼接
例子:
import tensorflow as tfa = tf.constant([[1, 2, 3], [4, 5, 6]])
b = tf.constant([[7, 8, 9], [10, 11, 12]])
c = tf.concat([a, b], axis=0)
d = tf.concat([a, b], axis=1)with tf.Session() as sess:sess.run(tf.global_variables_initializer())print(sess.run(c))print(sess.run(d))
输出:
c: axis=0是纵向拼接
[[ 1 2 3]
[ 4 5 6]
[ 7 8 9]
[10 11 12]]
d:axis=1是横向拼接
[[ 1 2 3 7 8 9]
[ 4 5 6 10 11 12]]