tf.concat()
阿新 • • 發佈:2018-12-17
tf.concat(
values,
axis,
name='concat'
)
作用:
在axis維度上對輸入矩陣進行拼接
例子:
import tensorflow as tf a = 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]]