concatenate从名字可以看出是连接两个数组,下面用一个小例子演示其用法
import numpy as np
import cv2
import keras.backend as K
import tensorflow as tf
a = K.variable(np.array([[1 , 2, 3]]))
b = K.variable(np.array([[3 , 2, 1]]))
c1 = K.concatenate([a , b] , axis=0)
c2 = K.concatenate([a , b] , axis=-1)
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
print(sess.run(c1))
print(sess.run(c2))
# [[1. 2. 3.]
# [3. 2. 1.]]
# [[1. 2. 3. 3. 2. 1.]]