當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。