训练损失减少但准确性始终为 0?

Training loss decrease but accuracy is always 0?

我尝试训练一个模型,输入是 (3000,1) 向量,主要由负数组成,对输入进行归一化。输出是表示为向量 (2500,1) 的二值图像。

我的模型是这样的:

model = Sequential()
model.add(Dense(3000, input_shape=(x_train.shape[1:]), activation='linear'))
model.add(Dense(2500, activation='relu'))
model.add(Dense(2500, activation='relu'))
model.add(Dense(2500, activation='relu'))
model.add(Dense(2500, activation='relu'))
model.add(Dense(y_train.shape[1], activation='sigmoid'))
model.compile(optimizer=Adam(learning_rate=0.0001), loss='binary_crossentropy', metrics=['accuracy'])

结果是这样的:

Epoch 1/300
1/1 - 0s - loss: 0.6999 - accuracy: 0.0000e+00 - val_loss: 0.6930 - val_accuracy: 0.0000e+00
Epoch 2/300
1/1 - 0s - loss: 0.6843 - accuracy: 0.0000e+00 - val_loss: 0.6911 - val_accuracy: 0.0000e+00
Epoch 3/300
1/1 - 0s - loss: 0.6700 - accuracy: 0.0000e+00 - val_loss: 0.6944 - val_accuracy: 0.0000e+00
Epoch 4/300
1/1 - 0s - loss: 0.6515 - accuracy: 0.0000e+00 - val_loss: 0.7081 - val_accuracy: 0.0000e+00
Epoch 5/300
1/1 - 0s - loss: 0.6314 - accuracy: 0.0000e+00 - val_loss: 0.7349 - val_accuracy: 0.0000e+00
Epoch 6/300
1/1 - 0s - loss: 0.6147 - accuracy: 0.0000e+00 - val_loss: 0.7568 - val_accuracy: 0.0000e+00
Epoch 7/300
1/1 - 0s - loss: 0.6006 - accuracy: 0.0000e+00 - val_loss: 0.7615 - val_accuracy: 0.0000e+00
Epoch 8/300
1/1 - 0s - loss: 0.5865 - accuracy: 0.0000e+00 - val_loss: 0.7560 - val_accuracy: 0.0000e+00
Epoch 9/300
1/1 - 0s - loss: 0.5738 - accuracy: 0.0000e+00 - val_loss: 0.7515 - val_accuracy: 0.0000e+00
Epoch 10/300
1/1 - 0s - loss: 0.5637 - accuracy: 0.0000e+00 - val_loss: 0.7533 - val_accuracy: 0.0000e+00
Epoch 11/300
1/1 - 0s - loss: 0.5555 - accuracy: 0.0000e+00 - val_loss: 0.7629 - val_accuracy: 0.0000e+00
Epoch 12/300
1/1 - 0s - loss: 0.5490 - accuracy: 0.0000e+00 - val_loss: 0.7766 - val_accuracy: 0.0000e+00
Epoch 13/300
1/1 - 0s - loss: 0.5441 - accuracy: 0.0000e+00 - val_loss: 0.7877 - val_accuracy: 0.0000e+00
Epoch 14/300
1/1 - 0s - loss: 0.5402 - accuracy: 0.0000e+00 - val_loss: 0.7937 - val_accuracy: 0.0000e+00
Epoch 15/300
1/1 - 0s - loss: 0.5370 - accuracy: 0.0000e+00 - val_loss: 0.7966 - val_accuracy: 0.0000e+00
Epoch 16/300
1/1 - 0s - loss: 0.5346 - accuracy: 0.0000e+00 - val_loss: 0.8001 - val_accuracy: 0.0000e+00
Epoch 17/300
1/1 - 0s - loss: 0.5329 - accuracy: 0.0000e+00 - val_loss: 0.8065 - val_accuracy: 0.0000e+00
Epoch 18/300
1/1 - 0s - loss: 0.5315 - accuracy: 0.0000e+00 - val_loss: 0.8152 - val_accuracy: 0.0000e+00
Epoch 19/300
1/1 - 0s - loss: 0.5305 - accuracy: 0.0000e+00 - val_loss: 0.8253 - val_accuracy: 0.0000e+00
Epoch 20/300
1/1 - 0s - loss: 0.5294 - accuracy: 0.0000e+00 - val_loss: 0.8337 - val_accuracy: 0.0000e+00
Epoch 21/300
1/1 - 0s - loss: 0.5283 - accuracy: 0.0000e+00 - val_loss: 0.8408 - val_accuracy: 0.0000e+00
Epoch 22/300
1/1 - 0s - loss: 0.5271 - accuracy: 0.0000e+00 - val_loss: 0.8476 - val_accuracy: 0.0000e+00
Epoch 23/300
1/1 - 0s - loss: 0.5259 - accuracy: 0.0000e+00 - val_loss: 0.8550 - val_accuracy: 0.0000e+00
Epoch 24/300
1/1 - 0s - loss: 0.5247 - accuracy: 0.0000e+00 - val_loss: 0.8625 - val_accuracy: 0.0000e+00
Epoch 25/300
1/1 - 0s - loss: 0.5235 - accuracy: 0.0000e+00 - val_loss: 0.8705 - val_accuracy: 0.0000e+00
Epoch 26/300
1/1 - 0s - loss: 0.5223 - accuracy: 0.0000e+00 - val_loss: 0.8794 - val_accuracy: 0.0000e+00
Epoch 27/300
1/1 - 0s - loss: 0.5211 - accuracy: 0.0000e+00 - val_loss: 0.8872 - val_accuracy: 0.0000e+00
Epoch 28/300
1/1 - 0s - loss: 0.5200 - accuracy: 0.0000e+00 - val_loss: 0.8940 - val_accuracy: 0.0000e+00
Epoch 29/300
1/1 - 0s - loss: 0.5188 - accuracy: 0.0000e+00 - val_loss: 0.8982 - val_accuracy: 0.0000e+00

准确性和有效性没有提高。验证损失在某个点后开始增加。

即使我尝试这个网络非常小的数据集(17 个数据集),它也不会顺利收敛。

然后我尝试决策树回归,决策树的分数是负数。我检查了数据集,但没有发现任何错误。有什么问题吗,你能帮帮我吗?

您的任务很难让模型获得良好的准确性。

一个输出中有 2500 个值,如果其中一个值错误,则每个数据样本的输出精度将为零。你的任务不需要你计算准确率,你可以在这里只关注损失。

或者您可以手动定义特定输出的准确度,必须正确预测这 2500 个值中的多少才能称为正确预测。例如这些值中的 50% 正确分类,每个值的误差小于 0.5。