MATLAB Answers

How can I improve my image classification CNN?

10 views (last 30 days)
My dataset is about 750 daisies and 1000 dandelions. They're input as 512x512 color images. I preprocess them by scaling them down to 256x256, making them grayscale, and running an edge detector. I split them into 70% training images and 30% verification images, then run them through a patternnet NN with layer options
layers = [
imageInputLayer([256 256 1])
convolution2dLayer(3,8,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,32,'Padding','same')
batchNormalizationLayer
reluLayer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
and training options
options = trainingOptions('adam', ...
'ValidationData', imgValidation, ...
'Plots', 'training-progress');
where imgValidation is the 30% of images I split for validation.
The plot of the training looks like this:
So I believe it is overfitting, but I'm not entirely sure how to fix that.
I think it's likely that there is room for improvement in the layer definitions. I took them with minor changes from this example https://www.mathworks.com/help/deeplearning/ug/create-simple-deep-learning-network-for-classification.html .
Thanks for taking a look at this. Any help is appreciated!

Accepted Answer

Divya Gaddipati
Divya Gaddipati on 8 Mar 2021
There are a lot of examples in the documentation that you can refer to for the task of Image classification using deep learning. Here are a few to get started:
1) Image category classification (This is most relevant to your task)
2) The most common method used is Transfer Learning. You can refer to this example to understand more on transfer learning, and this page which provides the list of the available pretrained models.
3) You can also use the Deep Network Designer that provides all these pretrained models. Refer to this link to understand more.
4) Additionally, you can also refer to the documentation page that explains some of the tips and tricks while training a deep learning network.
  1 Comment
Mackenzie Barrett
Mackenzie Barrett on 8 Mar 2021
I had been using the image category classification tutorial, but not having much success. The other links have been a great help, thanks! Validation accuracy is already significantly improved and it's not done training yet.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!