蓝色:训练损失
黑色:验证损失
如果建模给了我这样的情节,那意味着什么?是否过拟合?我应该如何让它变得更好?
代码如下:
classifier = Sequential()
classifier.add(LSTM(
input_dim=72,
output_dim=50,
return_sequences=True))
classifier.add(Dropout(0.20))
classifier.add(LSTM(
100,
return_sequences=False))
classifier.add(Dropout(0.20))
classifier.add(Dense(
output_dim=1))
classifier.add(Activation('relu'))
classifier.compile(loss='mse', optimizer='rmsprop')
X_train = np.reshape(X_train, (X_train.shape[0], 1, X_train.shape[1]))
X_test = np.reshape(X_test, (X_test.shape[0], 1, X_test.shape[1]))
#classifier.fit(X_train, y_train, batch_size = 10, nb_epoch = 10)
cls_return = classifier.fit(X_train, y_train, batch_size=300, nb_epoch=500, validation_split=0.05)
history = cls_return.history
plt.plot(history['loss'], label='Training Loss', color='blue')
plt.plot(history['val_loss'], label='Validation Loss', color='black')
plt.show()
