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

조회 수: 30 (최근 30일)
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.

답변 (1개)

Johanna Pingel
Johanna Pingel 2019년 2월 12일
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
Johanna Pingel
Johanna Pingel 2019년 2월 15일
After re-reading your question, I realized I made up the idea that your data was images, since that's what I work on all day. You're looking for a time series example for deep learning then:
Perhaps one of these examples is close? The good news is it looks like some of these examples use cell arrays as input!
Joana
Joana 2019년 12월 16일
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. :)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by