MATLAB Answers

Convolution Neural Network on my dataset

5 views (last 30 days)
Muhammad Usman
Muhammad Usman on 27 Nov 2017
Answered: Javier Pinzón on 1 Dec 2017
Hey all, My data set contains around 1200 entries. Each entry contains 81 images in it. I have one folder (it contains 81 images for one record) and a class label against it. I am confused, how do I give it to my CNN?
Thanks Already!

Answers (1)

Javier Pinzón
Javier Pinzón on 1 Dec 2017
Hello Muhammad,
Iif i understood, you have 1200 categories, and 81 data information in each category, split in folders.
If you what to get the categories, the best way i to locate ALL the category folders in 1 main folder, for example "/training/" folder, i that way you can get all the Folders labels automatically using this code line:
%%Training Dataset
location = '*path*/training';
imds = imageDatastore(location,'IncludeSubfolders',1,'LabelSource','foldernames');
*path is the complet address to get the training folder. It will give you all the data directions and labels writen en each folder.
To enter it to the CNN, you can use this other part:
trainingDS = imds;
% Convert labels to categoricals
trainingDS.Labels = categorical(trainingDS.Labels);
So you get a imagedatastore variable with "categories", and finally, enter it to the network with your defined layers and options:
[net, info] = trainNetwork(trainingDS, layers, opts);
Hope it helps, and thanks if this answer is accepted.
Any question, feel free to ask.

Community Treasure Hunt

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

Start Hunting!