CNN with data_set
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
SRUTHY SKARIA
el 21 de Feb. de 2018
Comentada: Nazmun Nahar Khan
el 3 de Sept. de 2021
Hi,
I want to train CNN with 2 channel data set which is stored in a cell array in a .mat file. have 4 such mat files in 4 folders which are used for labelling. I want to read those cellarray data from the mat files using imageDatastore. I was able to read the entire mat file, but I am having trouble reading the cell array data, which are actually the inputs for my training. Would anyone able to help me regarding this.
Thanks in Advance.
2 comentarios
Respuesta aceptada
Javier Pinzón
el 21 de Feb. de 2018
Editada: Javier Pinzón
el 21 de Feb. de 2018
hello Sruthy
I checked your request and problem, lets begin with an example from the call of the data.
location = 'Data/Train';
imds = imageDatastore(location, 'FileExtensions', '.mat', 'IncludeSubfolders',1, ...
'LabelSource','foldernames');
In the folder "Train" i have the 4 subfolders of each category, and in each subfolder, there are 100 .mat file with the data.
Then, parametrize the store variable:
countEachLabel(imds)
trainingDS = imds;
% Convert labels to categoricals
trainingDS.Labels = categorical(trainingDS.Labels);
trainingDS.ReadFcn = @readFcn1;
About the readFcn1, you only have to copy this in your read function:
function I = readFcn1(filename)
% Load data and get matrices from the structure
I = load(filename);
I = I.signaldata;
However, there is an important annotation that need to take into account, If you can see, I save the data in a variable called "I", and then, rewrite the variable with a "I.signaldata". The parameter signaldata is THE NAME OF YOUR VARIABLE IN THE .mat file, so you had to save all data with the same name in the work space, so when you load the mat file, it will have the same name for matlab, for example: I saved my ".mat" files with the name (signal1, signal2, signal3.mat... and so) but the variable in it is called "signaldata", so, all .mat have the same variable name but with different data inside.
If you dont call your variable iside the mat file with the same name, it make complicated to read the data.
you asked for the "filename" variable... no, it keep that name, because is called directly from the function.
Also, i highly recommend you to save the data inside of your variable as an "double array", because the CNN cant read "cell, struct", and so as input data. An also, the CNN only work with 1 or 3 channels, not with 2 or +4. so you would need to reorganize your data in 1 or 3 channels.
Hope it helps
Regards
Javier
4 comentarios
Nazmun Nahar Khan
el 3 de Sept. de 2021
Hi,
So I am also facing same issues. I also tried to use readfc1 as you mentioned above. Unfortunately, I am getting an error.
Error using trainNetwork (line 170)
Reference to non-existent field 'signaldata'.
Error in trainingCNN (line 70)
trainedNet = trainNetwork(imdsTrain,layers ,options);
Caused by:
Error using matlab.io.datastore.ImageDatastore/read (line 77)
Error using ReadFcn @readFcn1 for file:
C:\Users\data analysis\100\High\Data100_102.mat
Reference to non-existent field 'signaldata'.
Error in trainingCNN>readFcn1 (line 88)
I = I.signaldata;
So how can I fix it?
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!