当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


Python tf.keras.layers.concatenate用法及代码示例

Concatenate 层的函数接口。

用法

tf.keras.layers.concatenate(
    inputs, axis=-1, **kwargs
)

参数

  • inputs 输入张量列表(至少 2 个)。
  • axis 串联轴。
  • **kwargs 标准层关键字参数。

返回

  • 张量,输入在轴 axis 旁边的串联。
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, 30).reshape(2, 1, 5)
print(y)
[[[20 21 22 23 24]]
 [[25 26 27 28 29]]]
tf.keras.layers.concatenate([x, y],
                            axis=1)
<tf.Tensor:shape=(2, 3, 5), dtype=int64, numpy=
array([[[ 0,  1,  2,  3,  4],
      [ 5,  6,  7,  8,  9],
      [20, 21, 22, 23, 24]],
     [[10, 11, 12, 13, 14],
      [15, 16, 17, 18, 19],
      [25, 26, 27, 28, 29]]])>

相关用法


注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.keras.layers.concatenate。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。