Course 2 - Week 4 Assignment - Low Accuracy with given model params

Following the advise of using 2 epochs, image augmentation, no more than 2 Conv2D and 2 MaxPooling2D, expanding dimensions I can’t reach minimum accepted validation accuracy.

I have played around with learning rate [0.0001, 0.01, 0.007, 0.05, 0.1 etc.]
with # of filters in the Conv2 layer [64, 128, 512, 1024]
and adding and removing augmentation types [rotation_range=40, width_shift_range=0.2,
height_shift_range=0.2, shear_range=0.2, zoom_range=0.2, horizontal_flip=True,fill_mode=‘nearest’]

Could you please advise what kind of parameter tuning I could try?

Hi @Renata_Held ,
did you try increasing the units in your first Dense layer?

I tested the below options:
conv1 = 32, conv2 = 64, dense=512 - 0.0694 val_loss
conv1 = 128, conv2 = 64, dense=1024 - 0.0461 val_loss
conv1 = 64, conv2 = 64, dense=512 - 0.0432 val_loss
conv1 = 64, conv2 = 32, dense=512 - 0.0483 val_loss
conv1 = 128, conv2 = 512, dense=512 - 0.0432 val_loss
conv1 = 32, conv2 = 64, dense=1024 - 0.048 val_loss

I noticed it just now, can you double check the units of your second and last Dense layer. Remember that the number should be the same of the number of different letters in the alphabet.

Hi Maurizio,

I have 24 unique labels in the dataset.

I tested 24 & 25 & 26 classes in the output layer. Non of them changes the val_accuracy. The maximum I can achieve is 0.06

Hi Renata,
can you send me your file here, to see if we can understand what prevent your network from learning?

Hi Maurizio,

Attached is my file. Thank you for your support!

Exercise_4_Multi_class_classifier_Question-FINAL (1).py (5.3 KB)

1 Like

You instantiated ImageDataGenerator with no parameters, you should at least rescale. Hope it helps.

Maurizio

Hi Maurizio,

Thanks so much for the tip. The rescaling helped to improve the accuracy, however I continue to face issues with the submission.

the validation accuracy in the second epoch reached 0.8.
Still my submission fails due to low accuracy. Could there be a bug in the evaluation?

Hi Renata,
could be a bug, yes. Let me check. I suggest you to move on with your course, in the meantime.

Apparently this is a mysterious error,
some customers had success trying from time to time (at different time). Let me know if it eventually works.

Hi Maurizio,

Finally, this morning my submission passed :wink:
Thank you so much for your help!

Have a nice day!
Renata

Glad to be of any help, Renata. Good luck for the rest of your course. Best,

Maurizio

1 Like

I just wanted to share that I was having the same problem with chronic low accuracy around .05. The fix, in my case, was cleaning up the “missing category 9” problem in the labels data set. I’m not sure what the most pythonic way would have been, but I simply made a loop that added 1 to category labels 0-8, leaving 10-24 alone, and then I was left with a clean list of categories between 1 and 24. And voila, I instantly went from .05 accuracy to over .9. It didn’t occur to me how important that would be, or at least it wasn’t obvious to me that it was a step needed in the get_data function. Hope that’s helpful for someone else out there!

1 Like

@kcab98 This was really helpful thank you!

I didn’t realise that this was something we were supposed to correct for. In my code I had to lower all values greater than 8 by 1 so my values ranged from 0 to 23. When I did this the final result went from 0.05 to about 0.7.

Is this supposed to be automatically fixed by our code earlier on, or was the need for this fix mentioned somewhere else?

Just to note that the MNIST sign language dataset actually doesn’t contain any examples of class 9 (letter J) or class 25 (letter Z), because these involve motion. I used n_classes = 26 when training my model, to allow for label values from 0 to 25 i.e. covering all the letters. But the training data will only contain 23 possible letters. If I don’t do this, and use 23 as the number of classes, I see nan for my loss when using sparse_categorical_crossentropy.

2 Likes