Adding static data( not changing over time) to sequence data in LSTM

倖福魔咒の 提交于 2019-12-12 10:02:30

问题


I am trying to build a model like the following figure. Please see the following image:

I want to pass sequence data in LSTM layer and static data (blood group, gender) in another feed forward neural network layer. Later I want to merge them. However, I am confused about the dimenstion here.

  • If my understaning is right(which i depict in the image), how the 5-dimensional sequence data can be merged with 4 dimenstional static data?
  • Also, what is the difference of attention mechanism with this structure? (I found in the KERAS documentation that attention mechanism is an way to add static data with sequence data)

Basically, I want to add the static data with sequence data. Any other suggestion is apprciated.


回答1:


I am not sure if I got what you are asking, but I will try.

Example in Keras:

static_out = (static_input)

x = LSTM(n_cell_lstm, return_sequences=True)(dynamic_input)
x = Flatten()(x)
dynamic_out = (x)

z = concatenate([dynamic_out, static_out])

z = Dense(64, activation='relu')(z)

main_output = Dense(classes, activation='softmax', name='main_output')(z)

Practically you are using an LSTM architecture as you would if you where using only the dynamic data, but at the end you add the info coming from the static data. Hope this helps.



来源:https://stackoverflow.com/questions/53363986/adding-static-data-not-changing-over-time-to-sequence-data-in-lstm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!