通过拟合,Keras LSTM模型的误差和损失保持不变。

时间 2019-02-22
阅读 34
点赞 0
收藏 0
连接ryanb

我有一个模型,但装配过程并没有使它变得更好。整个过程中误差保持不变,所有预测值均为1.0。

试图得到一个模型来预测一个时间序列中的下一个价值,价值是每周的销售额,长度是107

model = Sequential()
model.add(LSTM(units = 64, return_sequences = True, input_shape = (1, 50)))
model.add(Dropout(0.2))
model.add(LSTM(units = 64))
model.add(Dense(10))
model.add(Dense(1, activation = 'softmax'))

model.compile(loss = 'mean_squared_error', optimizer = 'rmsprop', metrics = ['mae'])

model.fit(x = train_x, y = train_y, batch_size = 23, epochs = 100)

Epoch 1/100
36/36 [==============================] - 1s - loss: 0.6570 - mean_absolute_error: 0.8036     
Epoch 2/100
36/36 [==============================] - 0s - loss: 0.6570 - mean_absolute_error: 0.8036     

Epoch 99/100
36/36 [==============================] - 0s - loss: 0.6570 - mean_absolute_error: 0.8036     
Epoch 100/100
36/36 [==============================] - 0s - loss: 0.6570 - mean_absolute_error: 0.8036  

model.predict(x = test_x)

array([[1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.],
   [1.]], dtype=float32)

帮帮我吧,你是我唯一的希望

尚无答案