为什么我使用 LSTM 的训练结果都小于 1 且不准确?

乘风 deep-learning 216

原文标题Why my train perditions using LSTM are all less than one and not accurate?

我是深度学习的新手,并试图根据确诊病例的数量开发用于 COVID-19 时间序列预测的 LSTM。

这是我的数据集:

数据集

我尝试了以下参数。但是,我得到的所有结果都少于一个。你能帮帮我吗?

X_train1, y_train1 = X1[:500], y1[:500] 
X_val1, y_val1 = X1[500:550], y1[500:550]
X_test1, y_test1 = X1[550:], y1[550:]
X_train1.shape, y_train1.shape, X_val1.shape, y_val1.shape, 
X_test1.shape, y_test1.shape

((500, 5, 1), (500,), (50, 5, 1), (50,), (218, 5, 1), (218,))

model1 = Sequential()
model1.add(InputLayer((5, 1)))
model1.add(LSTM(64))
model1.add(Dense(8, 'relu'))
model1.add(Dense(1, 'linear'))

cp1 = ModelCheckpoint('model1/', save_best_only=True)
model1.compile(loss=MeanSquaredError(), optimizer=Adam(learning_rate=0.0001), metrics=[RootMeanSquaredError()])

model1.fit(X_train1, y_train1, validation_data=(X_val1, y_val1), epochs=10, callbacks=[cp1])

请查看此图片以获取结果样本:结果样本

原文链接:https://stackoverflow.com//questions/71665641/why-my-train-perditions-using-lstm-are-all-less-than-one-and-not-accurate

回复

我来回复
  • Ali Haider的头像
    Ali Haider 评论

    如果您可以共享更多代码,那就太好了。我的预感是您在训练期间对数据进行了规范化,因此模型的预测也被规范化了。对它们进行非规范化可能会给您想要的结果。

    2年前 0条评论
  • pyaj的头像
    pyaj 评论

    将您的输入训练、验证和测试数据重塑为 3D [样本、时间步长、特征]:

    X_train1 = X_train1.reshape((X_train1.shape[0], 1, X_train1.shape[1]))
    X_val1 = X_val1.reshape((X_val1.shape[0], 1, X_val1.shape[1]))
    X_test1 = X_test1.reshape((X_test1.shape[0], 1, X_test1.shape[1]))
    X_train1.shape, y_train1.shape, X_val1.shape, y_val1.shape, 
    X_test1.shape, y_test1.shape
    # Output (500, 1, 5), (500,), (50, 1, 5), (50,), (218, 1, 5), (218,)
    
    2年前 0条评论