user12921900
user12921900

Reputation:

Why training accuracy is not improving?

I'm tying to do some image classification training. Just got to work something. but no matter what neural network I use, still I get no progress. The accuracy is always stuck.

If you can get me any suggestion I will be very glad. I already tried to tweak batch size, etc...

You can find all the data and content here: https://github.com/marcusdiy/testai

Train for 31 steps, validate for 4 steps
Epoch 1/10
31/31 [==============================] - 11s 352ms/step - loss: -51.9861 - accuracy: 0.0950 - val_loss: -62.1700 - val_accuracy: 0.0833
Epoch 2/10
31/31 [==============================] - 10s 335ms/step - loss: -54.3329 - accuracy: 0.0942 - val_loss: -62.1700 - val_accuracy: 0.0833
Epoch 3/10
31/31 [==============================] - 10s 334ms/step - loss: -54.3329 - accuracy: 0.0942 - val_loss: -62.1700 - val_accuracy: 0.0833
Epoch 4/10
31/31 [==============================] - 11s 352ms/step - loss: -54.3329 - accuracy: 0.0942 - val_loss: -62.1700 - val_accuracy: 0.0833
Epoch 5/10
31/31 [==============================] - 10s 330ms/step - loss: -54.3329 - accuracy: 0.0942 - val_loss: -62.1700 - val_accuracy: 0.0833
Epoch 6/10
31/31 [==============================] - 10s 331ms/step - loss: -54.3329 - accuracy: 0.0942 - val_loss: -62.1700 - val_accuracy: 0.0833
Epoch 7/10
31/31 [==============================] - 10s 330ms/step - loss: -54.3329 - accuracy: 0.0942 - val_loss: -62.1700 - val_accuracy: 0.0833
Epoch 8/10
31/31 [==============================] - 11s 351ms/step - loss: -54.3329 - accuracy: 0.0942 - val_loss: -62.1700 - val_accuracy: 0.0833
Epoch 9/10
31/31 [==============================] - 11s 355ms/step - loss: -54.3329 - accuracy: 0.0942 - val_loss: -62.1700 - val_accuracy: 0.0833
Epoch 10/10
31/31 [==============================] - 11s 364ms/step - loss: -54.3329 - accuracy: 0.0942 - val_loss: -62.1700 - val_accuracy: 0.0833

Thanks!

Upvotes: 1

Views: 124

Answers (1)

Thibault Bacqueyrisses
Thibault Bacqueyrisses

Reputation: 2331

I don't really understand what you are doing, it's looks like you are performing a multi-label classification using Sigmoid and binary_crossentropy, which, as the name suggests allows to do a binary classification, with only 2 labels.

In order to have a working model, you have to change your binary model to a multi class one :

  • Change your last Dense layer to : classifier.add(Dense(output_dim=NB_CLASS, activation='softmax'))
  • Change your loss to be : classifier.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
  • Change your dataflow to be :
training_set = train_datagen.flow_from_directory(
        'train', target_size=(64, 64), batch_size=32, class_mode='categorical')

test_set = test_datagen.flow_from_directory(
        'test', target_size=(64, 64), batch_size=32, class_mode='categorical')

Keep me in touch !

Upvotes: 1

Related Questions