Keras:如何将两个层而不是 Elementwise 组合成更大的形状

所以我想在我的 keras-nn 中将多个层合并为 1。不同之处在于,我不想像在Add()-layer 中那样组合它们,但我想将具有不同形状但尺寸相同的多个层组合成一个更大的层,其形状是输入层的总和。这是我非常粗略的绘制结构(点代表一个节点):

http://img1.mukewang.com/626404c80001657610120794.jpg

这是一些我想象的代码:


[IN]

input_1 = Input(shape=(4,))

input_2 = Input(shape=(6,))


combined = Combined()([input_1, input_2])

print(input_1.shape, input_2.shape, input_3.shape)



[OUT]

(4,)  (6,)  (10,)

keras中可能已经有一个具有该功能的Layer,但是我浏览了互联网一段时间,找不到任何解决此问题的方法


慕沐林林
浏览 111回答 1
1回答

梵蒂冈之花

你想要的是Concatenate图层:input_1 = Input(shape=(4,))input_2 = Input(shape=(6,))combined = Concatenate()([input_1, input_2])print(input_1.shape, input_2.shape, combined.shape)这输出:(?, 4) (?, 6) (?, 10)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python