【问题标题】:Understanding the role of timestamp in Keras LSTM了解时间戳在 Keras LSTM 中的作用
【发布时间】:2020-11-28 21:24:43
【问题描述】:

给定一个包含 10232 个信号的信号数据集,每个 200K 暗淡 (10232, 200000) 用于分类目的。我对 Keras LSTM 的理解是它接受(samples, timestamp, features) 格式的数据。看了很多文章,发现 LSTM Keras 只接受 3D 的数据,所以我们应该首先将输入数据从 2D 扩展到 3D。以下是截图代码:

X = np.expand_dims(X, -1) # ---> (10232, 200000, 1)
input_layer = Input(shape=(X.shape[1], X.shape[2]))
lstm_ = LSTM(64, return_sequences=True)(input_layer)
lstm_ = Dropout(0.2)(lstm_)
lstm_ = LSTM(32, return_sequences=True)(lstm_)
lstm_ = Dropout(0.2)(lstm_)
lstm_ = LSTM(8)(lstm_)
output_layer = Dense(1, activation='sigmoid')(lstm_)
model = Model(inputs=input_layer, outputs=output_layer)

使时间戳等于每个时间序列X.shape[1] 的暗淡。我的问题是:如果我选择timestamp= 1000,即Input(shape=(1000, X.shape[2])),会发生什么?我认为这意味着它以某种方式将最初为 dim=200K 的每个时间序列划分为每个 dim=1000 的样本。Keras 会为我创建这些样本,每个样本都有 dim=1000,还是我应该手动执行?

谢谢

【问题讨论】:

    标签: python tensorflow keras lstm recurrent-neural-network


    【解决方案1】:

    如果您进行这些更改 - 您应该向网络序列提供 1000 个而不是 200K。 Keras 不会自动拆分 - 您必须手动进行。你应该为每1000个序列准备标签。

    【讨论】:

      猜你喜欢
      • 2016-12-07
      • 2018-04-07
      • 1970-01-01
      • 1970-01-01
      • 2019-07-17
      • 1970-01-01
      • 1970-01-01
      • 2020-07-11
      • 1970-01-01
      相关资源
      最近更新 更多