# Improving Validation Loss and Accuracy for CNN

I am new to CNNs and need some direction as I can't get any improvement in my validation results.

I am trying to do binary image classification on pictures of groups of small plastic pieces to detect defects. Unfortunately, I am unable to share pictures, but each picture is a group of round white pieces on a black background. One class includes pictures with all normal pieces, the other class includes pictures where two pieces in the picture are stuck together - and therefore defective.

I have a small data set: 250 pictures per class for training, 50 per class for validation, 30 per class for testing. The pictures are 256 x 256 pixels, although I can have a different resolution if needed.

Here is my CNN architecture:

classifier = Sequential()

# Treatment done to images:
train_datagen = ImageDataGenerator(rescale=1./255,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True)
validation_datagen = ImageDataGenerator(rescale=1./255)

train_batch_size = 10
val_batch_size = 10
num_epochs = 100
train_images = 250
val_images = 50

classifier.fit_generator(training_set,
steps_per_epoch=train_images // train_batch_size
epochs=num_epochs,
validation_data=validation_set,
validation_steps=val_images // val_batch_size)


Here are the results:

It's overfitting and the validation loss increases over time. The validation accuracy is not better than a coin toss, so clearly my model is not learning anything.

I have tried different values of dropout and L1/L2 for both the convolutional and FC layers, but validation accuracy is never better than a coin toss.

I understand that my data set is very small, but even getting a small increase in validation would be acceptable as long as my model seems correct, which it doesn't at this point.

Update: Switching from binary to multiclass classification helped raise the validation accuracy and reduced the validation loss, but it still grows consistenly:

• Instead of binary classification, make a multiclass classification with two classes. You are using relu with sigmoid which might cause the instability. I insist to use softmax at the output layer. – Shubham Panchal Jul 19 '19 at 0:30
• Thank you, @ShubhamPanchal. I switched to multiclass classification and am using softmax with relu instead of sigmoid, which helped improved the results slightly. However, the validation loss continues increasing instead of decreasing. Do you recommend making any other changes to the architecture to solve it? – Irina Jul 19 '19 at 14:15