【发布时间】:2019-01-25 15:49:01
【问题描述】:
我想在我的网络中组合 2 个不同层的输出,如下所示:
l1.shape
TensorShape([Dimension(None), Dimension(10), Dimension(100)])
l2.shape
TensorShape([Dimension(None), Dimension(20), Dimension(30)])
我想将层 l1 和 l2 组合起来,然后将它们提供给双 LSTM 层。我尝试了“连接”层,但它不起作用。我想要一些可以填充具有较低最后尺寸的层以获得与另一层相同的尺寸的东西。即:填充l2 的最后一个维度,得到以下两个:
l2_padded = some_function(l2, axis=-1, dim=l1.shape[-1])
l2_padded.shape
TensorShape([Dimension(None), Dimension(20), Dimension(100)])
然后进行拼接,
c = Concatenate(axis=1)([l1, l2_padded])
c.shape
TensorShape([Dimension(None), Dimension(30), Dimension(100)])
bilstm = Bidirectional(LSTM(100))(c)
# other layers ...
你能举一些例子和/或参考吗?
【问题讨论】:
标签: python-3.x merge keras-layer