【问题标题】:feed LSTM in keras在 keras 中喂 LSTM
【发布时间】:2017-05-19 18:41:21
【问题描述】:

我对 keras 很陌生。我想知道是否有人可以帮助我如何用我的 EEG 数据为 LSTM 提供数据。我有来自 306 个通道的 1400 次试验,长度为 600 点。

1- 我想创建一个 LSTM 网络,在每个时间步 t,第一层获取所有通道的输入(所有 EEG 通道最初都馈入同一个 LSTM 层)

2- 另一个网络由几个 306 个 LSTM 组成,每个 LSTM 在第一层只连接一个输入通道,然后是第二个编码层 通过接收连接的输入作为输入,执行通道间分析 所有通道 LSTM 的输出向量。

谢谢

【问题讨论】:

    标签: keras keras-layer


    【解决方案1】:

    如果我理解正确的话,代码应该是这样的:

    def lstm_model():
       hidden_units = 512  # may increase/decrease depending on capacity needed
       timesteps = 600
       input_dim = 306
       num_classes = 10    # num of classes for ecg output
       model = Sequential()
       model.add(LSTM(hidden_units, input_shape=(timesteps, input_dim)))
       model.add(Dense(num_classes))
       adam = Adam(lr=0.001)
       model.compile(loss='categorical_crossentropy', optimizer=adam, metrics=['accuracy'])
       return model
    
    def train():
       xt = np.array([])  # input_data shape = (num_trials, timesteps, input_dim)
       yt = np.array([])  # out_data shape = (num_trials, num_classes)
       batch_size = 16
       epochs = 10
       model = lstm_model()
       model.fit(xt, yt, epochs=epochs, batch_size=batch_size, shuffle=True)
    

    【讨论】:

    • 非常感谢您的帮助:)
    猜你喜欢
    • 2019-07-03
    • 1970-01-01
    • 1970-01-01
    • 2019-02-28
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 2018-01-15
    • 2016-12-07
    相关资源
    最近更新 更多