【发布时间】:2019-03-19 02:24:24
【问题描述】:
我正在尝试在 Keras 中重新实现这篇论文 1,因为作者使用了 PyTorch 2。这是网络架构: 到目前为止我所做的是:
number_of_output_classes = 1
hidden_size = 100
direc = 2
lstm_layer=Bidirectional(LSTM(hidden_size, dropout=0.2, return_sequences=True))(combined) #shape after this step (None, 200)
#weighted sum and attention should be here
attention = Dense(hidden_size*direc, activation='linear')(lstm_layer) #failed trial
drop_out_layer = Dropout(0.2)(attention)
output_layer=Dense(1,activation='sigmoid')(drop_out_layer) #shape after this step (None, 1)
我想在 LSTM 之后包含注意力层和最终的 FF 层,但由于尺寸和 return_sequence=True 选项,我遇到了错误。
【问题讨论】:
-
任何可以共享代码的 github 存储库
标签: python keras deep-learning nlp