Training loss decrease but accuracy is always 0?

Issue

I try to train a model, input is (3000,1) vector that is consist of negative numbers mostly, inormalize input. Output is binary image which is represented as vector (2500,1).

My model is like this:

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'])

Result is like this:

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

Accuracy and validation did not increase. Validation loss started to increase after some point.

Even when i try this network really small dataset(17 daatset), it does not converge smoothly.

Then i try decision tree regressor, score of the decision tree was negative number. I check the dataset, but i could not find something wrong. what could be wrong, can you please help me?

Solution

your task is hard for model to get good accuracy.

you have 2500 values in one output if one of these values is wrong then output will be zero accuracy for each data sample. your task dont require you to calculate accuracy, you can only focus on loss here.

Or you can manually define what accuracy is for your specific output, how many of these 2500 values have to be correctly predicted to be called correct prediction. such as 50% of these values correctly classified with less then 0.5 error per value.

Answered By – faheem

Answer Checked By – Robin (AngularFixing Admin)

Leave a Reply

Your email address will not be published.