python - 训练准确度保持为零,验证准确度保持不变

我正在尝试制作时间序列深度学习模型,但我不知道为什么训练精度保持为零而验证精度保持不变。以下是代码、训练和准确度数据。如果有人帮助我,将不胜感激。 train_x.shape=(28,14,9)train_y.shape=(28,)

optimizer = keras.optimizers.Adam(lr=.0000001)
model = Sequential()

model.add(LSTM(units=16, activation='relu', return_sequences=True, input_shape=(train_x.shape[1], train_x.shape[2])))

model.add(Dropout(0.2))

model.add(Dense(units=8))
model.add(Dropout(0.2))
model.add(Dense(units=1))
model.compile(optimizer=optimizer, loss='mae', metrics=['accuracy'])

history = model.fit(train_x, train_y, epochs=10, batch_size=16, validation_split=0.28, verbose=1)

Epoch 1/10
2/2 [==============================] - 2s 256ms/step - loss: 1.0722 - accuracy: 0.0000e+00 - val_loss: 0.2569 - val_accuracy: 0.1250
Epoch 2/10
2/2 [==============================] - 0s 23ms/step - loss: 1.0573 - accuracy: 0.0000e+00 - val_loss: 0.2568 - val_accuracy: 0.1250
Epoch 3/10
2/2 [==============================] - 0s 24ms/step - loss: 1.0742 - accuracy: 0.0000e+00 - val_loss: 0.2568 - val_accuracy: 0.1250
Epoch 4/10
2/2 [==============================] - 0s 26ms/step - loss: 1.0680 - accuracy: 0.0000e+00 - val_loss: 0.2568 - val_accuracy: 0.1250
Epoch 5/10
2/2 [==============================] - 0s 24ms/step - loss: 1.0826 - accuracy: 0.0000e+00 - val_loss: 0.2568 - val_accuracy: 0.1250
Epoch 6/10
2/2 [==============================] - 0s 23ms/step - loss: 1.0595 - accuracy: 0.0000e+00 - val_loss: 0.2568 - val_accuracy: 0.1250
Epoch 7/10
2/2 [==============================] - 0s 28ms/step - loss: 1.0163 - accuracy: 0.0000e+00 - val_loss: 0.2568 - val_accuracy: 0.1250
Epoch 8/10
2/2 [==============================] - 0s 27ms/step - loss: 1.0415 - accuracy: 0.0000e+00 - val_loss: 0.2568 - val_accuracy: 0.1250
Epoch 9/10
2/2 [==============================] - 0s 30ms/step - loss: 1.0222 - accuracy: 0.0000e+00 - val_loss: 0.2568 - val_accuracy: 0.1250
Epoch 10/10
2/2 [==============================] - 0s 26ms/step - loss: 1.0404 - accuracy: 0.0000e+00 - val_loss: 0.2568 - val_accuracy: 0.1250

回答1

目标 y 和预测 p 之间的准确度为

#{ y_i == p_i }
 ----------------
       #y

鉴于您正在使用回归,什么是之间的准确性

y = 1, 1, 1, 1

p = 1.000000000000001, 1.000000000000001, 1.000000000000001, 1.000000000000001

?

解决方法:在使用准确度之前将您的指标更改为 mae,或将您的问题更改为实际分类。

相似文章