我正在尝试在Keras训练LSTM,但似乎不合时宜。
adam = Adam(learning_rate=0.1, beta_1=0.9, beta_2=0.999, amsgrad=False)
model = Sequential()
model.add(LSTM(124, input_shape=(trainX.shape[1], trainX.shape[2])))
model.add(Dense(62))
model.compile(loss='mse', optimizer=adam)
history = model.fit(
trainX, trainY, epochs=100, batch_size=431, validation_data=(testX, testY), verbose=2, shuffle=False)
我的数据代表了一系列数据泄露事件,其中前0-7列是公司类型,而0-51列是美国各州的热点。我的目标是根据此数据集预测下一次违规。
date size 0 1 2 3 4 5 6 7 0 1 ... 40 41 42 43 44 45 46 47 48 49 50 51
0 1 32000 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
1 2 3500 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
2 3 1400000 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
3 4 120000 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
4 5 59000 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
每个时期花费的时间为0s,测试数据的损失基本上保持不变。这是我模型的最后10个时期。
Epoch 90/100
- 0s - loss: 130445623221660.6562 - val_loss: 5098486354074.1934
Epoch 91/100
- 0s - loss: 130445622565865.9375 - val_loss: 5098486346506.8730
Epoch 92/100
- 0s - loss: 130445622191126.0625 - val_loss: 5098485465787.7988
Epoch 93/100
- 0s - loss: 130445621816386.2344 - val_loss: 5098484149524.7568
Epoch 94/100
- 0s - loss: 130445621347961.4219 - val_loss: 5098484141613.4668
Epoch 95/100
- 0s - loss: 130445620785851.6406 - val_loss: 5098483698846.1465
Epoch 96/100
- 0s - loss: 130445620317426.8281 - val_loss: 5098483255046.9189
Epoch 97/100
- 0s - loss: 130445619942686.9844 - val_loss: 5098482810903.7217
Epoch 98/100
- 0s - loss: 130445619380577.2188 - val_loss: 5098481494640.6797
Epoch 99/100
- 0s - loss: 130445619005837.3750 - val_loss: 5098481050841.4521
Epoch 100/100
- 0s - loss: 130445618724782.5000 - val_loss: 5098480170466.3477
date size 0 1 2 3 4 5 6 7 0 1 ... 40 41 42 43 44 45 46 47 48 49 50 51
0 1 1.066633e-05 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
1 2 1.166333e-06 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
2 3 4.666663e-04 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
3 4 3.999967e-05 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
4 5 1.966633e-05 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
输出:
Epoch 90/100
- 0s - loss: 1425.8638 - val_loss: 8939.7717
Epoch 91/100
- 0s - loss: 1397.5078 - val_loss: 8847.1606
Epoch 92/100
- 0s - loss: 1403.1658 - val_loss: 8756.0660
Epoch 93/100
- 0s - loss: 1453.6541 - val_loss: 9025.9873
Epoch 94/100
- 0s - loss: 1435.4252 - val_loss: 8928.1981
Epoch 95/100
- 0s - loss: 1414.3660 - val_loss: 8830.8435
Epoch 96/100
- 0s - loss: 1391.6843 - val_loss: 8734.7518
Epoch 97/100
- 0s - loss: 1365.5961 - val_loss: 8655.9235
Epoch 98/100
- 0s - loss: 1431.5669 - val_loss: 8896.3086
Epoch 99/100
- 0s - loss: 1409.6963 - val_loss: 9031.4488
Epoch 100/100
- 0s - loss: 1466.6886 - val_loss: 9088.9677