keras中shape维度的堆叠
import numpy as np
import keras.backend as K
import tensorflow as tf
#a.shape=(2,2,2)
a = K.variable(np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]))
#b.shape=(2,2,2)
b = K.variable(np.array([[[9, 10], [11, 12]], [[13, 14], [15, 16]]]))
不同维度axis堆叠
c1 = K.concatenate([a, b], axis=0) #c1.shape=(4,2,2)
c2 = K.concatenate([a, b], axis=1) #c2.shape=(2,4,2)
c3 = K.concatenate([a, b], axis=2) #c3.shape=(2,2,4)
c4 = K.concatenate([a, b]) #默认即从倒数第一个维度进行融合的,c4.shape=(2,2,4)
c5 = K.concatenate([a, b],axis=-1) #c5.shape=(2,2,4)