这个 LSTM 模型是欠拟合、过拟合还是其他?

Is this LSTM model underfitting, overfitting or something else?

我正在使用 Keras LSTM 模型对股票进行序列预测。模型拟合历史显示了一个我以前很少看到的不同图表。

下面是我的代码:

keras_callbacks = [ EarlyStopping(监控='val_accuracy',模式='max',冗长=1,耐心=50), ModelCheckpoint(filepath=model_path, monitor='val_loss', save_best_only=True, verbose=1, mode='min', initial_value_threshold=0.1) ]

batch_size = 10
model = Sequential()
model.add(LSTM(128, input_shape=(X.shape[1], 1)))
model.add(BatchNormalization())
model.add(Dense(96))
model.add(Dense(y.shape[1], activation='sigmoid'))
model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])

history = model.fit(X, y, epochs=300, validation_split=0.33, batch_size=batch_size, verbose=2,
                    callbacks=keras_callbacks)

# plot the training history
plt.plot(history.history['loss'], label='Training Loss')
plt.plot(history.history['val_loss'], label='Validation Loss')
plt.legend()
plt.xlabel('Epochs')
plt.ylabel('Mean Squared Error')
plt.savefig('c:/tmp/stock/nyse1/' + basename + '.png')
plt.show()

模型的输入是一个长短不一的列表,而输出只是一只股票的方向,1表示做多,0表示做空。

有人可以解释图片的含义并建议我如何改进吗?

谢谢!

乔纳森,

我对 Adam 和 LSTM 也有类似的问题。我将振荡减少了 increasing the value of epsilon and reducing the value of the learning rate for Adam. I would also suggest to reduce your batch size but it is already quite low. This question 有一个有趣的相关答案。

查尔斯