Deep learning: how to labels data using a datastore?

11 visualizzazioni (ultimi 30 giorni)
Hello,
I have some data (close to 500 *.mat files, size 3620x1, corresponding to measured signals) which are classified into two folders. Folder names represent the status of the data. I would like to perfom some deep learning on it: to do this, I tried to create a datastore using fileDatastore, but I don't know how to label all data with the folder name. Is it any possibility?
I know I can add 'LabelSource' using imageDatastore, but the Deep Network Designer did not work with such a datastore with *.mat files inside... Is anybody faced this issue?

Risposte (1)

Ganapathi Subramanian R
Ganapathi Subramanian R il 4 Ott 2023
Hi Arnaud,
I understand that you are working on Deep Learning project and have an issue in labelling data using a datastore. Please provide the ‘FileExtensions’ and ‘ReadFcn’ Name-Value pairs in the ‘imageDatastore’ function to specify that the files are ‘.mat’ files and provide a custom function that can extract the matrix from each MAT-file.
dataPath = fullfile('data');
imds = imageDatastore(dataPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames','FileExtensions',{'.mat'},'ReadFcn',@my_read_fcn);
function res = my_read_fcn(f)
s = load(f);
res = s.NameOfMatrixVariable;
end
Please refer the below documentation for further information regarding ‘imageDatastore’ function.

Community Treasure Hunt

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

Start Hunting!

Translated by