How can data in the form of cell arrays be used to train CNN using deeplearning toolbox ?

28 views (last 30 days)
Hi everyone , Im new to the field of AI.
I have huge amounts of data arranged in the form of cell arrays. These data belong to 5 different classes and I want to use alexnet/googlenet to train my CNN for classification . Apparently The MATLAB deeplearning toolbox only supports image files. is there anyway to make it accept the cell arrays as input ? or do I need to change the form of the data ? any ideas ? can someone provide a simple code please.

Answers (1)

Johanna Pingel
Johanna Pingel on 12 Feb 2019
Are your image names in a cell array? If so, it's simply:
imds = imageDatastore(a); % where a is your cell array of filenames.
If your image data are in cell arrays, which I'm guessing is the case, it's slightly harder but not really. Write out the files into 5 subfolders based on your categories, then use imageDatastore.
%% write data out to files
for ii = 1:10 % or your number of files
imwrite(a{ii},"allfiles/category1/filename" + ii + ".png") % where a is your cell array of images
end
imageDatstore('allfiles/','IncludeSubfolders',true,'LabelSource','foldernames');
You'll have to change this code so that each file goes into the right folder based on category, but for me, it always comes back to datastores, since they are your simple input to training. Let me know if you have any questions
  4 Comments
Joana
Joana on 16 Dec 2019
Hi Johanna
I read your answer related to CNN, so i thought you might will be bale to guide for NN as well.? I tried it on the forum but nobody replied me. :(
I have to use NN ('patternnet') for 2-class classification problem. I have EEG data (of 1s, recorded at the sampling frequency of 1200) for two mental states in the following format: Number of EEG channels x Number of samples/points x Number of iterations = 22x1200x200; As the awake and asleep mental state was recorded for 100 times each.
I'm confused that how i should prepare the input signal for NN.?
In most of the literature the input layer is equal to the number of channels, but in the examples of NN database they follow the following format:
Input signal= samples x iterations
Targets= number of classes x iterations
Based on what i inferred from the examples i prepared my data in the following format:
Input Signal= 26400x 200
Targets= 1x 200
Although i'm getting acceptable results, but i am not sure if this the right way to it.?
I tried with the cell array as well, but it doesn't work with the patternet saying 'The timesteps are different for input signal and target'.
I will highly appreciate any guidence. :)

Sign in to comment.

Categories

Find more on Machine Learning and Deep Learning for Signals in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by