concatenate的使用
tf.keras.layers.Concatenate(axis=-1, **kwargs)
- Layer that concatenates a list of inputs.
在一层中将输入进行拼接 - It takes as input a list of tensors, all of the same shape except for the concatenation axis, and returns a single tensor that is the concatenation of all inputs.
将输入的tensors按照拼接的维度进行拼接,拼接的时候除了待拼接的维度尺寸可以不一样,其他的要保持一致。
解释一下axis的具体含义。
axis表示从第几个维度去拼接。
axis =0; 表示从第一个维度去拼接。
axis =1; 表示从第二个维度去拼接。
axis =2; 表示从第三个维度去拼接。
具体解释见代码如下:
>>> x = np.arange(20).reshape(2, 2, 5)
>>> print(x)
[[[ 0 1 2 3 4]
[ 5 6 7 8 9]]
[[10 11 12 13 14]
[15 16 17 18 19]]]
>>> y = np.arange(20, 40).reshape(2, 2, 5)
>>> print(y)
[[[20 21 22 23