我正在尝试训练LSTM,以预测一系列数字的一些数字。我的X数据集具有33个功能,而我的Y数据集则具有4个变量,我必须为每个X示例预测。例如:
XDF:
ydf:
在我将x,y转换为numpy数组并重塑数据后,我构建的数据我以下模型:
我得到以下结果,损失巨大和明显的过度拟合。有什么想法我做错了什么,我得到了这些结果?谢谢。
XDF:
ydf: https://drive.google.com/file/d/1rkjwl1fiiqdyjkrvl7zqktoxie8ftbxa/view?usp = sharing?usp = sharing
更新
我的代码和以下方式更新了,它似乎可以更好地工作。仍然巨大的损失和过度匹配,但是经过一些时代,似乎有一段时间的效果很好。关于如何减少损失和过度拟合的任何建议将不胜感激。
X = X.reshape((X.shape[0], 33, 1)) # (5850, 33, 1)
model = tf.keras.Sequential()
model.add(layers.LSTM(50, activation='relu', input_shape=(33, 1)))
model.add(layers.Dense(4))
model.add(layers.Dense(4))
model.add(layers.Dense(4))
early_stopping = EarlyStopping(monitor='val_loss', patience=42)
model.compile(optimizer=tf.keras.optimizers.Adam(0.01), loss=tf.keras.losses.MeanSquaredError(), metrics=['accuracy'])
model.fit(X, y, epochs=200, verbose=1, validation_split = 0.2)
I am trying to train an LSTM to predict some numbers from a sequence of number. My X dataset has 33 features and my Y dataset has 4 variables that I have to predict for each X sample. For example:
Xdf:

Ydf:

After I turn X, y to numpy arrays and reshape the data I build the below model:

I get the following results with huge loss and distinct overfitting. Any ideas what I am doing wrong and I am getting these results? Thanks.

Xdf: https://drive.google.com/file/d/1wH56E0M3ok1MGWzU6FGKgDJF7EZfL_7f/view?usp=sharing
ydf: https://drive.google.com/file/d/1RkjWl1FIiQDyjkRvl7ZQKTOXIE8FtBXA/view?usp=sharing
UPDATE
I edited my code the following way and it seems to bee working a tiny bit better. Still huge loss and overfitting but after some epochs it seemed it worked fine for a while. Any suggestions on how to reduce loss and overfitting would be appreciated.
X = X.reshape((X.shape[0], 33, 1)) # (5850, 33, 1)
model = tf.keras.Sequential()
model.add(layers.LSTM(50, activation='relu', input_shape=(33, 1)))
model.add(layers.Dense(4))
model.add(layers.Dense(4))
model.add(layers.Dense(4))
early_stopping = EarlyStopping(monitor='val_loss', patience=42)
model.compile(optimizer=tf.keras.optimizers.Adam(0.01), loss=tf.keras.losses.MeanSquaredError(), metrics=['accuracy'])
model.fit(X, y, epochs=200, verbose=1, validation_split = 0.2)
发布评论