【问题标题】:N timeseries feed to one layer with N lstm cells, how to concatenate lstm horizontally as a layer?N个时间序列馈送到具有N个lstm单元的一层,如何将lstm水平连接为一层?
【发布时间】:2023-03-29 18:02:01
【问题描述】:

我试图暗示https://dl.acm.org/doi/pdf/10.1145/3269206.3271794

它有一个类似的网络结构

timeseries1 -> lstm1
timeseries2 -> lstm2
....
timeseriesN -> lstmN

[lstm1, lstm2, ... , lstmN] ->  CNN -> FC


我看到很多堆叠 lstm 层的例子,没有人告诉我如何水平连接多个 lstm 单元格。

现在,我有一个包含 4 个时间序列列的数据框: ['t1', 't2', 't3', 't4'] ,我如何构建具有四个水平连接的 lstm 单元格的模型?

【问题讨论】:

    标签: tensorflow keras lstm tensorflow2.0 tf.keras


    【解决方案1】:

    试试这个:

    import tensorflow as tf
    input1 = tf.keras.layers.Input((10, 10))
    input2 = tf.keras.layers.Input((10, 10))
    x1 = tf.keras.layers.LSTM(128)(input1)
    x2 = tf.keras.layers.LSTM(128)(input2)
    x = tf.concat([x1, x2], -1)
    model = tf.keras.Model(inputs=[input1, input2], outputs=x)
    trainx1 = tf.random.uniform([10, 10, 10])
    trainx2 = tf.random.uniform([10, 10, 10])
    pred = model((trainx1, trainx2))
    

    【讨论】:

      猜你喜欢
      • 2017-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多